Documentation ¶
Overview ¶
Package downloader contains the manual full chain synchronisation.
Index ¶
- Variables
- type Block
- type DoneEvent
- type Downloader
- func (d *Downloader) DeliverBlocks(id string, blocks []*types.Block) error
- func (d *Downloader) DeliverHashes(id string, hashes []common.Hash) error
- func (d *Downloader) Has(hash common.Hash) bool
- func (d *Downloader) RegisterPeer(id string, head common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) error
- func (d *Downloader) Stats() (pending int, cached int, importing int, estimate time.Duration)
- func (d *Downloader) Synchronise(id string, head common.Hash)
- func (d *Downloader) Synchronising() bool
- func (d *Downloader) Terminate()
- func (d *Downloader) UnregisterPeer(id string) error
- type FailedEvent
- type StartEvent
Constants ¶
This section is empty.
Variables ¶
var ( MinHashFetch = 512 // Minimum amount of hashes to not consider a peer stalling MaxHashFetch = 2048 // Amount of hashes to be fetched per retrieval request MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request )
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func New ¶
func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock blockRetrievalFn, insertChain chainInsertFn, 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) 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) DeliverHashes ¶ added in v0.9.21
func (d *Downloader) DeliverHashes(id string, hashes []common.Hash) 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) Has ¶
func (d *Downloader) Has(hash common.Hash) bool
Has checks if the downloader knows about a particular hash, meaning that its either already downloaded of pending retrieval.
func (*Downloader) RegisterPeer ¶
func (d *Downloader) RegisterPeer(id string, head common.Hash, getHashes hashFetcherFn, getBlocks blockFetcherFn) 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 ¶
func (d *Downloader) Synchronise(id string, head common.Hash)
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.36
func (d *Downloader) Terminate()
Terminate interrupts the downloader, canceling all pending operations.
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.
type FailedEvent ¶ added in v0.9.21
type FailedEvent struct{ Err error }
type StartEvent ¶ added in v0.9.21
type StartEvent struct{}