synchronizer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MaxHeadersPerBatch is the number of headers to be retrieved per batch.
	MaxHeadersPerBatch = 64

	// MaxBlocksPerBatch is the number of blocks to be retrieved per batch.
	MaxBlocksPerBatch = 42

	// ProviderSearchTimeout is the max duration to find a peer for a resource.
	ProviderSearchTimeout = time.Second * 10
)

Variables

View Source
var (
	// ErrNoProvider is returned when no peer was found for a given resource.
	ErrNoProvider = errors.New("no peer could provide the resource")

	// ErrNoCommonAncestor is returned when no common ancestor is found with a peer's chain.
	ErrNoCommonAncestor = errors.New("the peer's chain does not intersect with ours")
)
View Source
var OptMaxBatchSizes = func(m uint64) Opt {
	return func(c *synchronizer) {
		c.maxHeadersPerBatch = m
		c.maxBlocksPerBatch = m
	}
}

OptMaxBatchSizes sets a max for the number of items in batch calls.

Functions

This section is empty.

Types

type ContentProviderFinder

type ContentProviderFinder interface {
	FindProviders(ctx context.Context, c cid.Cid) ([]pstore.PeerInfo, error)
}

ContentProviderFinder is an interface used to get the peers that provide a resource. The resource is identified by a content ID.

type Opt

type Opt func(*synchronizer)

Opt is an option for Synchronizer.

type Synchronizer

type Synchronizer interface {
	// Synchronize syncs the local chain with the network.
	// The given hash tells where to start the sync from.
	// e.g, genesis block hash for full resync when a new node comes.
	// Returns the blocks in a channel.
	Synchronize(context.Context, []byte, chain.Reader) (<-chan *pb.Block, <-chan error)
}

Synchronizer is used to sync the local chain with a peer's chain.

func NewSynchronizer

func NewSynchronizer(p p2p.P2P, dht ContentProviderFinder, opts ...Opt) Synchronizer

NewSynchronizer initializes a new synchronizer.

Directories

Path Synopsis
Package mocksynchronizer is a generated GoMock package.
Package mocksynchronizer is a generated GoMock package.

Jump to

Keyboard shortcuts

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