Documentation ¶
Index ¶
Constants ¶
const (
MaxHashesCount = 500
)
Maximum inventory hashes number is limited to 500.
const (
MaxHeadersAllowed = 2000
)
Users can at most request 2k header.
const MaxSize = 0x02000000
MaxSize is maximum payload size in decompressed form.
Variables ¶
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 GetBlockByIndex ¶ added in v0.91.0
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 latest block that node requests HashStart util.Uint256 Count int16 }
GetBlocks contains fields and methods to be shared with the
func NewGetBlocks ¶
NewGetBlocks returns a pointer to a GetBlocks object.
func (*GetBlocks) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*GetBlocks) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type Headers ¶
Headers payload.
func (*Headers) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Headers) EncodeBinary ¶
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 ¶
DecodeBinary implements Serializable interface.
func (*Inventory) EncodeBinary ¶
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 ¶
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 (*Ping) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Ping) EncodeBinary ¶
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 ¶
DecodeBinary implements Serializable interface.
func (*Version) EncodeBinary ¶
EncodeBinary implements Serializable interface.