syncer

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrForkTooLong is return when the syncing chain has fork with local
	ErrForkTooLong = fmt.Errorf("fork longer than threshold")
	// ErrChainHasBadTipSet is returned when the syncer traverses a chain with a cached bad tipset.
	ErrChainHasBadTipSet = errors.New("input chain contains a cached bad tipset")
	// ErrNewChainTooLong is returned when processing a fork that split off from the main chain too many blocks ago.
	ErrNewChainTooLong = errors.New("input chain forked from best chain past finality limit")
	// ErrUnexpectedStoreState indicates that the syncer's chain bsstore is violating expected invariants.
	ErrUnexpectedStoreState = errors.New("the chain bsstore is in an unexpected state")
)

Functions

func RangeProcess

func RangeProcess(ts []*types.TipSet, cb func(ts []*types.TipSet) error) (err error)

Types

type BlockValidator

type BlockValidator interface {
	ValidateFullBlock(ctx context.Context, blk *types.BlockHeader) error
}

type ChainReaderWriter

type ChainReaderWriter interface {
	GetHead() *types.TipSet
	GetTipSet(types.TipSetKey) (*types.TipSet, error)
	GetTipSetStateRoot(*types.TipSet) (cid.Cid, error)
	GetTipSetReceiptsRoot(*types.TipSet) (cid.Cid, error)
	HasTipSetAndState(context.Context, *types.TipSet) bool
	PutTipSetMetadata(context.Context, *chain.TipSetMetadata) error
	SetHead(context.Context, *types.TipSet) error
	HasSiblingState(*types.TipSet) bool
	GetSiblingState(*types.TipSet) ([]*chain.TipSetMetadata, error)
	GetLatestBeaconEntry(*types.TipSet) (*types.BeaconEntry, error)
	GetGenesisBlock(context.Context) (*types.BlockHeader, error)
}

ChainReaderWriter reads and writes the chain bsstore.

type ChainSelector

type ChainSelector interface {
	// IsHeavier returns true if tipset a is heavier than tipset b and false if
	// tipset b is heavier than tipset a.
	IsHeavier(ctx context.Context, a, b *types.TipSet) (bool, error)
	// Weight returns the weight of a tipset after the upgrade to version 1
	Weight(ctx context.Context, ts *types.TipSet) (big.Int, error)
}

ChainSelector chooses the heaviest between chains.

type StateProcessor added in v0.9.1

type StateProcessor interface {
	// RunStateTransition returns the state root CID resulting from applying the input ts to the
	// prior `stateRoot`.  It returns an error if the transition is invalid.
	RunStateTransition(ctx context.Context, ts *types.TipSet, parentStateRoot cid.Cid) (root cid.Cid, receipt cid.Cid, err error)
}

StateProcessor does semantic validation on fullblocks.

type Syncer

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

func NewSyncer

func NewSyncer(fv StateProcessor,
	hv BlockValidator,
	cs ChainSelector,
	s ChainReaderWriter,
	m messageStore,
	bsstore blockstore.Blockstore,
	exchangeClient exchange.Client,
	c clock.Clock,
	fork fork.IFork) (*Syncer, error)

NewSyncer constructs a Syncer ready for use. The chain reader must have a head tipset to initialize the staging field.

func (*Syncer) HandleNewTipSet

func (syncer *Syncer) HandleNewTipSet(ctx context.Context, target *syncTypes.Target) (err error)

HandleNewTipSet validates and syncs the chain rooted at the provided tipset to a chain bsstore. Iff catchup is false then the syncer will set the head.

func (*Syncer) Head added in v0.9.1

func (syncer *Syncer) Head() *types.TipSet

func (*Syncer) SetHead added in v0.9.1

func (syncer *Syncer) SetHead(ctx context.Context, ts *types.TipSet) error

Jump to

Keyboard shortcuts

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