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 ¶
- type StateCache
- func (sc *StateCache) Check(dependentRoot phase0.Root, targetEpoch phase0.Epoch) bool
- func (sc *StateCache) Close()
- func (sc *StateCache) Load(dependentRoot phase0.Root, targetEpoch phase0.Epoch) *spec.VersionedBeaconState
- func (sc *StateCache) Store(dependentRoot phase0.Root, targetEpoch phase0.Epoch, ...) error
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) 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.