payload

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

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 header.

View Source
const MaxMPTHashesCount = 32

MaxMPTHashesCount is the maximum number of requested MPT nodes hashes.

View Source
const MaxSize = 0x02000000

MaxSize is maximum payload size in decompressed form.

View Source
const MaxUserAgentLength = 1024

MaxUserAgentLength is the limit for 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 were 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 Serializable interface.

func (*AddressAndTime) EncodeBinary

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

EncodeBinary implements Serializable interface.

func (*AddressAndTime) GetTCPAddress

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

GetTCPAddress makes a string from IP and 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 Serializable interface.

func (*AddressList) EncodeBinary

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

EncodeBinary implements Serializable interface.

type Extensible

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

Extensible represents payload containing arbitrary data.

func NewExtensible

func NewExtensible() *Extensible

NewExtensible creates 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() common.Hash

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 specified start index and count.

func (*GetBlockByIndex) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*GetBlockByIndex) EncodeBinary

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

EncodeBinary implements Serializable interface.

type GetBlocks

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

GetBlocks contains getblocks message payload fields.

func NewGetBlocks

func NewGetBlocks(start common.Hash, count int16) *GetBlocks

NewGetBlocks returns a pointer to a GetBlocks object.

func (*GetBlocks) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*GetBlocks) EncodeBinary

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

EncodeBinary implements Serializable interface.

type Headers

type Headers struct {
	Hdrs []*block.Header
}

Headers payload.

func (*Headers) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*Headers) EncodeBinary

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

EncodeBinary implements Serializable interface.

type Inventory

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

	// A list of hashes.
	Hashes []common.Hash
}

Inventory payload.

func NewInventory

func NewInventory(typ InventoryType, hashes []common.Hash) *Inventory

NewInventory return a pointer to an Inventory.

func (*Inventory) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*Inventory) EncodeBinary

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

EncodeBinary implements 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() bool

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

type MPTData

type MPTData struct {
	Nodes [][]byte
}

MPTData represents the 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 requested MPT nodes hashes.
	Hashes []common.Hash
}

MPTInventory payload.

func NewMPTInventory

func NewMPTInventory(hashes []common.Hash) *MPTInventory

NewMPTInventory return a pointer to an MPTInventory.

func (*MPTInventory) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*MPTInventory) EncodeBinary

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

EncodeBinary implements Serializable interface.

type MerkleBlock

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

MerkleBlock represents a merkle block packet payload.

func (*MerkleBlock) DecodeBinary

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

DecodeBinary implements Serializable interface.

func (*MerkleBlock) EncodeBinary

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

EncodeBinary implements 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 Serializable interface.

func (NullPayload) EncodeBinary

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

EncodeBinary implements Serializable interface.

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 Serializable interface.

func (*Ping) EncodeBinary

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

EncodeBinary implements Serializable interface.

type Version

type Version struct {
	// NetMode of the node
	ChainID uint64
	// currently the version of the protocol is 0
	Version uint32
	// timestamp
	Timestamp uint32
	// it's used to distinguish the node from public IP
	Nonce uint32
	// client id
	UserAgent []byte
	// List of available network services
	Capabilities capability.Capabilities
}

Version payload.

func NewVersion

func NewVersion(chainId uint64, 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 Serializable interface.

func (*Version) EncodeBinary

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

EncodeBinary implements Serializable interface.

Jump to

Keyboard shortcuts

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