payload

package
v0.90.1-pre Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 10 Imported by: 16

Documentation

Index

Constants

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 MaxSize = 0x02000000

MaxSize is maximum payload size in decompressed form.

Variables

View Source
var ErrTooManyHeaders = errors.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 GetBlockData added in v0.90.0

type GetBlockData struct {
	IndexStart uint32
	Count      uint16
}

GetBlockData payload

func NewGetBlockData added in v0.90.0

func NewGetBlockData(indexStart uint32, count uint16) *GetBlockData

NewGetBlockData returns GetBlockData payload with specified start index and count

func (*GetBlockData) DecodeBinary added in v0.90.0

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

DecodeBinary implements Serializable interface.

func (*GetBlockData) EncodeBinary added in v0.90.0

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

EncodeBinary implements Serializable interface.

type GetBlocks

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

GetBlocks contains fields and methods to be shared with the

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
	Network netmode.Magic
}

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
	ConsensusType InventoryType = 0x2d
)

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 MerkleBlock

type MerkleBlock struct {
	*block.Base
	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 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