neoneo-go/pkg/core/header.go

34 lines
640 B
Go
Raw Normal View History

package core
import (
"fmt"
"github.com/CityOfZion/neo-go/pkg/io"
)
// Header holds the head info of a block.
type Header struct {
// Base of the block.
BlockBase
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) {
h.BlockBase.DecodeBinary(r)
var padding uint8
r.ReadLE(&padding)
if padding != 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) {
h.BlockBase.EncodeBinary(w)
w.WriteBytes([]byte{0})
}