mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 19:33:36 +00:00
52fa41a12a
* added account_state + changed ECPoint to PublicKey * account state persist * in depth test for existing accounts. * implemented GetTransaction. * added enrollment TX * added persist of accounts and unspent coins * bumped version -> 0.32.0
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package transaction
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"io"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
)
|
|
|
|
// DescStateType represents the type of StateDescriptor.
|
|
type DescStateType uint8
|
|
|
|
// Valid DescStateType constants.
|
|
const (
|
|
Account DescStateType = 0x40
|
|
Validator DescStateType = 0x48
|
|
)
|
|
|
|
// StateDescriptor ..
|
|
type StateDescriptor struct {
|
|
Type DescStateType
|
|
Key []byte
|
|
Value []byte
|
|
Field string
|
|
}
|
|
|
|
// DecodeBinary implements the Payload interface.
|
|
func (s *StateDescriptor) DecodeBinary(r io.Reader) error {
|
|
if err := binary.Read(r, binary.LittleEndian, &s.Type); err != nil {
|
|
return err
|
|
}
|
|
|
|
keyLen := util.ReadVarUint(r)
|
|
s.Key = make([]byte, keyLen)
|
|
if err := binary.Read(r, binary.LittleEndian, s.Key); err != nil {
|
|
return err
|
|
}
|
|
|
|
valLen := util.ReadVarUint(r)
|
|
s.Value = make([]byte, valLen)
|
|
if err := binary.Read(r, binary.LittleEndian, s.Value); err != nil {
|
|
return err
|
|
}
|
|
|
|
fieldLen := util.ReadVarUint(r)
|
|
field := make([]byte, fieldLen)
|
|
if err := binary.Read(r, binary.LittleEndian, field); err != nil {
|
|
return err
|
|
}
|
|
s.Field = string(field)
|
|
|
|
return nil
|
|
}
|
|
|
|
// EncodeBinary implements the Payload interface.
|
|
func (s *StateDescriptor) EncodeBinary(w io.Writer) error {
|
|
return nil
|
|
}
|