forked from TrueCloudLab/neoneo-go
361724a33e
Simplify error handling.
33 lines
671 B
Go
33 lines
671 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
|
|
}
|