snapshot

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCurrentStateSnapshotFound = errors.New("no current state snapshot found")

Functions

func GetAllAvailableHistory

func GetAllAvailableHistory(snapshotsPath string, oldestHistoryBlock *entities.Block, lastBlock *entities.Block) (string, *CurrentStateSnapshot, []HistorySnapshot, error)

func GetAllTableNames

func GetAllTableNames(ctx context.Context, conn *pgxpool.Pool) ([]string, error)

func GetChainID

func GetChainID(currentStatesChainID string, historiesChainID string) (string, error)

func GetCurrentStateSnapshots

func GetCurrentStateSnapshots(snapshotsDir string) (string, map[int64]CurrentStateSnapshot, error)

func GetFromHeight

func GetFromHeight(toHeight int64, snapshotInterval int64) int64

func GetHistoryIncludingDatanodeState

func GetHistoryIncludingDatanodeState(datanodeOldestHistoryBlock *entities.Block, datanodeLastBlock *entities.Block, chainID string,
	currentStateData map[int64]CurrentStateSnapshot, histories []HistorySnapshot,
) (*CurrentStateSnapshot, []HistorySnapshot, error)

GetHistoryIncludingDatanodeState returns currentStateSnapshot of the youngest snapshot or nil if none is found. Return the contiguous history in oldest first order or nil if none is found. If the datanode is populated with data, only snapshot data upto the datanodes current height will be returned.

func GetHistoryMd5Hash

func GetHistoryMd5Hash(log *logging.Logger, snapshot Meta) (string, error)

func GetOldestHistoryBlockAndLastBlock

func GetOldestHistoryBlockAndLastBlock(ctx context.Context, connConfig sqlstore.ConnectionConfig, blockStore *sqlstore.Blocks) (*entities.Block, *entities.Block, error)

func GetSnapshotMd5Hash

func GetSnapshotMd5Hash(log *logging.Logger, currentStateSnapshotFile string, historySnapshotFile string) (string, error)

func GetToAndFromHeightFromHistory

func GetToAndFromHeightFromHistory(currentStateSnapshot *CurrentStateSnapshot, contiguousHistory []HistorySnapshot) (int64, int64)

func HasVegaSchema

func HasVegaSchema(ctx context.Context, conf sqlstore.ConnectionConfig) (bool, error)

func InProgressFileName

func InProgressFileName(chainID string, height int64) string

Types

type Config

type Config struct {
	Enabled encoding.Bool `long:"set to false to prevent datanode creating snapshots" description:"set to false to prevent datanode creating snapshots"`

	RemoveSnapshotsOnStartup encoding.Bool `long:"remove-snapshops-on-startup" description:"if true the nodes snapshot directory will be emptied at startup"`

	Publish encoding.Bool `long:"publish" description:"set to true if this node should publish snapshot data"`

	DatabaseSnapshotsPath string `long:"database-snapshot-path" description:"the snapshots path relative the database working directory"`
}

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.

type Conn

type Conn interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type CurrentStateSnapshot

type CurrentStateSnapshot struct {
	ChainID string
	Height  int64
}

func NewCurrentSnapshot

func NewCurrentSnapshot(chainID string, height int64) CurrentStateSnapshot

func (CurrentStateSnapshot) CompressedFileName

func (s CurrentStateSnapshot) CompressedFileName() string

func (CurrentStateSnapshot) GetCopySQL

func (s CurrentStateSnapshot) GetCopySQL(dbMetaData DatabaseMetadata, databaseSnapshotsPath string) []string

func (CurrentStateSnapshot) String

func (s CurrentStateSnapshot) String() string

func (CurrentStateSnapshot) UncompressedDataDir

func (s CurrentStateSnapshot) UncompressedDataDir() string

type DatabaseMetadata

type DatabaseMetadata struct {
	TableNameToMetaData map[string]TableMetadata
	DatabaseVersion     int64
}

func NewDatabaseMetaData

func NewDatabaseMetaData(ctx context.Context, connConfig sqlstore.ConnectionConfig) (DatabaseMetadata, error)

func (DatabaseMetadata) GetHistoryTableNames

func (d DatabaseMetadata) GetHistoryTableNames() []string

type HistorySnapshot

type HistorySnapshot struct {
	ChainID    string
	HeightFrom int64
	HeightTo   int64
}

func GetHistorySnapshots

func GetHistorySnapshots(snapshotsDir string) (string, []HistorySnapshot, error)

func NewHistorySnapshot

func NewHistorySnapshot(chainID string, heightFrom int64, heightTo int64) HistorySnapshot

func (HistorySnapshot) CompressedFileName

func (h HistorySnapshot) CompressedFileName() string

func (HistorySnapshot) GetCopySQL

func (h HistorySnapshot) GetCopySQL(dbMetaData DatabaseMetadata, databaseSnapshotsPath string) []string

func (HistorySnapshot) String

func (h HistorySnapshot) String() string

func (HistorySnapshot) UncompressedDataDir

func (h HistorySnapshot) UncompressedDataDir() string

type IndexInfo

type IndexInfo struct {
	Tablename string
	Indexname string
	Indexdef  string
}

type Meta

type Meta struct {
	ChainID                  string
	HeightFrom               int64
	HeightTo                 int64
	CurrentStateSnapshotFile string
	HistorySnapshotFile      string
	DatabaseVersion          int64
}

func (Meta) String

func (m Meta) String() string

type Publisher

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

func NewPublisher

func NewPublisher(ctx context.Context, log *logging.Logger, config Config, snapshotsPath string) (*Publisher, error)

type Service

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

func NewSnapshotService

func NewSnapshotService(log *logging.Logger, config Config, brokerConfig broker.Config, blockStore *sqlstore.Blocks,
	networkParameterService func(ctx context.Context, key string) (entities.NetworkParameter, error), chainService *service.Chain, connConfig sqlstore.ConnectionConfig,
	snapshotsPath string,
) (*Service, error)

func (*Service) CreateSnapshotAsync

func (b *Service) CreateSnapshotAsync(ctx context.Context, chainID string, fromHeight int64, toHeight int64) (Meta, error)

func (*Service) LoadAllAvailableHistory

func (b *Service) LoadAllAvailableHistory(ctx context.Context) (int64, int64, error)

func (*Service) OnBlockCommitted

func (b *Service) OnBlockCommitted(ctx context.Context, chainID string, blockHeight int64) bool

func (*Service) Types

func (b *Service) Types() []events.Type

type TableMetadata

type TableMetadata struct {
	Name       string
	SortOrder  string
	Hypertable bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳