checkpoint

package
v0.75.0-preview.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func RemoveAll added in v0.74.0

func RemoveAll(vegaPaths paths.Paths) error

Types

type AssetsState

type AssetsState interface {
	State
	GetEnabledAssets() []*types.Asset
}

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

type CollateralState interface {
	State
	EnableAsset(ctx context.Context, asset types.Asset) error
}

CollateralState is part 2 of the hacky way to enable the assets required to load the collateral state

type Config

type Config struct {
	// logging level
	Level encoding.LogLevel
}

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 New

func New(log *logging.Logger, cfg Config, components ...State) (*Engine, error)

func (*Engine) Add

func (e *Engine) Add(comps ...State) error

Add used to add/register components after the engine has been instantiated already this is mainly used to make testing easier.

func (*Engine) BalanceCheckpoint

func (e *Engine) BalanceCheckpoint(ctx context.Context) (*types.CheckpointState, error)

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

func (e *Engine) Checkpoint(ctx context.Context, t time.Time) (*types.CheckpointState, error)

Checkpoint returns the overall checkpoint.

func (*Engine) Err

func (e *Engine) Err() error

func (*Engine) GetState

func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Engine) Keys

func (e *Engine) Keys() []string

func (*Engine) LoadState

func (e *Engine) LoadState(_ context.Context, snap *types.Payload) ([]types.StateProvider, error)

func (*Engine) Namespace

func (e *Engine) Namespace() types.SnapshotNamespace

func (*Engine) OnTimeElapsedUpdate

func (e *Engine) OnTimeElapsedUpdate(ctx context.Context, d time.Duration) error

func (*Engine) PollChanges

func (e *Engine) PollChanges(ctx context.Context, k string, ch chan<- *types.Payload)

func (*Engine) RegisterOnCheckpointLoaded

func (e *Engine) RegisterOnCheckpointLoaded(f func(context.Context))

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) Sync

func (e *Engine) Sync() error

func (*Engine) UponGenesis

func (e *Engine) UponGenesis(ctx context.Context, data []byte) (err error)

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

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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