payload

package
v0.75.1-pre Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 7 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.

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
	Services  uint64
	IP        [16]byte
	Port      uint16
}

AddressAndTime payload.

func NewAddressAndTime

func NewAddressAndTime(e *net.TCPAddr, t time.Time) *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) IPPortString

func (p *AddressAndTime) IPPortString() string

IPPortString makes a string from IP and port specified.

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 GetBlocks

type GetBlocks struct {
	// hash of latest block that node requests
	HashStart []util.Uint256
	// hash of last block that node requests
	HashStop util.Uint256
}

GetBlocks contains fields and methods to be shared with the

func NewGetBlocks

func NewGetBlocks(start []util.Uint256, stop util.Uint256) *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 []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 = 0x01 // 1
	BlockType     InventoryType = 0x02 // 2
	ConsensusType InventoryType = 0xe0 // 224
)

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 {
	// currently the version of the protocol is 0
	Version uint32
	// currently 1
	Services uint64
	// timestamp
	Timestamp uint32
	// port this server is listening on
	Port uint16
	// it's used to distinguish the node from public IP
	Nonce uint32
	// client id
	UserAgent []byte
	// Height of the block chain
	StartHeight uint32
	// Whether to receive and forward
	Relay bool
}

Version payload.

func NewVersion

func NewVersion(id uint32, p uint16, ua string, h uint32, r bool) *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(br *io.BinWriter)

EncodeBinary implements Serializable interface.

Jump to

Keyboard shortcuts

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