From 06b29e409c7591afd43fd3f0ee61bb2ffd86ef64 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 16 Sep 2020 13:39:53 +0300 Subject: [PATCH] transaction: remove Attribute.Data field --- pkg/core/transaction/attribute.go | 12 ------------ pkg/core/transaction/transaction_test.go | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/pkg/core/transaction/attribute.go b/pkg/core/transaction/attribute.go index 28f6d0c42..26f9d2737 100644 --- a/pkg/core/transaction/attribute.go +++ b/pkg/core/transaction/attribute.go @@ -1,7 +1,6 @@ package transaction import ( - "encoding/base64" "encoding/json" "errors" "fmt" @@ -12,28 +11,23 @@ import ( // Attribute represents a Transaction attribute. type Attribute struct { Type AttrType - Data []byte } // attrJSON is used for JSON I/O of Attribute. type attrJSON struct { Type string `json:"type"` - Data string `json:"data"` } // DecodeBinary implements Serializable interface. func (attr *Attribute) DecodeBinary(br *io.BinReader) { attr.Type = AttrType(br.ReadB()) - var datasize uint64 switch attr.Type { case HighPriority: default: br.Err = fmt.Errorf("failed decoding TX attribute usage: 0x%2x", int(attr.Type)) return } - attr.Data = make([]byte, datasize) - br.ReadBytes(attr.Data) } // EncodeBinary implements Serializable interface. @@ -50,7 +44,6 @@ func (attr *Attribute) EncodeBinary(bw *io.BinWriter) { func (attr *Attribute) MarshalJSON() ([]byte, error) { return json.Marshal(attrJSON{ Type: attr.Type.String(), - Data: base64.StdEncoding.EncodeToString(attr.Data), }) } @@ -61,10 +54,6 @@ func (attr *Attribute) UnmarshalJSON(data []byte) error { if err != nil { return err } - binData, err := base64.StdEncoding.DecodeString(aj.Data) - if err != nil { - return err - } switch aj.Type { case "HighPriority": attr.Type = HighPriority @@ -72,6 +61,5 @@ func (attr *Attribute) UnmarshalJSON(data []byte) error { return errors.New("wrong Type") } - attr.Data = binData return nil } diff --git a/pkg/core/transaction/transaction_test.go b/pkg/core/transaction/transaction_test.go index fd7705477..45157ced4 100644 --- a/pkg/core/transaction/transaction_test.go +++ b/pkg/core/transaction/transaction_test.go @@ -115,7 +115,7 @@ func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) { Version: 0, Signers: []Signer{{Account: util.Uint160{1, 2, 3}}}, Script: []byte{1, 2, 3, 4}, - Attributes: []Attribute{{Type: HighPriority, Data: []byte{}}}, + Attributes: []Attribute{{Type: HighPriority}}, Scripts: []Witness{}, Trimmed: false, }