2018-08-10 14:32:49 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
2020-01-14 12:32:07 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/block"
|
2019-09-16 09:18:13 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
2018-08-10 14:32:49 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// MerkleBlock represents a merkle block packet payload.
|
2018-08-10 14:32:49 +00:00
|
|
|
type MerkleBlock struct {
|
2020-01-14 12:32:07 +00:00
|
|
|
*block.BlockBase
|
2018-08-10 14:32:49 +00:00
|
|
|
TxCount int
|
|
|
|
Hashes []util.Uint256
|
|
|
|
Flags []byte
|
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// DecodeBinary implements Serializable interface.
|
|
|
|
func (m *MerkleBlock) DecodeBinary(br *io.BinReader) {
|
2020-01-14 12:32:07 +00:00
|
|
|
m.BlockBase = &block.BlockBase{}
|
2019-09-16 16:31:49 +00:00
|
|
|
m.BlockBase.DecodeBinary(br)
|
2018-08-10 14:32:49 +00:00
|
|
|
|
2019-08-28 12:43:56 +00:00
|
|
|
m.TxCount = int(br.ReadVarUint())
|
2019-11-14 08:07:23 +00:00
|
|
|
br.ReadArray(&m.Hashes)
|
2019-12-06 15:37:37 +00:00
|
|
|
m.Flags = br.ReadVarBytes()
|
2018-08-10 14:32:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:31:49 +00:00
|
|
|
// EncodeBinary implements Serializable interface.
|
|
|
|
func (m *MerkleBlock) EncodeBinary(bw *io.BinWriter) {
|
2020-01-14 12:32:07 +00:00
|
|
|
m.BlockBase = &block.BlockBase{}
|
2019-09-16 16:49:48 +00:00
|
|
|
m.BlockBase.EncodeBinary(bw)
|
|
|
|
|
|
|
|
bw.WriteVarUint(uint64(m.TxCount))
|
2019-11-14 08:07:23 +00:00
|
|
|
bw.WriteArray(m.Hashes)
|
2019-11-22 10:34:06 +00:00
|
|
|
bw.WriteVarBytes(m.Flags)
|
2018-08-10 14:32:49 +00:00
|
|
|
}
|