Documentation
¶
Index ¶
- Variables
- func WithIndexCollections(do bool) func(*Config)
- func WithIndexCommit(do bool) func(*Config)
- func WithIndexEvents(do bool) func(*Config)
- func WithIndexGuarantees(do bool) func(*Config)
- func WithIndexHeader(do bool) func(*Config)
- func WithIndexPayloads(do bool) func(*Config)
- func WithIndexResults(do bool) func(*Config)
- func WithIndexSeals(do bool) func(*Config)
- func WithIndexTransactions(do bool) func(*Config)
- func WithSkipBootstrap(skip bool) func(*Config)
- func WithTransition(status Status, transition TransitionFunc) func(*FSM)
- func WithWaitInterval(interval time.Duration) func(*Config)
- type Config
- type FSM
- type Feeder
- type Forest
- type Loader
- type State
- type Status
- type TransitionFunc
- type Transitions
- func (t *Transitions) BootstrapState(s *State) error
- func (t *Transitions) CollectRegisters(s *State) error
- func (t *Transitions) ForwardHeight(s *State) error
- func (t *Transitions) IndexChain(s *State) error
- func (t *Transitions) IndexRegisters(s *State) error
- func (t *Transitions) UpdateTree(s *State) error
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ IndexCommit: false, IndexHeader: false, IndexCollections: false, IndexGuarantees: false, IndexTransactions: false, IndexResults: false, IndexEvents: false, IndexPayloads: false, IndexSeals: false, SkipBootstrap: false, WaitInterval: 100 * time.Millisecond, }
DefaultConfig is the default configuration for the Mapper.
Functions ¶
func WithIndexCollections ¶
WithIndexCollections sets up the mapper to build the collections index.
func WithIndexCommit ¶
WithIndexCommit sets up the mapper to build the commits index.
func WithIndexEvents ¶
WithIndexEvents sets up the mapper to build the events index.
func WithIndexGuarantees ¶ added in v1.1.0
WithIndexGuarantees sets up the mapper to build the guarantees index.
func WithIndexHeader ¶
WithIndexHeader sets up the mapper to build the headers index.
func WithIndexPayloads ¶
WithIndexPayloads sets up the mapper to build the payloads index.
func WithIndexResults ¶ added in v1.1.0
WithIndexResults sets up the mapper to build the transaction results index.
func WithIndexSeals ¶ added in v1.1.0
WithIndexSeals sets up the mapper to build the seals index.
func WithIndexTransactions ¶
WithIndexTransactions sets up the mapper to build the transactions index.
func WithSkipBootstrap ¶
WithSkipBootstrap sets the mapper up to skip indexing the registers from the initial checkpoint.
func WithTransition ¶
func WithTransition(status Status, transition TransitionFunc) func(*FSM)
WithTransition specifies which TransitionFunc should be used when the state machine has the given status.
func WithWaitInterval ¶ added in v1.3.0
WithWaitInterval sets the wait interval that we will wait before retrying to retrieve a trie update when it wasn't available.
Types ¶
type Config ¶
type Config struct {
// The following attributes specify whether to index specific elements.
IndexCommit bool
IndexHeader bool
IndexCollections bool
IndexGuarantees bool
IndexTransactions bool
IndexResults bool
IndexEvents bool
IndexPayloads bool
IndexSeals bool
// Whether to skip the bootstrapping part.
SkipBootstrap bool
// The interval of time to wait between each attempt to map blocks when
// reading from live components.
WaitInterval time.Duration
}
Config contains optional parameters for the Mapper.
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
FSM is a finite state machine which is used to map block data from multiple sources into the DPS index.
type Feeder ¶
type Feeder interface {
Update() (*ledger.TrieUpdate, error)
}
Feeder represents something that can be consumed to get trie updates in chronological order.
type Forest ¶
type Forest interface {
Save(tree *trie.MTrie, paths []ledger.Path, parent flow.StateCommitment)
Has(commit flow.StateCommitment) bool
Tree(commit flow.StateCommitment) (*trie.MTrie, bool)
Paths(commit flow.StateCommitment) ([]ledger.Path, bool)
Parent(commit flow.StateCommitment) (flow.StateCommitment, bool)
Reset(finalized flow.StateCommitment)
}
Forest represents a multitude of trees which are mapped by their state commitment hash.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the state machine's state.
func EmptyState ¶
EmptyState returns a new empty state that uses the given Forest.
type Status ¶
type Status uint8
Status is a representation of the state machine's status.
type TransitionFunc ¶
TransitionFunc is a function that is applied onto the state machine's state.
type Transitions ¶
type Transitions struct {
// contains filtered or unexported fields
}
Transitions is what applies transitions to the state of an FSM.
func NewTransitions ¶
func NewTransitions(log zerolog.Logger, load Loader, chain dps.Chain, feed Feeder, index dps.Writer, options ...func(*Config)) *Transitions
NewTransitions returns a Transitions component using the given dependencies and using the given options.
func (*Transitions) BootstrapState ¶
func (t *Transitions) BootstrapState(s *State) error
BootstrapState bootstraps the state by loading the checkpoint if there is one and initializing the elements subsequently used by the FSM.
func (*Transitions) CollectRegisters ¶
func (t *Transitions) CollectRegisters(s *State) error
CollectRegisters reads the payloads for the next block to be indexed from the state's forest, unless payload indexing is disabled.
func (*Transitions) ForwardHeight ¶
func (t *Transitions) ForwardHeight(s *State) error
ForwardHeight increments the height at which the mapping operates, and updates the last indexed height.
func (*Transitions) IndexChain ¶
func (t *Transitions) IndexChain(s *State) error
IndexChain indexes chain data for the current height.
func (*Transitions) IndexRegisters ¶
func (t *Transitions) IndexRegisters(s *State) error
IndexRegisters indexes the registers that the state contains.
func (*Transitions) UpdateTree ¶
func (t *Transitions) UpdateTree(s *State) error
UpdateTree updates the state's tree. If the state's forest already matches with the next block's state commitment, it immediately returns and sets the state's status to StatusMatched.