pruning

package
v2.0.0-...-4666e1d Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

Pruning Manager

The pruning package defines the PruningManager struct which is responsible for pruning the state storage (SS) and the state commitment (SC) based on the current height of the chain. The PruningOption struct defines the configuration for pruning and is passed to the PruningManager during initialization.

Prune Options

The PruningOption struct includes the following fields:

  • KeepRecent (uint64): The number of recent heights to keep in the state.
  • Interval (uint64): The interval of how often to prune the state. 0 means no pruning.

Pausable Pruner

The PausablePruner interface defines the PausePruning method, which is used to pause the pruning process. The PruningManager will check if the pruner is a PausablePruner and call the PausePruning method before and after Commit to pause and resume pruning. This is useful for when the pruning process is asynchronous and needs to be paused during a commit to prevent parallel writes.

Pruning Flow

sequenceDiagram
    autonumber

    participant A as RootStore
    participant B as PruningManager
    participant C as CommitmentStore
    participant D as StorageStore

    loop Commit
        A->>B: SignalCommit(true, height)
        alt SC is PausablePruner
            B->>C: PausePruning(true)
        else SS is PausablePruner
            B->>D: PausePruing(true)
        end
        A->>C: Commit Changeset
        A->>D: Write Changeset
        A->>B: SignalCommit(false, height)
        alt SC is PausablePruner
            B->>C: PausePruning(false)
        else SS is PausablePruner
            B->>D: PausePruing(false)
        end
        B->>C: Prune(height)
        B->>D: Prune(height)
    end

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager is a struct that manages the pruning of old versions of the SC and SS.

func NewManager

func NewManager(scPruner, ssPruner store.Pruner, scPruningOption, ssPruningOption *store.PruningOption) *Manager

NewManager creates a new Pruning Manager.

func (*Manager) Prune

func (m *Manager) Prune(version uint64) error

Prune prunes the SC and SS to the provided version.

NOTE: It can be called outside of the store manually.

func (*Manager) SignalCommit

func (m *Manager) SignalCommit(start bool, version uint64) error

SignalCommit signals to the manager that a commit has started or finished. It is used to trigger the pruning of the SC and SS. It pauses or resumes the pruning of the SC and SS if the pruner implements the PausablePruner interface.

Jump to

Keyboard shortcuts

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