statecache

package
v1.22.5 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package statecache provides an optional file-system-backed cache for beacon states. States are stored as compressed SSZ files keyed by (dependentRoot, targetEpoch). The cache limits the number of stored states and re-initializes from the filesystem on restart (no in-memory index — just scans the directory).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StateCache

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

StateCache manages cached beacon states on the local filesystem. It is safe for concurrent use.

func New

func New(cfg *types.Config, dynSsz *dynssz.DynSsz) *StateCache

New creates a new StateCache. Returns nil if the config disables caching. The directory is created if it doesn't exist.

func (*StateCache) Check

func (sc *StateCache) Check(dependentRoot phase0.Root, targetEpoch phase0.Epoch) bool

Check returns true if a cached state exists for the given key.

func (*StateCache) Close

func (sc *StateCache) Close()

Close removes the cache directory if it was auto-created as a temp dir.

func (*StateCache) Load

func (sc *StateCache) Load(dependentRoot phase0.Root, targetEpoch phase0.Epoch) *spec.VersionedBeaconState

Load reads a cached state from disk. Returns nil if not found.

func (*StateCache) Store

func (sc *StateCache) Store(dependentRoot phase0.Root, targetEpoch phase0.Epoch, state *spec.VersionedBeaconState) error

Store writes a state to disk and enforces the max states limit.

Jump to

Keyboard shortcuts

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