pruner

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileExist

func CheckFileExist(path string) (bool, error)

func NewStateBloomFromDisk

func NewStateBloomFromDisk(filename string) (*stateBloom, error)

NewStateBloomFromDisk loads the state bloom from the given file. In this case the assumption is held the bloom filter is complete.

func RecoverPruning

func RecoverPruning(datadir string, db ethdb.Database, triesInMemory uint64) error

RecoverPruning will resume the pruning procedure during the system restart. This function is used in this case: user tries to prune state data, but the system was interrupted midway because of crash or manual-kill. In this case if the bloom filter for filtering active state is already constructed, the pruning can be resumed. What's more if the bloom filter is constructed, the pruning **has to be resumed**. Otherwise a lot of dangling nodes may be left in the disk.

Types

type BlockPruner

type BlockPruner struct {
	BlockAmountReserved uint64
	// contains filtered or unexported fields
}

func NewBlockPruner

func NewBlockPruner(db ethdb.Database, n *node.Node, oldAncientPath, newAncientPath string, BlockAmountReserved uint64) *BlockPruner

func (*BlockPruner) AncientDbReplacer

func (p *BlockPruner) AncientDbReplacer() error

func (*BlockPruner) BlockPruneBackUp

func (p *BlockPruner) BlockPruneBackUp(name string, cache, handles int, namespace string, readonly, interrupt bool) error

Backup the ancient data for the old ancient db, i.e. the most recent 128 blocks in ancient db.

func (*BlockPruner) RecoverInterruption

func (p *BlockPruner) RecoverInterruption(name string, cache, handles int, namespace string, readonly bool) error

type Config

type Config struct {
	Datadir   string // The directory of the state database
	BloomSize uint64 // The Megabytes of memory allocated to bloom-filter
}

Config includes all the configurations for pruning.

type Pruner

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

Pruner is an offline tool to prune the stale state with the help of the snapshot. The workflow of pruner is very simple:

  • iterate the snapshot, reconstruct the relevant state
  • iterate the database, delete all other state entries which don't belong to the target state and the genesis state

It can take several hours(around 2 hours for mainnet) to finish the whole pruning work. It's recommended to run this offline tool periodically in order to release the disk usage and improve the disk read performance to some extent.

func NewAllPruner

func NewAllPruner(db ethdb.Database) (*Pruner, error)

func NewPruner

func NewPruner(db ethdb.Database, config Config, triesInMemory uint64) (*Pruner, error)

NewPruner creates the pruner instance.

func (*Pruner) Prune

func (p *Pruner) Prune(root common.Hash) error

Prune deletes all historical state nodes except the nodes belong to the specified state version. If user doesn't specify the state version, use the bottom-most snapshot diff layer as the target.

func (*Pruner) PruneAll

func (p *Pruner) PruneAll(genesis *core.Genesis) error

Jump to

Keyboard shortcuts

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