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 MaxStateRootsAllowed = 2000
MaxStateRootsAllowed is a maxumum amount of state roots which can be sent in a single payload.
Variables ¶
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 ¶
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 ¶
NewGetBlocks returns a pointer to a GetBlocks object.
func (*GetBlocks) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*GetBlocks) EncodeBinary ¶
EncodeBinary implements Serializable interface.
type GetStateRoots ¶ added in v0.76.0
GetStateRoots represents request for state roots.
func (*GetStateRoots) DecodeBinary ¶ added in v0.76.0
func (g *GetStateRoots) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable.
func (*GetStateRoots) EncodeBinary ¶ added in v0.76.0
func (g *GetStateRoots) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable.
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 = 0x01 // 1 BlockType InventoryType = 0x02 // 2 StateRootType InventoryType = 0x03 // 3 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 ¶
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 StateRoots ¶ added in v0.76.0
StateRoots contains multiple StateRoots.
func (*StateRoots) DecodeBinary ¶ added in v0.76.0
func (s *StateRoots) DecodeBinary(r *io.BinReader)
DecodeBinary implements io.Serializable.
func (*StateRoots) EncodeBinary ¶ added in v0.76.0
func (s *StateRoots) EncodeBinary(w *io.BinWriter)
EncodeBinary implements io.Serializable.
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 ¶
NewVersion returns a pointer to a Version payload.
func (*Version) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Version) EncodeBinary ¶
EncodeBinary implements Serializable interface.