Documentation
¶
Overview ¶
Package history implements the runtime block history and pruning policy.
Index ¶
Constants ¶
View Source
const ( // PrunerStrategyNone is the name of the none pruner strategy. PrunerStrategyNone = "none" // PrunerStrategyKeepLast is the name of the keep last pruner strategy. PrunerStrategyKeepLast = "keep_last" )
View Source
const DbFilename = "history.db"
DbFilename is the filename of the history database.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Pruner configures the pruner to use.
Pruner PrunerFactory
// PruneInterval configures the pruning interval.
PruneInterval time.Duration
}
Config is runtime history keeper configuration.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns the default runtime history keeper config.
type History ¶
type History interface {
roothash.BlockHistory
// Pruner returns the history pruner.
Pruner() Pruner
// Close closes the history keeper.
Close()
}
History is the runtime history interface.
type PruneHandler ¶
type PruneHandler interface {
// Prune is called before the specified rounds are pruned.
//
// If an error is returned, pruning is aborted and the rounds are
// not pruned from history.
//
// Note that this can be called for the same round multiple
// times (e.g., if one of the handlers fails but others succeed
// and pruning is later retried).
Prune(ctx context.Context, rounds []uint64) error
}
PruneHandler is a handler that is called when rounds are pruned from history.
type Pruner ¶
type Pruner interface {
// Prune purges unneeded history, given the latest round.
Prune(ctx context.Context, latestRound uint64) error
// RegisterHandler registers a prune handler.
RegisterHandler(handler PruneHandler)
}
Pruner is the runtime history pruner interface.
type PrunerFactory ¶
PrunerFactory is the runtime history pruner factory interface.
func NewKeepLastPruner ¶
func NewKeepLastPruner(numKept uint64) PrunerFactory
NewKeepLastPruner creates a pruner that keeps the last configured number of rounds.
func NewNonePruner ¶
func NewNonePruner() PrunerFactory
NewNonePruner creates a new pruner that never prunes anything.
Click to show internal directories.
Click to hide internal directories.