payload

package
v0.0.0-...-886a677 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const ConsensusCategory = "dBFT"

ConsensusCategory is a message category for consensus-related extensible payloads.

View Source
const MaxAddrsCount = 200

MaxAddrsCount is the maximum number of addresses that could be packed into one payload.

View Source
const (
	MaxHashesCount = 500
)

Maximum inventory hashes number is limited to 500.

View Source
const (
	MaxHeadersAllowed = 2000
)

Users can at most request 2k headers.

View Source
const MaxMPTHashesCount = 32

MaxMPTHashesCount is the maximum number of the requested MPT nodes hashes.

View Source
const MaxSize = 0x02000000

MaxSize is the maximum payload size in decompressed form.

View Source
const MaxUserAgentLength = 1024

MaxUserAgentLength is the limit for the user agent field.

Variables

View Source
var ErrNoHeaders = errors.New("no headers (zero length array)")

ErrNoHeaders is returned for zero-elements Headers payload which is considered to be invalid.

View Source
var ErrTooManyHeaders = fmt.Errorf("too many headers were received (max: %d)", MaxHeadersAllowed)

ErrTooManyHeaders is an error returned when too many headers have been received.

Functions

This section is empty.

Types

type AddressAndTime

type AddressAndTime struct {
	Timestamp    uint32
	IP           [16]byte
	Capabilities capability.Capabilities
}

AddressAndTime payload.

func NewAddressAndTime

func NewAddressAndTime(e *net.TCPAddr, t time.Time, c capability.Capabilities) *AddressAndTime

NewAddressAndTime creates a new AddressAndTime object.

func (*AddressAndTime) DecodeBinary

func (p *AddressAndTime) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*AddressAndTime) EncodeBinary

func (p *AddressAndTime) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

func (*AddressAndTime) GetTCPAddress

func (p *AddressAndTime) GetTCPAddress() (string, error)

GetTCPAddress makes a string from the IP and the port specified in TCPCapability. It returns an error if there's no such capability.

type AddressList

type AddressList struct {
	Addrs []*AddressAndTime
}

AddressList is a list with AddrAndTime.

func NewAddressList

func NewAddressList(n int) *AddressList

NewAddressList creates a list for n AddressAndTime elements.

func (*AddressList) DecodeBinary

func (p *AddressList) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*AddressList) EncodeBinary

func (p *AddressList) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type Extensible

type Extensible struct {
	// Category is the payload type.
	Category string
	// ValidBlockStart is the starting height for a payload to be valid.
	ValidBlockStart uint32
	// ValidBlockEnd is the height after which a payload becomes invalid.
	ValidBlockEnd uint32
	// Sender is the payload sender or signer.
	Sender util.Uint160
	// Data is custom payload data.
	Data []byte
	// Witness is payload witness.
	Witness transaction.Witness
	// contains filtered or unexported fields
}

Extensible represents a payload containing arbitrary data.

func NewExtensible

func NewExtensible() *Extensible

NewExtensible creates a new extensible payload.

func (*Extensible) DecodeBinary

func (e *Extensible) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable.

func (*Extensible) EncodeBinary

func (e *Extensible) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable.

func (*Extensible) Hash

func (e *Extensible) Hash() util.Uint256

Hash returns payload hash.

type GetBlockByIndex

type GetBlockByIndex struct {
	IndexStart uint32
	Count      int16
}

GetBlockByIndex payload.

func NewGetBlockByIndex

func NewGetBlockByIndex(indexStart uint32, count int16) *GetBlockByIndex

NewGetBlockByIndex returns GetBlockByIndex payload with the specified start index and count.

func (*GetBlockByIndex) DecodeBinary

func (d *GetBlockByIndex) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*GetBlockByIndex) EncodeBinary

func (d *GetBlockByIndex) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type GetBlocks

type GetBlocks struct {
	// Hash of the latest block that node requests.
	HashStart util.Uint256
	Count     int16
}

GetBlocks contains getblocks message payload fields.

func NewGetBlocks

func NewGetBlocks(start util.Uint256, count int16) *GetBlocks

NewGetBlocks returns a pointer to a GetBlocks object.

func (*GetBlocks) DecodeBinary

func (p *GetBlocks) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*GetBlocks) EncodeBinary

func (p *GetBlocks) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type Headers

type Headers struct {
	Hdrs []*block.Header
	// StateRootInHeader specifies whether the header contains a state root.
	StateRootInHeader bool
}

Headers payload.

func (*Headers) DecodeBinary

func (p *Headers) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*Headers) EncodeBinary

func (p *Headers) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type Inventory

type Inventory struct {
	// Type of the object hash.
	Type InventoryType

	// A list of hashes.
	Hashes []util.Uint256
}

Inventory payload.

func NewInventory

func NewInventory(typ InventoryType, hashes []util.Uint256) *Inventory

NewInventory returns a pointer to an Inventory.

func (*Inventory) DecodeBinary

func (p *Inventory) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*Inventory) EncodeBinary

func (p *Inventory) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type InventoryType

type InventoryType uint8

InventoryType is the type of an object in the Inventory message.

const (
	TXType               InventoryType = 0x2b
	BlockType            InventoryType = 0x2c
	ExtensibleType       InventoryType = 0x2e
	P2PNotaryRequestType InventoryType = 0x50
)

List of valid InventoryTypes.

func (InventoryType) String

func (i InventoryType) String() string

String implements the Stringer interface.

func (InventoryType) Valid

func (i InventoryType) Valid(p2pSigExtensionsEnabled bool) bool

Valid returns true if the inventory (type) is known.

type MPTData

type MPTData struct {
	Nodes [][]byte
}

MPTData represents a set of serialized MPT nodes.

func (*MPTData) DecodeBinary

func (d *MPTData) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable.

func (*MPTData) EncodeBinary

func (d *MPTData) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable.

type MPTInventory

type MPTInventory struct {
	// A list of the requested MPT nodes hashes.
	Hashes []util.Uint256
}

MPTInventory payload.

func NewMPTInventory

func NewMPTInventory(hashes []util.Uint256) *MPTInventory

NewMPTInventory return a pointer to an MPTInventory.

func (*MPTInventory) DecodeBinary

func (p *MPTInventory) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*MPTInventory) EncodeBinary

func (p *MPTInventory) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type MerkleBlock

type MerkleBlock struct {
	*block.Header
	TxCount int
	Hashes  []util.Uint256
	Flags   []byte
}

MerkleBlock represents a merkle block packet payload.

func (*MerkleBlock) DecodeBinary

func (m *MerkleBlock) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*MerkleBlock) EncodeBinary

func (m *MerkleBlock) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type NullPayload

type NullPayload struct {
}

NullPayload is a dummy payload with no fields.

func NewNullPayload

func NewNullPayload() NullPayload

NewNullPayload returns zero-sized stub payload.

func (NullPayload) DecodeBinary

func (p NullPayload) DecodeBinary(r *io.BinReader)

DecodeBinary implements the Serializable interface.

func (NullPayload) EncodeBinary

func (p NullPayload) EncodeBinary(w *io.BinWriter)

EncodeBinary implements the Serializable interface.

type P2PNotaryRequest

type P2PNotaryRequest struct {
	MainTransaction     *transaction.Transaction `json:"maintx"`
	FallbackTransaction *transaction.Transaction `json:"fallbacktx"`

	Witness transaction.Witness
	// contains filtered or unexported fields
}

P2PNotaryRequest contains main and fallback transactions for the Notary service.

func NewP2PNotaryRequestFromBytes

func NewP2PNotaryRequestFromBytes(b []byte) (*P2PNotaryRequest, error)

NewP2PNotaryRequestFromBytes decodes a P2PNotaryRequest from the given bytes.

func (*P2PNotaryRequest) Bytes

func (r *P2PNotaryRequest) Bytes() ([]byte, error)

Bytes returns serialized P2PNotaryRequest payload.

func (*P2PNotaryRequest) Copy

Copy creates a deep copy of P2PNotaryRequest. It creates deep copy of the MainTransaction, FallbackTransaction and Witness, including all slice fields. Cached values like 'hashed' and 'size' of the transactions are reset to ensure the copy can be modified independently of the original.

func (*P2PNotaryRequest) DecodeBinary

func (r *P2PNotaryRequest) DecodeBinary(br *io.BinReader)

DecodeBinary implements the io.Serializable interface.

func (*P2PNotaryRequest) EncodeBinary

func (r *P2PNotaryRequest) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

func (*P2PNotaryRequest) Hash

func (r *P2PNotaryRequest) Hash() util.Uint256

Hash returns payload's hash.

type Payload

type Payload interface {
	io.Serializable
}

Payload is anything that can be binary encoded/decoded.

type Ping

type Ping struct {
	// Index of the last block.
	LastBlockIndex uint32
	// Timestamp.
	Timestamp uint32
	// Nonce of the server.
	Nonce uint32
}

Ping payload for ping/pong payloads.

func NewPing

func NewPing(blockIndex uint32, nonce uint32) *Ping

NewPing creates new Ping payload.

func (*Ping) DecodeBinary

func (p *Ping) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*Ping) EncodeBinary

func (p *Ping) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

type Version

type Version struct {
	// NetMode of the node
	Magic netmode.Magic
	// currently the version of the protocol is 0
	Version uint32
	// timestamp
	Timestamp uint32
	// it's used to distinguish several nodes using the same public IP (or different ones)
	Nonce uint32
	// client id
	UserAgent []byte
	// List of available network services
	Capabilities capability.Capabilities
}

Version payload.

func NewVersion

func NewVersion(magic netmode.Magic, id uint32, ua string, c []capability.Capability) *Version

NewVersion returns a pointer to a Version payload.

func (*Version) DecodeBinary

func (p *Version) DecodeBinary(br *io.BinReader)

DecodeBinary implements the Serializable interface.

func (*Version) EncodeBinary

func (p *Version) EncodeBinary(bw *io.BinWriter)

EncodeBinary implements the Serializable interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL