downloader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconHelperConfig

type BeaconHelperConfig struct {
	BlockC     <-chan *types.Block
	InsertHook func()
}

BeaconHelperConfig is the extra config used for beaconHelper which uses pub-sub block message to do sync.

type Config

type Config struct {
	// Only run stream sync protocol as a server.
	// TODO: remove this when stream sync is fully up.
	ServerOnly bool

	// parameters
	Network     nodeconfig.NetworkType
	Concurrency int // Number of concurrent sync requests
	MinStreams  int // Minimum number of streams to do sync
	InitStreams int // Number of streams requirement for initial bootstrap

	// stream manager config
	SmSoftLowCap int
	SmHardLowCap int
	SmHiCap      int
	SmDiscBatch  int

	// config for beacon config
	BHConfig *BeaconHelperConfig
}

Config is the downloader config

type Downloader

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

Downloader is responsible for sync task of one shard

func NewDownloader

func NewDownloader(host p2p.Host, bc core.BlockChain, config Config) *Downloader

NewDownloader creates a new downloader

func (*Downloader) Close

func (d *Downloader) Close()

Close close the downloader

func (*Downloader) DownloadAsync

func (d *Downloader) DownloadAsync()

DownloadAsync triggers the download async.

func (*Downloader) NumPeers

func (d *Downloader) NumPeers() int

NumPeers returns the number of peers connected of a specific shard.

func (*Downloader) Start

func (d *Downloader) Start()

Start start the downloader

func (*Downloader) SubscribeDownloadFinished

func (d *Downloader) SubscribeDownloadFinished(ch chan struct{}) event.Subscription

SubscribeDownloadFinished subscribe the download finished

func (*Downloader) SubscribeDownloadStarted

func (d *Downloader) SubscribeDownloadStarted(ch chan struct{}) event.Subscription

SubscribeDownloadStarted subscribe download started

func (*Downloader) SyncStatus

func (d *Downloader) SyncStatus() (bool, uint64, uint64)

IsSyncing return the current sync status

type Downloaders

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

Downloaders is the set of downloaders

func NewDownloaders

func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downloaders

NewDownloaders creates Downloaders for sync of multiple blockchains

func (*Downloaders) Close

func (ds *Downloaders) Close()

Close close the downloaders

func (*Downloaders) DownloadAsync

func (ds *Downloaders) DownloadAsync(shardID uint32)

DownloadAsync triggers a download

func (*Downloaders) GetShardDownloader

func (ds *Downloaders) GetShardDownloader(shardID uint32) *Downloader

GetShardDownloader get the downloader with the given shard ID

func (*Downloaders) IsActive

func (ds *Downloaders) IsActive() bool

IsActive returns whether the downloader is active

func (*Downloaders) NumPeers

func (ds *Downloaders) NumPeers() map[uint32]int

NumPeers returns the connected peers for each shard

func (*Downloaders) Start

func (ds *Downloaders) Start()

Start start the downloaders

func (*Downloaders) SyncStatus

func (ds *Downloaders) SyncStatus(shardID uint32) (bool, uint64, uint64)

SyncStatus returns whether the given shard is doing syncing task and the target block number.

Jump to

Keyboard shortcuts

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