2018-03-21 16:11:04 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
2019-09-16 09:18:13 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-03-21 16:11:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (s *StateDescriptor) DecodeBinary(r *io.BinReader) {
|
2019-09-16 09:18:13 +00:00
|
|
|
r.ReadLE(&s.Type)
|
2018-03-21 16:11:04 +00:00
|
|
|
|
2019-12-06 15:37:37 +00:00
|
|
|
s.Key = r.ReadVarBytes()
|
|
|
|
s.Value = r.ReadVarBytes()
|
2019-09-16 09:18:13 +00:00
|
|
|
s.Field = r.ReadString()
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (s *StateDescriptor) EncodeBinary(w *io.BinWriter) {
|
2019-09-16 09:18:13 +00:00
|
|
|
w.WriteLE(s.Type)
|
2019-11-22 10:34:06 +00:00
|
|
|
w.WriteVarBytes(s.Key)
|
|
|
|
w.WriteVarBytes(s.Value)
|
2019-09-16 09:18:13 +00:00
|
|
|
w.WriteString(s.Field)
|
2018-03-21 16:11:04 +00:00
|
|
|
}
|