2018-08-10 14:32:49 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core"
|
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 {
|
|
|
|
*core.BlockBase
|
|
|
|
TxCount int
|
|
|
|
Hashes []util.Uint256
|
|
|
|
Flags []byte
|
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// DecodeBinary implements the Payload interface.
|
2019-09-16 09:18:13 +00:00
|
|
|
func (m *MerkleBlock) DecodeBinary(br *io.BinReader) error {
|
2018-08-10 14:32:49 +00:00
|
|
|
m.BlockBase = &core.BlockBase{}
|
2019-09-16 09:18:13 +00:00
|
|
|
if err := m.BlockBase.DecodeBinary(br); err != nil {
|
2018-08-10 14:32:49 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-08-28 12:43:56 +00:00
|
|
|
m.TxCount = int(br.ReadVarUint())
|
|
|
|
n := br.ReadVarUint()
|
2018-08-10 14:32:49 +00:00
|
|
|
m.Hashes = make([]util.Uint256, n)
|
|
|
|
for i := 0; i < len(m.Hashes); i++ {
|
2019-08-28 12:43:56 +00:00
|
|
|
br.ReadLE(&m.Hashes[i])
|
2018-08-10 14:32:49 +00:00
|
|
|
}
|
2019-08-28 12:43:56 +00:00
|
|
|
m.Flags = br.ReadBytes()
|
|
|
|
return br.Err
|
2018-08-10 14:32:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// EncodeBinary implements the Payload interface.
|
2019-09-16 09:18:13 +00:00
|
|
|
func (m *MerkleBlock) EncodeBinary(bw *io.BinWriter) error {
|
2018-08-10 14:32:49 +00:00
|
|
|
return nil
|
|
|
|
}
|