mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-25 03:56:34 +00:00
transaction: implement encoding for state
This commit is contained in:
parent
868c9d6e8c
commit
af212f496e
2 changed files with 17 additions and 1 deletions
|
@ -29,6 +29,17 @@ func (tx *StateTX) DecodeBinary(r io.Reader) error {
|
||||||
|
|
||||||
// EncodeBinary implements the Payload interface.
|
// EncodeBinary implements the Payload interface.
|
||||||
func (tx *StateTX) EncodeBinary(w io.Writer) error {
|
func (tx *StateTX) EncodeBinary(w io.Writer) error {
|
||||||
|
bw := util.BinWriter{W: w}
|
||||||
|
bw.WriteVarUint(uint64(len(tx.Descriptors)))
|
||||||
|
if bw.Err != nil {
|
||||||
|
return bw.Err
|
||||||
|
}
|
||||||
|
for _, desc := range tx.Descriptors {
|
||||||
|
err := desc.EncodeBinary(w)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,12 @@ func (s *StateDescriptor) DecodeBinary(r io.Reader) error {
|
||||||
|
|
||||||
// EncodeBinary implements the Payload interface.
|
// EncodeBinary implements the Payload interface.
|
||||||
func (s *StateDescriptor) EncodeBinary(w io.Writer) error {
|
func (s *StateDescriptor) EncodeBinary(w io.Writer) error {
|
||||||
return nil
|
bw := util.BinWriter{W: w}
|
||||||
|
bw.WriteLE(s.Type)
|
||||||
|
bw.WriteBytes(s.Key)
|
||||||
|
bw.WriteBytes(s.Value)
|
||||||
|
bw.WriteString(s.Field)
|
||||||
|
return bw.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDescriptor) Size() int {
|
func (s *StateDescriptor) Size() int {
|
||||||
|
|
Loading…
Reference in a new issue