fetch

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

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

Go to latest
Published: Oct 26, 2016 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 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))

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)

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