Documentation ¶
Overview ¶
Package fetch implements block replication for participant Chain Cores.
Index ¶
- func BootstrapSnapshot(ctx context.Context, c *protocol.Chain, peer *rpc.Client, health func(error))
- func DownloadBlocks(ctx context.Context, peer *rpc.Client, height uint64) (chan *bc.Block, chan error)
- func Fetch(ctx context.Context, c *protocol.Chain, peer *rpc.Client, health func(error), ...)
- func GeneratorHeight() (uint64, time.Time)
- func Init(ctx context.Context, peer *rpc.Client)
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BootstrapSnapshot ¶
func BootstrapSnapshot(ctx context.Context, c *protocol.Chain, peer *rpc.Client, health func(error))
BootstrapSnapshot downloads and stores the most recent snapshot from the provided peer. It's run when bootstrapping a new Core to an existing network. It should be run before invoking Chain.Recover.
func DownloadBlocks ¶
func DownloadBlocks(ctx context.Context, peer *rpc.Client, height uint64) (chan *bc.Block, chan error)
DownloadBlocks starts a goroutine to download blocks from the given peer, starting at the given height and incrementing from there. It will re-attempt downloads for the next block in the network until it is available. It returns two channels, one for reading blocks and the other for reading errors. Progress will halt unless callers are reading from both. DownloadBlocks will continue even if it encounters errors, until its context is done.
func Fetch ¶
func Fetch(ctx context.Context, c *protocol.Chain, peer *rpc.Client, health func(error), prevBlock *bc.Block, prevSnapshot *state.Snapshot)
Fetch runs in a loop, fetching blocks from the configured peer (e.g. the generator) and applying them to the local Chain.
It returns when its context is canceled. After each attempt to fetch and apply a block, it calls health to report either an error or nil to indicate success.
func GeneratorHeight ¶
Types ¶
type Snapshot ¶
type Snapshot struct { Attempt int Height uint64 Size uint64 // contains filtered or unexported fields }
Snapshot describes a snapshot being downloaded from a peer Core.
func SnapshotProgress ¶
func SnapshotProgress() *Snapshot