payload

package
v0.98.3-pre Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 14 Imported by: 16

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 added in v0.90.0

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 added in v0.93.0

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 util.Uint160
	// 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 added in v0.93.0

func NewExtensible() *Extensible

NewExtensible creates new extensible payload.

func (*Extensible) DecodeBinary added in v0.93.0

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

DecodeBinary implements io.Serializable.

func (*Extensible) EncodeBinary added in v0.93.0

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

EncodeBinary implements io.Serializable.

func (*Extensible) Hash added in v0.93.0

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

Hash returns payload hash.

type GetBlockByIndex added in v0.91.0

type GetBlockByIndex struct {
	IndexStart uint32
	Count      int16
}

GetBlockByIndex payload.

func NewGetBlockByIndex added in v0.91.0

func NewGetBlockByIndex(indexStart uint32, count int16) *GetBlockByIndex

NewGetBlockByIndex returns GetBlockByIndex payload with specified start index and count.

func (*GetBlockByIndex) DecodeBinary added in v0.91.0

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

DecodeBinary implements Serializable interface.

func (*GetBlockByIndex) EncodeBinary added in v0.91.0

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

func (*GetBlocks) EncodeBinary

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

EncodeBinary implements Serializable interface.

type Headers

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

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 []util.Uint256
}

Inventory payload.

func NewInventory

func NewInventory(typ InventoryType, hashes []util.Uint256) *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(p2pSigExtensionsEnabled bool) bool

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

type MPTData added in v0.97.3

type MPTData struct {
	Nodes [][]byte
}

MPTData represents the set of serialized MPT nodes.

func (*MPTData) DecodeBinary added in v0.97.3

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

DecodeBinary implements io.Serializable.

func (*MPTData) EncodeBinary added in v0.97.3

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

EncodeBinary implements io.Serializable.

type MPTInventory added in v0.97.3

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

MPTInventory payload.

func NewMPTInventory added in v0.97.3

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

NewMPTInventory return a pointer to an MPTInventory.

func (*MPTInventory) DecodeBinary added in v0.97.3

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

DecodeBinary implements Serializable interface.

func (*MPTInventory) EncodeBinary added in v0.97.3

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

EncodeBinary implements 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 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 P2PNotaryRequest added in v0.92.0

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 added in v0.93.0

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

NewP2PNotaryRequestFromBytes decodes P2PNotaryRequest from the given bytes.

func (*P2PNotaryRequest) Bytes added in v0.93.0

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

Bytes returns serialized P2PNotaryRequest payload.

func (*P2PNotaryRequest) DecodeBinary added in v0.92.0

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

DecodeBinary implements io.Serializable interface.

func (*P2PNotaryRequest) EncodeBinary added in v0.92.0

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

EncodeBinary implements Serializable interface.

func (*P2PNotaryRequest) Hash added in v0.92.0

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 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
	Magic netmode.Magic
	// 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(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 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