github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/network/payload/mptinventory.go (about)

     1  package payload
     2  
     3  import (
     4  	"github.com/nspcc-dev/neo-go/pkg/io"
     5  	"github.com/nspcc-dev/neo-go/pkg/util"
     6  )
     7  
     8  // MaxMPTHashesCount is the maximum number of the requested MPT nodes hashes.
     9  const MaxMPTHashesCount = 32
    10  
    11  // MPTInventory payload.
    12  type MPTInventory struct {
    13  	// A list of the requested MPT nodes hashes.
    14  	Hashes []util.Uint256
    15  }
    16  
    17  // NewMPTInventory return a pointer to an MPTInventory.
    18  func NewMPTInventory(hashes []util.Uint256) *MPTInventory {
    19  	return &MPTInventory{
    20  		Hashes: hashes,
    21  	}
    22  }
    23  
    24  // DecodeBinary implements the Serializable interface.
    25  func (p *MPTInventory) DecodeBinary(br *io.BinReader) {
    26  	br.ReadArray(&p.Hashes, MaxMPTHashesCount)
    27  }
    28  
    29  // EncodeBinary implements the Serializable interface.
    30  func (p *MPTInventory) EncodeBinary(bw *io.BinWriter) {
    31  	bw.WriteArray(p.Hashes)
    32  }