UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

55 lines 2.17 kB
import { routes } from "@lodestar/api"; import { CachedBeaconStateAllForks } from "@lodestar/state-transition"; import { Epoch, RootHex } from "@lodestar/types"; import { Metrics } from "../../metrics/index.js"; import { StateRegenerationOpts } from "../regen/interface.js"; import { BlockStateCache } from "./types.js"; /** * Old implementation of StateCache (used to call `StateContextCache`) * - Prune per checkpoint so number of states ranges from 96 to 128 * - Keep a separate head state to make sure it is always available */ export declare class BlockStateCacheImpl implements BlockStateCache { /** * Max number of states allowed in the cache */ readonly maxStates: number; private readonly cache; /** Epoch -> Set<blockRoot> */ private readonly epochIndex; private readonly metrics; /** * Strong reference to prevent head state from being pruned. * null if head state is being regen and not available at the moment. */ private head; constructor({ maxStates, metrics }: { maxStates?: number; metrics?: Metrics | null; }); get(rootHex: RootHex, opts?: StateRegenerationOpts): CachedBeaconStateAllForks | null; add(item: CachedBeaconStateAllForks): void; setHeadState(item: CachedBeaconStateAllForks | null): void; /** * Get a seed state for state reload. * This is to conform to the api only as this cache is not used in n-historical state. * See ./fifoBlockStateCache.ts for implementation */ getSeedState(): CachedBeaconStateAllForks; clear(): void; get size(): number; /** * TODO make this more robust. * Without more thought, this currently breaks our assumptions about recent state availablity */ prune(headStateRootHex: RootHex): void; /** * Prune per finalized epoch. */ deleteAllBeforeEpoch(finalizedEpoch: Epoch): void; /** ONLY FOR DEBUGGING PURPOSES. For lodestar debug API */ dumpSummary(): routes.lodestar.StateCacheItem[]; getStates(): IterableIterator<CachedBeaconStateAllForks>; private deleteAllEpochItems; } //# sourceMappingURL=blockStateCacheImpl.d.ts.map