Documentation ¶
Index ¶
- Constants
- func AvailableSnapshotsHeights(dbpath string) ([]Data, []Data, error)
- func SnapshotsHeightsFromTree(tree *iavl.MutableTree) ([]Data, []Data, error)
- type Config
- type Data
- type Engine
- func (e *Engine) AddProviders(provs ...types.StateProvider)
- func (e *Engine) ApplySnapshot(ctx context.Context) error
- func (e *Engine) ApplySnapshotChunk(chunk *types.RawChunk) (bool, error)
- func (e *Engine) CheckLoaded() (bool, error)
- func (e *Engine) ClearAndInitialise() error
- func (e *Engine) Close() error
- func (e *Engine) GetMissingChunks() []uint32
- func (e *Engine) Hash(ctx context.Context) ([]byte, error)
- func (e *Engine) Info() ([]byte, int64, string)
- func (e *Engine) List() ([]*types.Snapshot, error)
- func (e *Engine) LoadSnapshotChunk(height uint64, format, chunk uint32) (*types.RawChunk, error)
- func (e *Engine) OnSnapshotIntervalUpdate(ctx context.Context, interval int64) error
- func (e *Engine) ReceiveSnapshot(snap *types.Snapshot) error
- func (e *Engine) RejectSnapshot() error
- func (e *Engine) ReloadConfig(cfg Config)
- func (e *Engine) Snapshot(ctx context.Context) (b []byte, errlol error)
- func (e *Engine) SnapshotNow(ctx context.Context) (b []byte, errlol error)
- type StateProviderT
- type StatsService
- type TimeService
Constants ¶
const (
SnapshotDBName = "snapshot"
)
Variables ¶
This section is empty.
Functions ¶
func SnapshotsHeightsFromTree ¶
func SnapshotsHeightsFromTree(tree *iavl.MutableTree) ([]Data, []Data, error)
Types ¶
type Config ¶
type Config struct { Level encoding.LogLevel `` /* 151-byte string literal not displayed */ KeepRecent int `long:"snapshot-keep-recent" description:"Number of historic snapshots to keep on disk. Limited to the 10 most recent ones"` RetryLimit int `long:"max-retries" description:"Maximum number of times to try and apply snapshot chunk"` Storage string `long:"storage" choice:"GOLevelDB" choice:"memory" description:"Storage type to use"` DBPath string `long:"db-path" description:"Path to database"` StartHeight int64 `` /* 207-byte string literal not displayed */ }
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
func NewTestConfig ¶
func NewTestConfig() Config
type Data ¶ added in v0.55.0
type Data struct { Version int64 `json:"version"` Hash []byte `json:"hash"` Height uint64 `json:"height"` Size int64 `json:"size"` }
Data is a representation of the information we an scrape from the avl tree.
type Engine ¶
type Engine struct { Config // contains filtered or unexported fields }
Engine the snapshot engine.
func New ¶
func New(ctx context.Context, vegapath paths.Paths, conf Config, log *logging.Logger, tm TimeService, stats StatsService) (*Engine, error)
New returns a new snapshot engine.
func (*Engine) AddProviders ¶
func (e *Engine) AddProviders(provs ...types.StateProvider)
AddProviders adds the provider keys and namespaces to the mappings N.B. if happens during taking a snapshot must be called within the lock.
func (*Engine) ApplySnapshot ¶
ApplySnapshot takes the snapshot data sent over via tendermint and reconstructs the AVL tree from the data. This call does *not* restore the state into the providers.
func (*Engine) ApplySnapshotChunk ¶
func (*Engine) CheckLoaded ¶
CheckLoaded will return whether we have loaded from a snapshot. If we have loaded via stat-sync we will already know if we are loading from local store, then we do that node.
func (*Engine) ClearAndInitialise ¶
ClearAndInitialise kicks the snapshot engine into its initial state setting up the DB connections and ensuring any pre-existing snapshot database is removed first. It is to be called by a chain that is starting from block 0.
func (*Engine) GetMissingChunks ¶
func (*Engine) Info ¶
Info simply returns the current snapshot hash Can be used for the TM info call.
func (*Engine) LoadSnapshotChunk ¶
func (*Engine) OnSnapshotIntervalUpdate ¶
func (*Engine) RejectSnapshot ¶
func (*Engine) ReloadConfig ¶
type StateProviderT ¶
type StateProviderT interface { // Namespace this provider operates in, basically a prefix for the keys Namespace() types.SnapshotNamespace // Keys gets all the nodes this provider populates Keys() []string // GetState returns the new state as a payload type // NB: GetState must be threadsafe as it may be called from multiple goroutines concurrently! GetState(key string) *types.Payload // PollChanges waits for an update on a channel - if nothing was updated, then nil can be sent // we can call this at the end of a block, so the engines have time until commit to provide the data // rather than a series of blocking calls PollChanges(ctx context.Context, k string, ch chan<- *types.Payload) // Sync is called when polling for changes, but we need the snapshot data now. Similar to wg.Wait() // on all of the state providers Sync() error // Err is called if the provider sent nil on the poll channel. Return nil if all was well (just no changes) // or the relevant error if something failed. The same error can be returned when calling Sync() Err() error // LoadState is called to set the state once again, has to return state providers // in case a new engine is created in the process (e.g. execution engine creating markets, with positions and matching engines) LoadState(ctx context.Context, pl *types.Payload) ([]types.StateProvider, error) }
type StatsService ¶
type StatsService interface {
SetHeight(uint64)
}