Documentation
¶
Index ¶
- Constants
- func BuildCodec() (codec.Manager, error)
- func BuildGossipMessage(codec codec.Manager, msg GossipMessage) ([]byte, error)
- func RequestToBytes(codec codec.Manager, request Request) ([]byte, error)
- type BlockRequest
- type BlockResponse
- type CodeRequest
- type CodeResponse
- type GossipHandler
- type GossipMessage
- type LeafsRequest
- type LeafsResponse
- type NoopMempoolGossipHandler
- type Request
- type RequestHandler
- type ResponseHandler
- type SyncableBlock
- type TxsGossip
Constants ¶
const ( // TxMsgSoftCapSize is the ideal size of encoded transaction bytes we send in // any [Txs] message. We do not limit inbound messages to // this size, however. Max inbound message size is enforced by the codec // (512KB). TxMsgSoftCapSize = common.StorageSize(64 * units.KiB) )
const (
Version = uint16(0)
)
Variables ¶
This section is empty.
Functions ¶
func BuildCodec ¶ added in v0.1.1
func BuildGossipMessage ¶ added in v0.2.1
func BuildGossipMessage(codec codec.Manager, msg GossipMessage) ([]byte, error)
Types ¶
type BlockRequest ¶ added in v0.2.1
type BlockRequest struct { Hash common.Hash `serialize:"true"` Height uint64 `serialize:"true"` Parents uint16 `serialize:"true"` }
BlockRequest is a request to retrieve Parents number of blocks starting from Hash from newest-oldest manner
func (BlockRequest) Handle ¶ added in v0.2.1
func (b BlockRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)
func (BlockRequest) String ¶ added in v0.2.1
func (b BlockRequest) String() string
type BlockResponse ¶ added in v0.2.1
type BlockResponse struct {
Blocks [][]byte `serialize:"true"`
}
BlockResponse is a response to a BlockRequest Blocks is slice of RLP encoded blocks starting with the block requested in BlockRequest.Hash. The next block is the parent, etc. handler: handlers.BlockRequestHandler
type CodeRequest ¶ added in v0.2.1
CodeRequest is a request to retrieve a contract code with specified Hash
func NewCodeRequest ¶ added in v0.2.1
func NewCodeRequest(hash common.Hash) CodeRequest
func (CodeRequest) Handle ¶ added in v0.2.1
func (c CodeRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)
func (CodeRequest) String ¶ added in v0.2.1
func (c CodeRequest) String() string
type CodeResponse ¶ added in v0.2.1
type CodeResponse struct {
Data []byte `serialize:"true"`
}
CodeResponse is a response to a CodeRequest crypto.Keccak256Hash of Data is expected to equal CodeRequest.Hash handler: handlers.CodeRequestHandler
type GossipHandler ¶ added in v0.1.1
GossipHandler handles incoming gossip messages
type GossipMessage ¶ added in v0.2.1
type GossipMessage interface { // types implementing GossipMessage should also implement fmt.Stringer for logging purposes. fmt.Stringer // Handle this gossip message with the gossip handler. Handle(handler GossipHandler, nodeID ids.NodeID) error }
func ParseGossipMessage ¶ added in v0.2.1
func ParseGossipMessage(codec codec.Manager, bytes []byte) (GossipMessage, error)
type LeafsRequest ¶ added in v0.2.1
type LeafsRequest struct { Root common.Hash `serialize:"true"` Start []byte `serialize:"true"` End []byte `serialize:"true"` Limit uint16 `serialize:"true"` }
LeafsRequest is a request to receive trie leaves at specified Root within Start and End byte range Limit outlines maximum number of leaves to returns starting at Start
func (LeafsRequest) Handle ¶ added in v0.2.1
func (l LeafsRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error)
func (LeafsRequest) String ¶ added in v0.2.1
func (l LeafsRequest) String() string
type LeafsResponse ¶ added in v0.2.1
type LeafsResponse struct { // Keys and Vals provides the key-value pairs in the trie in the response. Keys [][]byte `serialize:"true"` Vals [][]byte `serialize:"true"` // More indicates if there are more leaves to the right of the last value in this response. // // This is not serialized since it is set in the client after verifying the response via // VerifyRangeProof and determining if there are in fact more leaves to the right of the // last value in this response. More bool // ProofKeys and ProofVals are the key-value pairs used in the range proof of the provided key-value // pairs. ProofKeys [][]byte `serialize:"true"` ProofVals [][]byte `serialize:"true"` }
LeafsResponse is a response to a LeafsRequest Keys must be within LeafsRequest.Start and LeafsRequest.End and sorted in lexicographical order.
ProofKeys and ProofVals are expected to be non-nil and valid range proofs if the key-value pairs in the response are not the entire trie. If the key-value pairs make up the entire trie, ProofKeys and ProofVals should be empty since the root will be sufficient to prove that the leaves are included in the trie.
More is a flag set in the client after verifying the response, which indicates if the last key-value pair in the response has any more elements to its right within the trie.
type NoopMempoolGossipHandler ¶ added in v0.1.1
type NoopMempoolGossipHandler struct{}
type Request ¶ added in v0.1.1
type Request interface { // Requests should implement String() for logging. fmt.Stringer // Handle allows `Request` to call respective methods on handler to handle // this particular request type Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) }
Request represents a Network request type
type RequestHandler ¶ added in v0.1.1
type RequestHandler interface { HandleTrieLeafsRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, leafsRequest LeafsRequest) ([]byte, error) HandleBlockRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, request BlockRequest) ([]byte, error) HandleCodeRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, codeRequest CodeRequest) ([]byte, error) }
RequestHandler interface handles incoming requests from peers Must have methods in format of handleType(context.Context, ids.NodeID, uint32, request Type) error so that the Request object of relevant Type can invoke its respective handle method on this struct. Also see GossipHandler for implementation style.
type ResponseHandler ¶ added in v0.1.1
type ResponseHandler interface { // OnResponse is invoked when the peer responded to a request OnResponse(nodeID ids.NodeID, requestID uint32, response []byte) error // OnFailure is invoked when there was a failure in processing a request // The FailureReason outlines the underlying cause. OnFailure(nodeID ids.NodeID, requestID uint32) error }
ResponseHandler handles response for a sent request Only one of OnResponse or OnFailure is called for a given requestID, not both
type SyncableBlock ¶ added in v0.2.1
type SyncableBlock struct { BlockNumber uint64 `serialize:"true"` BlockRoot common.Hash `serialize:"true"` AtomicRoot common.Hash `serialize:"true"` BlockHash common.Hash `serialize:"true"` }
SyncableBlock provides the information necessary to sync a node starting at the given block.
func (SyncableBlock) String ¶ added in v0.2.1
func (s SyncableBlock) String() string