Version: v0.0.0-...-686c1ca Latest Latest

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

Go to latest
Published: May 12, 2015 License: GPL-2.0 Imports: 11 Imported by: 0




This section is empty.


View Source
var (
	ErrBusy = errors.New("busy")

	ErrPendingQueue = errors.New("pending items in queue")
	ErrTimeout      = errors.New("timeout")


This section is empty.


type Downloader

type Downloader struct {
	// contains filtered or unexported fields

func New

func New(hasBlock hashCheckFn, getBlock getBlockFn) *Downloader

func (*Downloader) AddHashes

func (d *Downloader) AddHashes(id string, hashes []common.Hash) error

func (*Downloader) Cancel

func (d *Downloader) Cancel() bool

Cancel cancels all of the operations and resets the queue. It returns true if the cancel operation was completed.

func (*Downloader) DeliverChunk

func (d *Downloader) DeliverChunk(id string, blocks []*types.Block) error

Deliver a chunk to the downloader. This is usually done through the BlocksMsg by the protocol handler.

func (*Downloader) Has

func (d *Downloader) Has(hash common.Hash) bool

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

func (d *Downloader) Stats() (current int, max int)

func (*Downloader) Synchronise

func (d *Downloader) Synchronise(id string, hash common.Hash) error

Synchronise will select the peer and use it for synchronising. If an empty string is given it will use the best peer possible and synchronize if it's TD is higher than our own. If any of the checks fail an error will be returned. This method is synchronous

func (*Downloader) TakeBlocks

func (d *Downloader) TakeBlocks() types.Blocks

TakeBlocks takes blocks from the queue and yields them to the blockTaker handler it's possible it yields no blocks

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL