mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
683424cce8
Will be needed for the block test from `dev`.
41 lines
831 B
Go
41 lines
831 B
Go
package transaction
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
)
|
|
|
|
// StateTX represents a state transaction.
|
|
type StateTX struct {
|
|
Descriptors []*StateDescriptor
|
|
}
|
|
|
|
// DecodeBinary implements the Payload interface.
|
|
func (tx *StateTX) DecodeBinary(r io.Reader) error {
|
|
br := util.BinReader{R: r}
|
|
lenDesc := br.ReadVarUint()
|
|
if br.Err != nil {
|
|
return br.Err
|
|
}
|
|
for i := 0; i < int(lenDesc); i++ {
|
|
tx.Descriptors[i] = &StateDescriptor{}
|
|
if err := tx.Descriptors[i].DecodeBinary(r); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeBinary implements the Payload interface.
|
|
func (tx *StateTX) EncodeBinary(w io.Writer) error {
|
|
return nil
|
|
}
|
|
|
|
func (tx *StateTX) Size() int {
|
|
sz := util.GetVarSize(uint64(len(tx.Descriptors)))
|
|
for _, desc := range tx.Descriptors {
|
|
sz += desc.Size()
|
|
}
|
|
return sz
|
|
}
|