fetch

package
v0.0.0-...-7b153b8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package fetch implements block replication for participant Chain Cores.

Index

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

func GeneratorHeight() (uint64, time.Time)

func Init

func Init(ctx context.Context, peer *rpc.Client)

Init initializes the fetch package.

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

func (*Snapshot) BytesRead

func (r *Snapshot) BytesRead() uint64

func (*Snapshot) InProgress

func (s *Snapshot) InProgress() bool

func (*Snapshot) Read

func (r *Snapshot) Read(b []byte) (int, error)

Jump to

Keyboard shortcuts

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