2021-07-30 13:57:42 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// MaxMPTHashesCount is the maximum number of the requested MPT nodes hashes.
|
2021-07-30 13:57:42 +00:00
|
|
|
const MaxMPTHashesCount = 32
|
|
|
|
|
|
|
|
// MPTInventory payload.
|
|
|
|
type MPTInventory struct {
|
2022-04-20 18:30:09 +00:00
|
|
|
// A list of the requested MPT nodes hashes.
|
2021-07-30 13:57:42 +00:00
|
|
|
Hashes []util.Uint256
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewMPTInventory return a pointer to an MPTInventory.
|
|
|
|
func NewMPTInventory(hashes []util.Uint256) *MPTInventory {
|
|
|
|
return &MPTInventory{
|
|
|
|
Hashes: hashes,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// DecodeBinary implements the Serializable interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (p *MPTInventory) DecodeBinary(br *io.BinReader) {
|
|
|
|
br.ReadArray(&p.Hashes, MaxMPTHashesCount)
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:30:09 +00:00
|
|
|
// EncodeBinary implements the Serializable interface.
|
2021-07-30 13:57:42 +00:00
|
|
|
func (p *MPTInventory) EncodeBinary(bw *io.BinWriter) {
|
|
|
|
bw.WriteArray(p.Hashes)
|
|
|
|
}
|