diff --git a/pkg/core/transaction/attr_usage.go b/pkg/core/transaction/attr_usage.go deleted file mode 100644 index ab9a5f6da..000000000 --- a/pkg/core/transaction/attr_usage.go +++ /dev/null @@ -1,10 +0,0 @@ -package transaction - -//go:generate stringer -type=AttrUsage - -// AttrUsage represents the purpose of the attribute. -type AttrUsage uint8 - -// List of valid attribute usages (none for preview3). -//const ( -//) diff --git a/pkg/core/transaction/attribute.go b/pkg/core/transaction/attribute.go index d0ef1d3c6..e61f24085 100644 --- a/pkg/core/transaction/attribute.go +++ b/pkg/core/transaction/attribute.go @@ -10,26 +10,26 @@ import ( // Attribute represents a Transaction attribute. type Attribute struct { - Usage AttrUsage - Data []byte + Type AttrType + Data []byte } // attrJSON is used for JSON I/O of Attribute. type attrJSON struct { - Usage string `json:"usage"` - Data string `json:"data"` + Type string `json:"type"` + Data string `json:"data"` } // DecodeBinary implements Serializable interface. func (attr *Attribute) DecodeBinary(br *io.BinReader) { - attr.Usage = AttrUsage(br.ReadB()) + attr.Type = AttrType(br.ReadB()) var datasize uint64 /** - switch attr.Usage { + switch attr.Type { default: - br.Err = fmt.Errorf("failed decoding TX attribute usage: 0x%2x", int(attr.Usage)) + br.Err = fmt.Errorf("failed decoding TX attribute usage: 0x%2x", int(attr.Type)) return } */ @@ -39,18 +39,18 @@ func (attr *Attribute) DecodeBinary(br *io.BinReader) { // EncodeBinary implements Serializable interface. func (attr *Attribute) EncodeBinary(bw *io.BinWriter) { - bw.WriteB(byte(attr.Usage)) - switch attr.Usage { + bw.WriteB(byte(attr.Type)) + switch attr.Type { default: - bw.Err = fmt.Errorf("failed encoding TX attribute usage: 0x%2x", attr.Usage) + bw.Err = fmt.Errorf("failed encoding TX attribute usage: 0x%2x", attr.Type) } } // MarshalJSON implements the json Marshaller interface. func (attr *Attribute) MarshalJSON() ([]byte, error) { return json.Marshal(attrJSON{ - Usage: "", // attr.Usage.String() when we're to have some real attributes - Data: base64.StdEncoding.EncodeToString(attr.Data), + Type: "", // attr.Type.String() when we're to have some real attributes + Data: base64.StdEncoding.EncodeToString(attr.Data), }) } @@ -66,9 +66,9 @@ func (attr *Attribute) UnmarshalJSON(data []byte) error { return err } /** - switch aj.Usage { + switch aj.Type { default: - return errors.New("wrong Usage") + return errors.New("wrong Type") } */ diff --git a/pkg/core/transaction/attrtype.go b/pkg/core/transaction/attrtype.go new file mode 100644 index 000000000..db2d7a35e --- /dev/null +++ b/pkg/core/transaction/attrtype.go @@ -0,0 +1,10 @@ +package transaction + +//go:generate stringer -type=AttrType + +// AttrType represents the purpose of the attribute. +type AttrType uint8 + +// List of valid attribute types (none for preview3). +//const ( +//)