2020-10-14 16:07:16 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
2020-11-18 11:13:09 +00:00
|
|
|
"fmt"
|
2020-10-14 16:07:16 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NotValidBefore represents attribute with the height transaction is not valid before.
|
|
|
|
type NotValidBefore struct {
|
|
|
|
Height uint32 `json:"height"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements io.Serializable interface.
|
|
|
|
func (n *NotValidBefore) DecodeBinary(br *io.BinReader) {
|
|
|
|
bytes := br.ReadVarBytes(4)
|
2020-11-18 11:13:09 +00:00
|
|
|
if br.Err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(bytes) != 4 {
|
|
|
|
br.Err = fmt.Errorf("expected 4 bytes, got %d", len(bytes))
|
|
|
|
return
|
|
|
|
}
|
2020-10-14 16:07:16 +00:00
|
|
|
n.Height = binary.LittleEndian.Uint32(bytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeBinary implements io.Serializable interface.
|
|
|
|
func (n *NotValidBefore) EncodeBinary(w *io.BinWriter) {
|
|
|
|
bytes := make([]byte, 4)
|
|
|
|
binary.LittleEndian.PutUint32(bytes, n.Height)
|
|
|
|
w.WriteVarBytes(bytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *NotValidBefore) toJSONMap(m map[string]interface{}) {
|
|
|
|
m["height"] = n.Height
|
|
|
|
}
|