2020-01-14 15:32:07 +03:00
|
|
|
package block
|
2018-03-17 12:53:21 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-09-16 12:18:13 +03:00
|
|
|
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-03-17 12:53:21 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Header holds the head info of a block.
|
|
|
|
type Header struct {
|
|
|
|
// Base of the block.
|
2020-01-15 11:29:50 +03:00
|
|
|
Base
|
2019-10-22 17:56:03 +03:00
|
|
|
// Padding that is fixed to 0.
|
2018-03-17 12:53:21 +01:00
|
|
|
_ uint8
|
|
|
|
}
|
|
|
|
|
2019-09-16 19:31:49 +03:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (h *Header) DecodeBinary(r *io.BinReader) {
|
2020-01-15 11:29:50 +03:00
|
|
|
h.Base.DecodeBinary(r)
|
2018-03-17 12:53:21 +01:00
|
|
|
|
2019-12-06 18:37:46 +03:00
|
|
|
padding := []byte{0}
|
|
|
|
r.ReadBytes(padding)
|
2019-01-25 14:20:35 +03:00
|
|
|
|
2019-12-06 18:37:46 +03:00
|
|
|
if padding[0] != 0 {
|
2019-09-16 19:31:49 +03:00
|
|
|
r.Err = fmt.Errorf("format error: padding must equal 0 got %d", padding)
|
2018-03-17 12:53:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:56:03 +03:00
|
|
|
// EncodeBinary implements Serializable interface.
|
2019-09-16 19:31:49 +03:00
|
|
|
func (h *Header) EncodeBinary(w *io.BinWriter) {
|
2020-01-15 11:29:50 +03:00
|
|
|
h.Base.EncodeBinary(w)
|
2019-12-06 18:22:21 +03:00
|
|
|
w.WriteBytes([]byte{0})
|
2018-03-17 12:53:21 +01:00
|
|
|
}
|