Documentation ¶
Overview ¶
Package downloader contains the manual full chain synchronisation.
Index ¶
- Variables
- type DoneEvent
- type Downloader
- func (d *Downloader) DeliverBlocks(id string, blocks []*types.Block) (err error)
- func (d *Downloader) DeliverBodies(id string, transactions [][]*types.Transaction, uncles [][]*types.Header) (err error)
- func (d *Downloader) DeliverHashes(id string, hashes []common.Hash) (err error)
- func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
- func (d *Downloader) DeliverNodeData(id string, data [][]byte) (err error)
- func (d *Downloader) DeliverReceipts(id string, receipts [][]*types.Receipt) (err error)
- func (d *Downloader) Progress() (uint64, uint64, uint64)
- func (d *Downloader) RegisterPeer(id string, version int, head common.Hash, getRelHashes relativeHashFetcherFn, ...) error
- func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, mode SyncMode) error
- func (d *Downloader) Synchronising() bool
- func (d *Downloader) Terminate()
- func (d *Downloader) UnregisterPeer(id string) error
- type FailedEvent
- type StartEvent
- type SyncMode
Constants ¶
This section is empty.
Variables ¶
var ( MaxHashFetch = 512 // Amount of hashes to be fetched per retrieval request MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request MaxBodyFetch = 128 // Amount of block bodies to be fetched per retrieval request MaxReceiptFetch = 256 // Amount of transaction receipts to allow fetching per request MaxStateFetch = 384 // Amount of node state values to allow fetching per request )
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func New ¶
func New(stateDb ethdb.Database, mux *event.TypeMux, hasHeader headerCheckFn, hasBlockAndState blockAndStateCheckFn, getHeader headerRetrievalFn, getBlock blockRetrievalFn, headHeader headHeaderRetrievalFn, headBlock headBlockRetrievalFn, headFastBlock headFastBlockRetrievalFn, commitHeadBlock headBlockCommitterFn, getTd tdRetrievalFn, insertHeaders headerChainInsertFn, insertBlocks blockChainInsertFn, insertReceipts receiptChainInsertFn, rollback chainRollbackFn, dropPeer peerDropFn) *Downloader
New creates a new downloader to fetch hashes and blocks from remote peers.
func (*Downloader) DeliverBlocks ¶ added in v0.9.21
func (d *Downloader) DeliverBlocks(id string, blocks []*types.Block) (err error)
DeliverBlocks injects a new batch of blocks received from a remote node. This is usually invoked through the BlocksMsg by the protocol handler.
func (*Downloader) DeliverBodies ¶ added in v1.2.3
func (d *Downloader) DeliverBodies(id string, transactions [][]*types.Transaction, uncles [][]*types.Header) (err error)
DeliverBodies injects a new batch of block bodies received from a remote node.
func (*Downloader) DeliverHashes ¶ added in v0.9.21
func (d *Downloader) DeliverHashes(id string, hashes []common.Hash) (err error)
DeliverHashes injects a new batch of hashes received from a remote node into the download schedule. This is usually invoked through the BlockHashesMsg by the protocol handler.
func (*Downloader) DeliverHeaders ¶ added in v1.2.3
func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
DeliverHeaders injects a new batch of blck headers received from a remote node into the download schedule.
func (*Downloader) DeliverNodeData ¶ added in v1.3.1
func (d *Downloader) DeliverNodeData(id string, data [][]byte) (err error)
DeliverNodeData injects a new batch of node state data received from a remote node.
func (*Downloader) DeliverReceipts ¶ added in v1.3.1
func (d *Downloader) DeliverReceipts(id string, receipts [][]*types.Receipt) (err error)
DeliverReceipts injects a new batch of receipts received from a remote node.
func (*Downloader) Progress ¶ added in v1.3.1
func (d *Downloader) Progress() (uint64, uint64, uint64)
Progress retrieves the synchronisation boundaries, specifically the origin block where synchronisation started at (may have failed/suspended); the block or header sync is currently at; and the latest known block which the sync targets.
func (*Downloader) RegisterPeer ¶
func (d *Downloader) RegisterPeer(id string, version int, head common.Hash, getRelHashes relativeHashFetcherFn, getAbsHashes absoluteHashFetcherFn, getBlocks blockFetcherFn, getRelHeaders relativeHeaderFetcherFn, getAbsHeaders absoluteHeaderFetcherFn, getBlockBodies blockBodyFetcherFn, getReceipts receiptFetcherFn, getNodeData stateFetcherFn) error
RegisterPeer injects a new download peer into the set of block source to be used for fetching hashes and blocks from.
func (*Downloader) Synchronise ¶
Synchronise tries to sync up our local block chain with a remote peer, both adding various sanity checks as well as wrapping it with various log entries.
func (*Downloader) Synchronising ¶ added in v0.9.21
func (d *Downloader) Synchronising() bool
Synchronising returns whether the downloader is currently retrieving blocks.
func (*Downloader) Terminate ¶ added in v0.9.32
func (d *Downloader) Terminate()
Terminate interrupts the downloader, canceling all pending operations. The downloader cannot be reused after calling Terminate.
func (*Downloader) UnregisterPeer ¶
func (d *Downloader) UnregisterPeer(id string) error
UnregisterPeer remove a peer from the known list, preventing any action from the specified peer. An effort is also made to return any pending fetches into the queue.
type FailedEvent ¶ added in v0.9.21
type FailedEvent struct{ Err error }
type StartEvent ¶ added in v0.9.21
type StartEvent struct{}