pruner

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisallowRevertToArchival is returned when a node has been run with pruner enabled before and
	// launching it with archival mode.
	ErrDisallowRevertToArchival = errors.New(
		"node has been run with pruner enabled before, it is not safe to convert to an archival" +
			"Run with --experimental-pruning enabled or consider re-initializing the store")
)

Functions

func DetectPreviousRun added in v0.14.0

func DetectPreviousRun(ctx context.Context, ds datastore.Datastore) error

DetectPreviousRun checks if the pruner has run before by checking for the existence of a checkpoint.

func IsWithinAvailabilityWindow added in v0.14.0

func IsWithinAvailabilityWindow(t time.Time, window AvailabilityWindow) bool

IsWithinAvailabilityWindow checks whether the given timestamp is within the given AvailabilityWindow. If the window is disabled (0), it returns true for every timestamp.

func WithPrunerMetrics added in v0.14.0

func WithPrunerMetrics(s *Service) error

WithPrunerMetrics is a utility function to turn on pruner metrics and that is expected to be "invoked" by the fx lifecycle.

Types

type AvailabilityWindow

type AvailabilityWindow time.Duration

func (AvailabilityWindow) Duration added in v0.14.0

func (aw AvailabilityWindow) Duration() time.Duration

type Option added in v0.14.0

type Option func(*Params)

func WithPruneCycle added in v0.14.0

func WithPruneCycle(cycle time.Duration) Option

WithPruneCycle configures how often the pruning Service triggers a pruning cycle.

type Params added in v0.14.0

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

func DefaultParams added in v0.14.0

func DefaultParams() Params

func (*Params) Validate added in v0.14.0

func (p *Params) Validate() error

type Pruner

type Pruner interface {
	Prune(context.Context, *header.ExtendedHeader) error
}

Pruner contains methods necessary to prune data from the node's datastore.

type Service

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

Service handles running the pruning cycle for the node.

func NewService

func NewService(
	p Pruner,
	window AvailabilityWindow,
	getter libhead.Getter[*header.ExtendedHeader],
	ds datastore.Datastore,
	blockTime time.Duration,
	opts ...Option,
) (*Service, error)

func (*Service) Start

func (s *Service) Start(context.Context) error

Start loads the pruner's last pruned height (1 if pruner is freshly initialized) and runs the prune loop, pruning any blocks older than the given availability window.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

func (*Service) WithMetrics added in v0.14.0

func (s *Service) WithMetrics() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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