Documentation ¶
Index ¶
- Variables
- type AssetsState
- type CollateralState
- type Config
- type Engine
- func (e *Engine) Add(comps ...State) error
- func (e *Engine) BalanceCheckpoint(ctx context.Context) (*types.CheckpointState, error)
- func (e *Engine) Checkpoint(ctx context.Context, t time.Time) (*types.CheckpointState, error)
- func (e *Engine) Err() error
- func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *Engine) HasChanged(k string) bool
- func (e *Engine) Keys() []string
- func (e *Engine) LoadState(_ context.Context, snap *types.Payload) ([]types.StateProvider, error)
- func (e *Engine) Namespace() types.SnapshotNamespace
- func (e *Engine) OnTimeElapsedUpdate(ctx context.Context, d time.Duration) error
- func (e *Engine) PollChanges(ctx context.Context, k string, ch chan<- *types.Payload)
- func (e *Engine) RegisterOnCheckpointLoaded(f func(context.Context))
- func (e *Engine) Stopped() bool
- func (e *Engine) Sync() error
- func (e *Engine) UponGenesis(ctx context.Context, data []byte) (err error)
- func (e *Engine) ValidateCheckpoint(cpt *types.CheckpointState) error
- type GenesisState
- type State
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownCheckpointName = errors.New("component for checkpoint not registered") ErrComponentWithDuplicateName = errors.New("multiple components with the same name") ErrNoCheckpointExpectedToBeRestored = errors.New("no checkpoint expected to be restored") ErrIncompatibleHashes = errors.New("incompatible hashes") )
Functions ¶
This section is empty.
Types ¶
type AssetsState ¶
AssetsState is a bit of a hacky way to get the assets that were enabled when checkpoint was reloaded, so we can enable them in the collateral engine
type CollateralState ¶
CollateralState is part 2 of the hacky way to enable the assets required to load the collateral state
type Config ¶
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Add ¶
Add used to add/register components after the engine has been instantiated already this is mainly used to make testing easier.
func (*Engine) BalanceCheckpoint ¶
BalanceCheckpoint is used for deposits and withdrawals. We want a checkpoint to be taken in those events but these checkpoints should not affect the timing (delta, time between checkpoints). Currently, this call generates a full checkpoint, but we probably will change this to be a sparse checkpoint only containing changes in balances and (perhaps) network parameters...
func (*Engine) Checkpoint ¶
Checkpoint returns the overall checkpoint.
func (*Engine) HasChanged ¶
func (*Engine) Namespace ¶
func (e *Engine) Namespace() types.SnapshotNamespace
func (*Engine) OnTimeElapsedUpdate ¶
func (*Engine) PollChanges ¶
func (*Engine) RegisterOnCheckpointLoaded ¶
func (*Engine) UponGenesis ¶
func (*Engine) ValidateCheckpoint ¶
func (e *Engine) ValidateCheckpoint(cpt *types.CheckpointState) error
type GenesisState ¶
type GenesisState struct { CheckpointHash string `json:"load_hash"` CheckpointState string `json:"state"` }
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
func LoadGenesisState ¶
func LoadGenesisState(data []byte) (*GenesisState, error)
type State ¶
type State interface { Name() types.CheckpointName Checkpoint() ([]byte, error) Load(ctx context.Context, checkpoint []byte) error }
State interface represents system components that need checkpointting Name returns the component name (key in engine map) Hash returns, obviously, the state hash @TODO adding func to get the actual data