eth

package
v0.0.0-...-10c1c44 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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 NewPeer

func NewPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, txpool TxPool) *Peer

NewPeer create a wrapper for a network connection and negotiated protocol version.

func (*Peer) AsyncSendNewBlock

func (p *Peer) AsyncSendNewBlock(block *types.Block, td *big.Int)

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

func (p *Peer) AsyncSendNewBlockHash(block *types.Block)

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

func (p *Peer) AsyncSendPooledTransactionHashes(hashes []common.Hash)

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

func (p *Peer) AsyncSendTransactions(hashes []common.Hash)

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) Head

func (p *Peer) Head() (hash common.Hash, td *big.Int)

Head retrieves the current head hash and total difficulty of the peer.

func (*Peer) ID

func (p *Peer) ID() string

ID retrieves the peer's unique identifier.

func (*Peer) KnownBlock

func (p *Peer) KnownBlock(hash common.Hash) bool

KnownBlock returns whether peer is known to already have a block.

func (*Peer) KnownTransaction

func (p *Peer) KnownTransaction(hash common.Hash) bool

KnownTransaction returns whether peer is known to already have a transaction.

func (*Peer) ReplyBlockBodiesRLP

func (p *Peer) ReplyBlockBodiesRLP(id uint64, bodies []rlp.RawValue) error

ReplyBlockBodiesRLP is the eth/66 version of SendBlockBodiesRLP.

func (*Peer) ReplyBlockHeaders

func (p *Peer) ReplyBlockHeaders(id uint64, headers []*types.Header) error

ReplyBlockHeaders is the eth/66 version of SendBlockHeaders.

func (*Peer) ReplyNodeData

func (p *Peer) ReplyNodeData(id uint64, data [][]byte) error

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

func (p *Peer) ReplyReceiptsRLP(id uint64, receipts []rlp.RawValue) error

ReplyReceiptsRLP is the eth/66 response to GetReceipts.

func (*Peer) RequestBodies

func (p *Peer) RequestBodies(hashes []common.Hash) error

RequestBodies fetches a batch of blocks' bodies corresponding to the hashes specified.

func (*Peer) RequestHeadersByHash

func (p *Peer) RequestHeadersByHash(origin common.Hash, amount int, skip int, reverse bool) error

RequestHeadersByHash fetches a batch of blocks' headers corresponding to the specified header query, based on the hash of an origin block.

func (*Peer) RequestHeadersByNumber

func (p *Peer) RequestHeadersByNumber(origin uint64, amount int, skip int, reverse bool) error

RequestHeadersByNumber fetches a batch of blocks' headers corresponding to the specified header query, based on the number of an origin block.

func (*Peer) RequestNodeData

func (p *Peer) RequestNodeData(hashes []common.Hash) error

RequestNodeData fetches a batch of arbitrary data from a node's known state data, corresponding to the specified hashes.

func (*Peer) RequestOneHeader

func (p *Peer) RequestOneHeader(hash common.Hash) error

RequestOneHeader is a wrapper around the header query functions to fetch a single header. It is used solely by the fetcher.

func (*Peer) RequestReceipts

func (p *Peer) RequestReceipts(hashes []common.Hash) error

RequestReceipts fetches a batch of transaction receipts from a remote node.

func (*Peer) RequestTxs

func (p *Peer) RequestTxs(hashes []common.Hash) error

RequestTxs fetches a batch of transactions from a remote node.

func (*Peer) SendBlockBodiesRLP

func (p *Peer) SendBlockBodiesRLP(bodies []rlp.RawValue) error

SendBlockBodiesRLP sends a batch of block contents to the remote peer from an already RLP encoded format.

func (*Peer) SendBlockHeaders

func (p *Peer) SendBlockHeaders(headers []*types.Header) error

SendBlockHeaders sends a batch of block headers to the remote peer.

func (*Peer) SendNewBlock

func (p *Peer) SendNewBlock(block *types.Block, td *big.Int) error

SendNewBlock propagates an entire block to a remote peer.

func (*Peer) SendNewBlockHashes

func (p *Peer) SendNewBlockHashes(hashes []common.Hash, numbers []uint64) error

SendNewBlockHashes announces the availability of a number of blocks through a hash notification.

func (*Peer) SendNodeData

func (p *Peer) SendNodeData(data [][]byte) error

SendNodeDataRLP sends a batch of arbitrary internal data, corresponding to the hashes requested.

func (*Peer) SendPooledTransactionsRLP

func (p *Peer) SendPooledTransactionsRLP(hashes []common.Hash, txs []rlp.RawValue) error

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

func (p *Peer) SendReceiptsRLP(receipts []rlp.RawValue) error

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.

func (*Peer) SetHead

func (p *Peer) SetHead(hash common.Hash, td *big.Int)

SetHead updates the head hash and total difficulty of the peer.

func (*Peer) Version

func (p *Peer) Version() uint

Version retrieves the peer's negoatiated `eth` protocol version.

Jump to

Keyboard shortcuts

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