neo-go/pkg/network/payload/merkleblock.go

36 lines
802 B
Go
Raw Normal View History

package payload
import (
"github.com/CityOfZion/neo-go/pkg/core/block"
"github.com/CityOfZion/neo-go/pkg/io"
"github.com/CityOfZion/neo-go/pkg/util"
)
// MerkleBlock represents a merkle block packet payload.
type MerkleBlock struct {
2020-01-15 08:29:50 +00:00
*block.Base
TxCount int
Hashes []util.Uint256
Flags []byte
}
// DecodeBinary implements Serializable interface.
func (m *MerkleBlock) DecodeBinary(br *io.BinReader) {
2020-01-15 08:29:50 +00:00
m.Base = &block.Base{}
m.Base.DecodeBinary(br)
m.TxCount = int(br.ReadVarUint())
br.ReadArray(&m.Hashes)
m.Flags = br.ReadVarBytes()
}
// EncodeBinary implements Serializable interface.
func (m *MerkleBlock) EncodeBinary(bw *io.BinWriter) {
2020-01-15 08:29:50 +00:00
m.Base = &block.Base{}
m.Base.EncodeBinary(bw)
bw.WriteVarUint(uint64(m.TxCount))
bw.WriteArray(m.Hashes)
bw.WriteVarBytes(m.Flags)
}