download

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBusy          = fmt.Errorf("busy")
	ErrCanceled      = fmt.Errorf("syncing canceled (requested)")
	ErrSyncBlock     = fmt.Errorf("err sync block")
	ErrTimeout       = fmt.Errorf("timeout")
	ErrBadPeer       = fmt.Errorf("bad peer error")
	ErrNoPeers       = fmt.Errorf("no peers to download")
	ErrInvalidPubSub = fmt.Errorf("PubSub is nil")
)

Functions

func NewDownloader

func NewDownloader(ctx context.Context, bc common.IBlockChain, network common.INetwork, pubsub common.IPubSub, peers common.PeerMap) common.IDownloader

Types

type Downloader

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

func (*Downloader) Close

func (d *Downloader) Close() error

func (*Downloader) ConnHandler

func (d *Downloader) ConnHandler(data []byte, ID peer.ID) error

func (*Downloader) FindBlock

func (d *Downloader) FindBlock(number uint64, peerID peer.ID) (uint64, error)

func (*Downloader) IsDownloading

func (d *Downloader) IsDownloading() bool

func (*Downloader) Start

func (d *Downloader) Start() error

Start Downloader

func (*Downloader) SyncBody

func (d *Downloader) SyncBody() error

func (*Downloader) SyncHeader

func (d *Downloader) SyncHeader() error

func (*Downloader) SyncTx

func (d *Downloader) SyncTx() error

type Request

type Request struct {
	Peer string    // Demultiplexer if cross-peer requests are batched together
	Sent time.Time // Timestamp when the request was sent
	// contains filtered or unexported fields
}

type Response

type Response struct {
	Req  *request      // Original request to cross-reference with
	Res  interface{}   // Remote response for the request query
	Meta interface{}   // Metadata generated locally on the receiver thread
	Time time.Duration // Time it took for the request to be served
	Done chan error    // Channel to signal message handling to the reader
	// contains filtered or unexported fields
}

type SyncMode

type SyncMode uint32

SyncMode represents the synchronisation mode of the downloader. It is a uint32 as it is used with atomic operations.

const (
	FullSync SyncMode = iota
	SnapSync
	LightSync
	HeaderSync
)

func (SyncMode) IsValid

func (mode SyncMode) IsValid() bool

func (SyncMode) MarshalText

func (mode SyncMode) MarshalText() ([]byte, error)

func (SyncMode) String

func (mode SyncMode) String() string

String implements the stringer interface.

func (*SyncMode) UnmarshalText

func (mode *SyncMode) UnmarshalText(text []byte) error

type Task

type Task struct {
	Id         peer.ID
	H          hash.Hash
	TimeBegin  time.Time
	IsSync     bool
	IndexBegin uint256.Int
	IndexEnd   uint256.Int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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