neoneo-go/pkg/core/block/header.go

34 lines
633 B
Go
Raw Normal View History

package block
import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/io"
)
// Header holds the head info of a block.
type Header struct {
// Base of the block.
2020-01-15 08:29:50 +00:00
Base
2019-10-22 14:56:03 +00:00
// Padding that is fixed to 0.
_ uint8
}
// DecodeBinary implements Serializable interface.
func (h *Header) DecodeBinary(r *io.BinReader) {
2020-01-15 08:29:50 +00:00
h.Base.DecodeBinary(r)
2019-12-06 15:37:46 +00:00
padding := []byte{0}
r.ReadBytes(padding)
2019-12-06 15:37:46 +00:00
if padding[0] != 0 {
r.Err = fmt.Errorf("format error: padding must equal 0 got %d", padding)
}
}
2019-10-22 14:56:03 +00:00
// EncodeBinary implements Serializable interface.
func (h *Header) EncodeBinary(w *io.BinWriter) {
2020-01-15 08:29:50 +00:00
h.Base.EncodeBinary(w)
w.WriteBytes([]byte{0})
}