Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentMainnetHeight() int64
- func HeightToUnix(height int64, genesisTs int64) int64
- func UnixToHeight(ts int64, genesisTs int64) int64
- type ActorProcessor
- type GapFiller
- type GapIndexer
- type GapIndexerLens
- type HeadEvent
- type HeadNotifier
- type MessageExecutionProcessor
- type MessageProcessor
- type TaskHeight
- type TaskResult
- type TipSetCache
- func (c *TipSetCache) Add(ts *types.TipSet) (*types.TipSet, error)
- func (c *TipSetCache) Confidence() int
- func (c *TipSetCache) Head() (*types.TipSet, error)
- func (c *TipSetCache) Height() abi.ChainEpoch
- func (c *TipSetCache) Len() int
- func (c *TipSetCache) Reset()
- func (c *TipSetCache) Revert(ts *types.TipSet) error
- func (c *TipSetCache) SetCurrent(ts *types.TipSet) error
- func (c *TipSetCache) Size() int
- func (c *TipSetCache) Tail() (*types.TipSet, error)
- func (c *TipSetCache) TailHeight() abi.ChainEpoch
- func (c *TipSetCache) Warm(ctx context.Context, head *types.TipSet, ...) error
- type TipSetIndexer
- type TipSetIndexerOpt
- type TipSetObserver
- type TipSetProcessor
- type TipSetsProcessor
- type Walker
- type Watcher
Constants ¶
const ( ActorStatesRawTask = "actorstatesraw" // task that only extracts raw actor state ActorStatesPowerTask = "actorstatespower" // task that only extracts power actor states (but not the raw state) ActorStatesRewardTask = "actorstatesreward" // task that only extracts reward actor states (but not the raw state) ActorStatesMinerTask = "actorstatesminer" // task that only extracts miner actor states (but not the raw state) ActorStatesInitTask = "actorstatesinit" // task that only extracts init actor states (but not the raw state) ActorStatesMarketTask = "actorstatesmarket" // task that only extracts market actor states (but not the raw state) ActorStatesMultisigTask = "actorstatesmultisig" // task that only extracts multisig actor states (but not the raw state) ActorStatesVerifreg = "actorstatesverifreg" // task that only extracts verified registry actor states (but not the raw state) BlocksTask = "blocks" // task that extracts block data MessagesTask = "messages" // task that extracts message data ChainEconomicsTask = "chaineconomics" // task that extracts chain economics data MultisigApprovalsTask = "msapprovals" // task that extracts multisig actor approvals ImplicitMessageTask = "implicitmessage" // task that extract implicitly executed messages: cron tick and block reward. ChainConsensusTask = "consensus" )
const ( // HeadEventRevert indicates that the event signals a reversion of a tipset from the chain HeadEventRevert = "revert" // HeadEventRevert indicates that the event signals the application of a tipset to the chain HeadEventApply = "apply" // HeadEventRevert indicates that the event signals the current known head tipset HeadEventCurrent = "current" )
Constants for HeadEvent types
const MainnetGenesisTs = 1598306400 // unix timestamp of genesis epoch
Variables ¶
var ( ErrCacheEmpty = errors.New("cache empty") ErrAddOutOfOrder = errors.New("added tipset height lower than current head") ErrRevertOutOfOrder = errors.New("reverted tipset does not match current head") ErrEmptyRevert = errors.New("reverted received on empty cache") )
var AllTasks = []string{ ActorStatesRawTask, ActorStatesPowerTask, ActorStatesRewardTask, ActorStatesMinerTask, ActorStatesInitTask, ActorStatesMarketTask, ActorStatesMultisigTask, ActorStatesVerifreg, BlocksTask, MessagesTask, ChainEconomicsTask, MultisigApprovalsTask, ImplicitMessageTask, ChainConsensusTask, }
var FullTaskSet mapset.Set
Functions ¶
func CurrentMainnetHeight ¶
func CurrentMainnetHeight() int64
CurrentMainnetHeight calculates the current height of the filecoin mainnet.
func HeightToUnix ¶
HeightToUnix converts a chain height to a unix timestamp given the unix timestamp of the genesis epoch.
func UnixToHeight ¶
UnixToHeight converts a unix timestamp a chain height given the unix timestamp of the genesis epoch.
Types ¶
type ActorProcessor ¶
type ActorProcessor interface { // ProcessActors processes a set of actors. If error is non-nil then the processor encountered a fatal error. // Any data returned must be accompanied by a processing report. ProcessActors(ctx context.Context, ts *types.TipSet, pts *types.TipSet, actors map[string]lens.ActorStateChange, emsgs []*lens.ExecutedMessage) (model.Persistable, *visormodel.ProcessingReport, error) }
type GapFiller ¶
func NewGapFiller ¶
type GapIndexer ¶
func NewGapIndexer ¶
type GapIndexerLens ¶
type HeadNotifier ¶
type HeadNotifier interface { // HeadEvents returns a channel that receives head events. It may be closed // by the sender of the events, in which case Err will return a non-nil error // explaining why. HeadEvents may return nil if this implementation will never // notify any events. HeadEvents() <-chan *HeadEvent // Err returns the reason for the closing of the HeadEvents channel. Err() error }
A HeadNotifier reports tipset events that occur at the head of the chain
type MessageExecutionProcessor ¶
type MessageExecutionProcessor interface {
ProcessMessageExecutions(ctx context.Context, store adt.Store, ts *types.TipSet, pts *types.TipSet, imsgs []*lens.MessageExecution) (model.Persistable, *visormodel.ProcessingReport, error)
}
type MessageProcessor ¶
type MessageProcessor interface { // ProcessMessages processes messages contained within a tipset. If error is non-nil then the processor encountered a fatal error. // pts is the tipset containing the messages, ts is the tipset containing the receipts // Any data returned must be accompanied by a processing report. ProcessMessages(ctx context.Context, ts *types.TipSet, pts *types.TipSet, emsgs []*lens.ExecutedMessage, blkMsgs []*lens.BlockMessages) (model.Persistable, *visormodel.ProcessingReport, error) }
type TaskHeight ¶
type TaskResult ¶
type TaskResult struct { Task string Error error Report visormodel.ProcessingReportList Data model.Persistable StartedAt time.Time CompletedAt time.Time }
A TaskResult is either some data to persist or an error which indicates that the task did not complete. Partial completions are possible provided the Data contains a persistable log of the results.
type TipSetCache ¶
type TipSetCache struct {
// contains filtered or unexported fields
}
TipSetCache is a cache of recent tipsets that can keep track of reversions. Inspired by tipSetCache in Lotus chain/events package.
func NewTipSetCache ¶
func NewTipSetCache(size int) *TipSetCache
func (*TipSetCache) Add ¶
Add adds a new tipset which becomes the new head of the cache. If the buffer is full, the tail being evicted is also returned.
func (*TipSetCache) Confidence ¶ added in v0.8.2
func (c *TipSetCache) Confidence() int
Confidence returns the number of tipset that the cache must hold before tipsets are evicted on Add.
func (*TipSetCache) Head ¶
func (c *TipSetCache) Head() (*types.TipSet, error)
Head returns the tipset at the head of the cache.
func (*TipSetCache) Height ¶
func (c *TipSetCache) Height() abi.ChainEpoch
Height returns the height of the current head or zero if the cache is empty.
func (*TipSetCache) Len ¶
func (c *TipSetCache) Len() int
Len returns the number of tipsets in the cache. This will never exceed the size of the cache.
func (*TipSetCache) Revert ¶
func (c *TipSetCache) Revert(ts *types.TipSet) error
Revert removes the head tipset
func (*TipSetCache) SetCurrent ¶
func (c *TipSetCache) SetCurrent(ts *types.TipSet) error
SetCurrent replaces the current head
func (*TipSetCache) Size ¶
func (c *TipSetCache) Size() int
Size returns the maximum number of tipsets that may be present in the cache.
func (*TipSetCache) Tail ¶
func (c *TipSetCache) Tail() (*types.TipSet, error)
Tail returns the tipset at the tail of the cache.
func (*TipSetCache) TailHeight ¶
func (c *TipSetCache) TailHeight() abi.ChainEpoch
TailHeight returns the height of the current tail or zero if the cache is empty.
type TipSetIndexer ¶
type TipSetIndexer struct {
// contains filtered or unexported fields
}
TipSetIndexer waits for tipsets and persists their block data into a database.
func NewTipSetIndexer ¶
func NewTipSetIndexer(node lens.API, d model.Storage, window time.Duration, name string, tasks []string, options ...TipSetIndexerOpt) (*TipSetIndexer, error)
NewTipSetIndexer extracts block, message and actor state data from a tipset and persists it to storage. Extraction and persistence are concurrent. Extraction of the a tipset can proceed while data from the previous extraction is being persisted. The indexer may be given a time window in which to complete data extraction. The name of the indexer is used as the reporter in the visor_processing_reports table.
func (*TipSetIndexer) Close ¶
func (t *TipSetIndexer) Close() error
func (*TipSetIndexer) SkipTipSet ¶
SkipTipSet writes a processing report to storage for each indexer task to indicate that the entire tipset was not processed.
type TipSetIndexerOpt ¶
type TipSetIndexerOpt func(t *TipSetIndexer)
type TipSetObserver ¶
type TipSetObserver interface { TipSet(ctx context.Context, ts *types.TipSet) error SkipTipSet(ctx context.Context, ts *types.TipSet, reason string) error Close() error }
A TipSetObserver waits for notifications of new tipsets.
type TipSetProcessor ¶
type TipSetProcessor interface { // ProcessTipSet processes a tipset. If error is non-nil then the processor encountered a fatal error. // Any data returned must be accompanied by a processing report. ProcessTipSet(ctx context.Context, ts *types.TipSet) (model.Persistable, *visormodel.ProcessingReport, error) }
type TipSetsProcessor ¶
type TipSetsProcessor interface { // ProcessTipSets processes a parent and child tipset. If error is non-nil then the processor encountered a fatal error. // Any data returned must be accompanied by a processing report. ProcessTipSets(ctx context.Context, child, parent *types.TipSet) (model.Persistable, visormodel.ProcessingReportList, error) }
type Walker ¶
type Walker struct {
// contains filtered or unexported fields
}
Walker is a job that indexes blocks by walking the chain history.
func NewWalker ¶
func NewWalker(obs TipSetObserver, node lens.API, minHeight, maxHeight int64) *Walker
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher is a task that indexes blocks by following the chain head.
func NewWatcher ¶
func NewWatcher(obs TipSetObserver, hn HeadNotifier, cache *TipSetCache) *Watcher
NewWatcher creates a new Watcher. confidence sets the number of tipsets that will be held in a cache awaiting possible reversion. Tipsets will be written to the database when they are evicted from the cache due to incoming later tipsets.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
builtin
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/account
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/cron
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/init
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/market
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/miner
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/multisig
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/paych
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/power
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/reward
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
builtin/verifreg
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |
policy
Code generated by: `make actors-gen`.
|
Code generated by: `make actors-gen`. |