Documentation ¶
Overview ¶
Package downloader contains the manual full chain synchronisation.
Package downloader contains the manual full chain synchronisation.
Index ¶
- Variables
- type BlockChain
- type DoneEvent
- type Downloader
- func (d *Downloader) Cancel()
- func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
- func (d *Downloader) RegisterLightPeer(id string, version int, peer LightPeer) error
- func (d *Downloader) RegisterPeer(id string, version int, peer Peer) 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 LightPeer
- type Peer
- 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 MaxSkeletonSize = 128 // Number of header fetches to need for a skeleton assembly 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 MaxForkAncestry = 3 * params.EpochDuration // Maximum chain reorganisation )
Functions ¶
This section is empty.
Types ¶
type BlockChain ¶
type BlockChain interface { // HasHeader verifies a header's presence in the local chain. HasHeader(common.Hash, uint64) bool // GetHeaderByHash retrieves a header from the local chain. GetHeaderByHash(common.Hash) *types.Header // CurrentHeader retrieves the head header from the local chain. CurrentHeader() *types.Header // GetTd returns the total difficulty of a local block. GetTd(common.Hash, uint64) *big.Int // InsertHeaderChain inserts a batch of headers into the local chain. InsertHeaderChain([]*types.Header, int) (int, error) }
BlockChain encapsulates functions required to synchronise a light chain.
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func New ¶
func New(mode SyncMode, stateDb ethdb.Database, mux *event.TypeMux, chain BlockChain, dropPeer peerDropFn) *Downloader
New creates a new downloader to fetch hashes and blocks from remote peers.
func (*Downloader) Cancel ¶
func (d *Downloader) Cancel()
Cancel cancels all of the operations and resets the queue. It returns true if the cancel operation was completed.
func (*Downloader) DeliverHeaders ¶
func (d *Downloader) DeliverHeaders(id string, headers []*types.Header) (err error)
DeliverHeaders injects a new batch of block headers received from a remote node into the download schedule.
func (*Downloader) RegisterLightPeer ¶
func (d *Downloader) RegisterLightPeer(id string, version int, peer LightPeer) error
RegisterLightPeer injects a light client peer, wrapping it so it appears as a regular peer.
func (*Downloader) RegisterPeer ¶
func (d *Downloader) RegisterPeer(id string, version int, peer Peer) 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 ¶
func (d *Downloader) Synchronising() bool
Synchronising returns whether the downloader is currently retrieving blocks.
func (*Downloader) Terminate ¶
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 ¶
type FailedEvent struct{ Err error }
type LightPeer ¶
type LightPeer interface { Head() (common.Hash, *big.Int) RequestHeadersByHash(common.Hash, int, int, bool) error RequestHeadersByNumber(uint64, int, int, bool) error }
LightPeer encapsulates the methods required to synchronise with a remote light peer.
type Peer ¶
type Peer interface { LightPeer }
Peer encapsulates the methods required to synchronise with a remote full peer.
type StartEvent ¶
type StartEvent struct{}
type SyncMode ¶
type SyncMode int
SyncMode represents the synchronisation mode of the downloader.