downloader

package
v0.9.23 Latest Latest
Warning

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

Go to latest
Published: May 21, 2015 License: LGPL-2.1-or-later Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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

)

Variables

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

	ErrBadPeer      = errors.New("action from bad peer ignored")
	ErrStallingPeer = errors.New("peer is stalling")

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

	ErrInvalidChain     = errors.New("retrieved hash chain is invalid")
	ErrCrossCheckFailed = errors.New("block cross-check failed")
)

Functions

This section is empty.

Types

type DoneEvent added in v0.9.22

type DoneEvent struct{}

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

func New

func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock getBlockFn) *Downloader

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) DeliverBlocks added in v0.9.22

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.22

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

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) Synchronising added in v0.9.22

func (d *Downloader) Synchronising() bool

Synchronising returns the state of the downloader

func (*Downloader) TakeBlocks

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

TakeBlocks takes blocks from the queue and yields them to the caller.

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.22

type FailedEvent struct{ Err error }

type StartEvent added in v0.9.22

type StartEvent struct{}

Jump to

Keyboard shortcuts

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