snapshot

package
v0.68.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnapshotDBName     = "snapshot"
	SnapshotMetaDBName = "snapshot_meta"
)

Variables

View Source
var ErrUnknownSnapshotVersion = errors.New("unknown snapshot version")

Functions

func AvailableSnapshotsHeights

func AvailableSnapshotsHeights(dbpath string) ([]Data, []Data, error)

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

func (e *Engine) ApplySnapshot(ctx context.Context) error

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 (e *Engine) ApplySnapshotChunk(chunk *types.RawChunk) (bool, error)

func (*Engine) CheckLoaded

func (e *Engine) CheckLoaded() (bool, error)

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

func (e *Engine) ClearAndInitialise() error

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) Close

func (e *Engine) Close() error

func (*Engine) GetMissingChunks

func (e *Engine) GetMissingChunks() []uint32

func (*Engine) Hash

func (e *Engine) Hash(ctx context.Context) ([]byte, error)

func (*Engine) Info

func (e *Engine) Info() ([]byte, int64, string)

Info simply returns the current snapshot hash Can be used for the TM info call.

func (*Engine) List

func (e *Engine) List() ([]*types.Snapshot, error)

List returns all snapshots available.

func (*Engine) ListMeta added in v0.65.1

func (e *Engine) ListMeta() ([]*tmtypes.Snapshot, error)

List returns all snapshots available.

func (*Engine) LoadSnapshotChunk

func (e *Engine) LoadSnapshotChunk(height uint64, format, chunk uint32) (*types.RawChunk, error)

func (*Engine) OnSnapshotIntervalUpdate

func (e *Engine) OnSnapshotIntervalUpdate(ctx context.Context, interval int64) error

func (*Engine) ReceiveSnapshot

func (e *Engine) ReceiveSnapshot(snap *types.Snapshot) error

func (*Engine) RejectSnapshot

func (e *Engine) RejectSnapshot() error

func (*Engine) ReloadConfig

func (e *Engine) ReloadConfig(cfg Config)

func (*Engine) Snapshot

func (e *Engine) Snapshot(ctx context.Context) (b []byte, errlol error)

func (*Engine) SnapshotNow

func (e *Engine) SnapshotNow(ctx context.Context) (b []byte, errlol error)

SnapshotNow takes a snapshot regardless of current block height as requested.

type MDB added in v0.66.0

type MDB interface {
	Save(version []byte, state []byte) error
	Load(version []byte) (state []byte, err error)
	Close() error
}

func NewMetaGoLevelDB added in v0.66.0

func NewMetaGoLevelDB(db *db.GoLevelDB) MDB

func NewMetaMemDB added in v0.66.0

func NewMetaMemDB() MDB

type MetaDB added in v0.66.0

type MetaDB struct {
	// contains filtered or unexported fields
}

func NewMetaDB added in v0.66.0

func NewMetaDB(db MDB) *MetaDB

func (*MetaDB) Close added in v0.66.0

func (m *MetaDB) Close() error

func (*MetaDB) Load added in v0.66.0

func (m *MetaDB) Load(version int64) (*tmtypes.Snapshot, error)

func (*MetaDB) Save added in v0.66.0

func (m *MetaDB) Save(version int64, state *tmtypes.Snapshot) error

type MetaGoLevelDB added in v0.66.0

type MetaGoLevelDB struct {
	// contains filtered or unexported fields
}

func (*MetaGoLevelDB) Close added in v0.66.0

func (m *MetaGoLevelDB) Close() error

func (*MetaGoLevelDB) Load added in v0.66.0

func (m *MetaGoLevelDB) Load(version []byte) (state []byte, err error)

func (*MetaGoLevelDB) Save added in v0.66.0

func (m *MetaGoLevelDB) Save(version []byte, state []byte) error

type MetaMemDB added in v0.66.0

type MetaMemDB struct {
	// contains filtered or unexported fields
}

func (*MetaMemDB) Close added in v0.66.0

func (m *MetaMemDB) Close() error

func (*MetaMemDB) Load added in v0.66.0

func (m *MetaMemDB) Load(version []byte) (state []byte, err error)

func (*MetaMemDB) Save added in v0.66.0

func (m *MetaMemDB) Save(version []byte, state []byte) error

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)
}

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
	SetTimeNow(context.Context, time.Time)
}

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