packsdownloader

package
v0.0.0-...-59e56fa Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PacksDownloader

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

PacksDownloader is responsible for accumulating pack announcements from various peers and scheduling them for retrieval.

func New

func New(fetcher *fetcher.Fetcher, onlyNotConnected onlyNotConnectedFn, dropPeer dropPeerFn) *PacksDownloader

New creates a packs fetcher to retrieve events based on pack announcements.

func (*PacksDownloader) OnNewEpoch

func (d *PacksDownloader) OnNewEpoch(myEpoch idx.Epoch, peerEpoch func(string) idx.Epoch)

func (*PacksDownloader) Peer

func (*PacksDownloader) PeersNum

func (d *PacksDownloader) PeersNum() int

func (*PacksDownloader) RegisterPeer

func (d *PacksDownloader) RegisterPeer(peer Peer, myEpoch idx.Epoch) error

RegisterPeer injects a new download peer into the set of block source to be used for fetching hashes and blocks from.

func (*PacksDownloader) Terminate

func (d *PacksDownloader) Terminate()

Terminate interrupts the downloader, canceling all pending operations. The downloader cannot be reused after calling Terminate.

func (*PacksDownloader) UnregisterPeer

func (d *PacksDownloader) UnregisterPeer(peer string) error

UnregisterPeer removes 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 Peer

type Peer struct {
	ID    string
	Epoch idx.Epoch

	RequestPackInfos packInfoRequesterFn
	RequestPack      packRequesterFn
}

type PeerPacksDownloader

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

PeerPacksDownloader is responsible for accumulating pack announcements from various peers and scheduling them for retrieval.

func (*PeerPacksDownloader) NotifyPack

func (d *PeerPacksDownloader) NotifyPack(epoch idx.Epoch, index idx.Pack, ids hash.Events, time time.Time, fetchEvents fetcher.EventsRequesterFn) error

NotifyPack injects new packs from a peer

func (*PeerPacksDownloader) NotifyPackInfo

func (d *PeerPacksDownloader) NotifyPackInfo(epoch idx.Epoch, index idx.Pack, heads hash.Events, time time.Time) error

NotifyPackInfo injects new pack infos from a peer

func (*PeerPacksDownloader) NotifyPacksNum

func (d *PeerPacksDownloader) NotifyPacksNum(epoch idx.Epoch, packsNum idx.Pack) error

NotifyPacksNum injects new packs num from a peer

func (*PeerPacksDownloader) Start

func (d *PeerPacksDownloader) Start()

Start boots up the announcement based synchroniser, accepting and processing hash notifications and event fetches until termination requested.

func (*PeerPacksDownloader) Stop

func (d *PeerPacksDownloader) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

Jump to

Keyboard shortcuts

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