neoneo-go/pkg/core/transaction/state.go
Roman Khimov d1a4e43c48 io: redo Serializable to return errors in BinReader/BinWriter
Further simplifies error handling.
2019-09-17 13:21:52 +03:00

28 lines
688 B
Go

package transaction
import (
"github.com/CityOfZion/neo-go/pkg/io"
)
// StateTX represents a state transaction.
type StateTX struct {
Descriptors []*StateDescriptor
}
// DecodeBinary implements Serializable interface.
func (tx *StateTX) DecodeBinary(r *io.BinReader) {
lenDesc := r.ReadVarUint()
tx.Descriptors = make([]*StateDescriptor, lenDesc)
for i := 0; i < int(lenDesc); i++ {
tx.Descriptors[i] = &StateDescriptor{}
tx.Descriptors[i].DecodeBinary(r)
}
}
// EncodeBinary implements Serializable interface.
func (tx *StateTX) EncodeBinary(w *io.BinWriter) {
w.WriteVarUint(uint64(len(tx.Descriptors)))
for _, desc := range tx.Descriptors {
desc.EncodeBinary(w)
}
}