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 ¶
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.