{"modulePath":"github.com/onflow/flow-go","version":"v0.51.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pruner\n\n## Constants\n\n```go\nconst (\n\tDefaultHeightRangeTarget = uint64(2_000_000)\n\tDefaultThreshold         = uint64(100_000)\n\tDefaultPruningInterval   = 10 * time.Minute\n)\n```\n\n## Variables\n\n```go\nvar ErrNoRegisteredHeightRecorders = errors.New(\"no registered height recorders\")\n```\nErrNoRegisteredHeightRecorders represents an error indicating that pruner did not register any execution data height recorders. This error occurs when the pruner attempts to perform operations that require at least one registered height recorder, but none are found.\n\n## Types\n\n```go\ntype Pruner struct {\n\tcomponent.Component\n\t// contains filtered or unexported fields\n}\n```\nPruner is a component responsible for pruning data from execution data storage. It is configured with the following parameters:\n\n  - Height range target: The target number of most recent blocks to store data for. This controls the total amount of data stored on disk.\n  - Threshold: The number of block heights that we can exceed the height range target by before pruning is triggered. This controls the frequency of pruning.\n\nThe Pruner consumes a stream of tracked height notifications, and triggers pruning once the difference between the tracked height and the last pruned height reaches the height range target + threshold. A height is considered fulfilled once it has both been executed, tracked, and sealed.\n\n```go\nfunc NewPruner(logger zerolog.Logger, metrics module.ExecutionDataPrunerMetrics, storage tracker.Storage, opts ...PrunerOption) (*Pruner, error)\n```\nNewPruner creates a new Pruner.\n\n```go\nfunc (p *Pruner) RegisterHeightRecorder(recorder execution_data.ProcessedHeightRecorder)\n```\nRegisterHeightRecorder registers an execution data height recorder with the Pruner.\n\nParameters:\n\n  - recorder: The execution data height recorder to register.\n\n```go\nfunc (p *Pruner) SetHeightRangeTarget(heightRangeTarget uint64)\n```\nSetHeightRangeTarget updates the Pruner's height range target.\n\n```go\nfunc (p *Pruner) SetThreshold(threshold uint64)\n```\nSetThreshold update's the Pruner's threshold.\n\n```go\ntype PrunerOption func(*Pruner)\n```\n\n```go\nfunc WithHeightRangeTarget(heightRangeTarget uint64) PrunerOption\n```\nWithHeightRangeTarget is used to configure the pruner with a custom height range target.\n\n```go\nfunc WithPruneCallback(callback func(context.Context) error) PrunerOption\n```\nWithPruneCallback sets a custom callback function to be called after pruning.\n\n```go\nfunc WithPruningInterval(interval time.Duration) PrunerOption\n```\nWithPruningInterval is used to configure the pruner with a custom pruning interval.\n\n```go\nfunc WithThreshold(threshold uint64) PrunerOption\n```\nWithThreshold is used to configure the pruner with a custom threshold.\n\n","path":"github.com/onflow/flow-go/module/executiondatasync/pruner","name":"pruner","synopsis":"","isRedistributable":true}
