Documentation ¶
Index ¶
- type Peer
- func (p *Peer) AsyncSendNewBlock(block *types.Block, td *big.Int)
- func (p *Peer) AsyncSendNewBlockHash(block *types.Block)
- func (p *Peer) AsyncSendPooledTransactionHashes(hashes []common.Hash)
- func (p *Peer) AsyncSendTransactions(hashes []common.Hash)
- func (p *Peer) Close()
- func (p *Peer) ExpectRequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error
- func (p *Peer) Head() (hash common.Hash, td *big.Int)
- func (p *Peer) ID() string
- func (p *Peer) KnownBlock(hash common.Hash) bool
- func (p *Peer) KnownTransaction(hash common.Hash) bool
- func (p *Peer) ReplyBlockBodiesRLP(id uint64, bodies []rlp.RawValue) error
- func (p *Peer) ReplyBlockHeaders(id uint64, headers []*types.Header) error
- func (p *Peer) ReplyNodeData(id uint64, data [][]byte) error
- func (p *Peer) ReplyPooledTransactionsRLP(id uint64, hashes []common.Hash, txs []rlp.RawValue) error
- func (p *Peer) ReplyReceiptsRLP(id uint64, receipts []rlp.RawValue) error
- func (p *Peer) RequestBodies(hashes []common.Hash) error
- func (p *Peer) RequestHeadersByHash(origin common.Hash, amount int, skip int, reverse bool) error
- func (p *Peer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error
- func (p *Peer) RequestNodeData(hashes []common.Hash) error
- func (p *Peer) RequestOneHeader(hash common.Hash) error
- func (p *Peer) RequestReceipts(hashes []common.Hash) error
- func (p *Peer) RequestTxs(hashes []common.Hash) error
- func (p *Peer) SendBlockBodiesRLP(bodies []rlp.RawValue) error
- func (p *Peer) SendBlockHeaders(headers []*types.Header) error
- func (p *Peer) SendNewBlock(block *types.Block, td *big.Int) error
- func (p *Peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error
- func (p *Peer) SendNodeData(data [][]byte) error
- func (p *Peer) SendPooledTransactionsRLP(hashes []common.Hash, txs []rlp.RawValue) error
- func (p *Peer) SendReceiptsRLP(receipts []rlp.RawValue) error
- func (p *Peer) SendTransactions(txs types.Transactions) error
- func (p *Peer) SetHead(hash common.Hash, td *big.Int)
- func (p *Peer) Version() uint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
type Peer struct { *p2p.Peer // The embedded P2P package peer // contains filtered or unexported fields }
Peer is a collection of relevant information we have about a `eth` peer.
func (*Peer) AsyncSendNewBlock ¶
AsyncSendNewBlock queues an entire block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) AsyncSendNewBlockHash ¶
AsyncSendNewBlockHash queues the availability of a block for propagation to a remote peer. If the peer's broadcast queue is full, the event is silently dropped.
func (*Peer) AsyncSendPooledTransactionHashes ¶
AsyncSendPooledTransactionHashes queues a list of transactions hashes to eventually announce to a remote peer. The number of pending sends are capped (new ones will force old sends to be dropped)
func (*Peer) AsyncSendTransactions ¶
AsyncSendTransactions queues a list of transactions (by hash) to eventually propagate to a remote peer. The number of pending sends are capped (new ones will force old sends to be dropped)
func (*Peer) Close ¶
func (p *Peer) Close()
Close signals the broadcast goroutine to terminate. Only ever call this if you created the peer yourself via NewPeer. Otherwise let whoever created it clean it up!
func (*Peer) ExpectRequestHeadersByNumber ¶
func (p *Peer) ExpectRequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error
ExpectRequestHeadersByNumber is a testing method to mirror the recipient side of the RequestHeadersByNumber operation.
func (*Peer) KnownBlock ¶
KnownBlock returns whether peer is known to already have a block.
func (*Peer) KnownTransaction ¶
KnownTransaction returns whether peer is known to already have a transaction.
func (*Peer) ReplyBlockBodiesRLP ¶
ReplyBlockBodiesRLP is the eth/66 version of SendBlockBodiesRLP.
func (*Peer) ReplyBlockHeaders ¶
ReplyBlockHeaders is the eth/66 version of SendBlockHeaders.
func (*Peer) ReplyNodeData ¶
ReplyNodeData is the eth/66 response to GetNodeData.
func (*Peer) ReplyPooledTransactionsRLP ¶
func (p *Peer) ReplyPooledTransactionsRLP(id uint64, hashes []common.Hash, txs []rlp.RawValue) error
ReplyPooledTransactionsRLP is the eth/66 version of SendPooledTransactionsRLP.
func (*Peer) ReplyReceiptsRLP ¶
ReplyReceiptsRLP is the eth/66 response to GetReceipts.
func (*Peer) RequestBodies ¶
RequestBodies fetches a batch of blocks' bodies corresponding to the hashes specified.
func (*Peer) RequestHeadersByHash ¶
RequestHeadersByHash fetches a batch of blocks' headers corresponding to the specified header query, based on the hash of an origin block.
func (*Peer) RequestHeadersByNumber ¶
RequestHeadersByNumber fetches a batch of blocks' headers corresponding to the specified header query, based on the number of an origin block.
func (*Peer) RequestNodeData ¶
RequestNodeData fetches a batch of arbitrary data from a node's known state data, corresponding to the specified hashes.
func (*Peer) RequestOneHeader ¶
RequestOneHeader is a wrapper around the header query functions to fetch a single header. It is used solely by the fetcher.
func (*Peer) RequestReceipts ¶
RequestReceipts fetches a batch of transaction receipts from a remote node.
func (*Peer) RequestTxs ¶
RequestTxs fetches a batch of transactions from a remote node.
func (*Peer) SendBlockBodiesRLP ¶
SendBlockBodiesRLP sends a batch of block contents to the remote peer from an already RLP encoded format.
func (*Peer) SendBlockHeaders ¶
SendBlockHeaders sends a batch of block headers to the remote peer.
func (*Peer) SendNewBlock ¶
SendNewBlock propagates an entire block to a remote peer.
func (*Peer) SendNewBlockHashes ¶
SendNewBlockHashes announces the availability of a number of blocks through a hash notification.
func (*Peer) SendNodeData ¶
SendNodeDataRLP sends a batch of arbitrary internal data, corresponding to the hashes requested.
func (*Peer) SendPooledTransactionsRLP ¶
SendPooledTransactionsRLP sends requested transactions to the peer and adds the hashes in its transaction hash set for future reference.
Note, the method assumes the hashes are correct and correspond to the list of transactions being sent.
func (*Peer) SendReceiptsRLP ¶
SendReceiptsRLP sends a batch of transaction receipts, corresponding to the ones requested from an already RLP encoded format.
func (*Peer) SendTransactions ¶
func (p *Peer) SendTransactions(txs types.Transactions) error
SendTransactions sends transactions to the peer and includes the hashes in its transaction hash set for future reference.
This method is a helper used by the async transaction sender. Don't call it directly as the queueing (memory) and transmission (bandwidth) costs should not be managed directly.
The reasons this is public is to allow packages using this protocol to write tests that directly send messages without having to do the asyn queueing.