UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

61 lines 2.69 kB
import { routes } from "@lodestar/api"; import { CachedBeaconStateAllForks } from "@lodestar/state-transition"; import { Epoch, RootHex, phase0 } from "@lodestar/types"; import { Metrics } from "../../metrics/index.js"; import { StateRegenerationOpts } from "../regen/interface.js"; import { CheckpointStateCache } from "./types.js"; export type CheckpointHex = { epoch: Epoch; rootHex: RootHex; }; /** * In memory cache of CachedBeaconState * belonging to checkpoint * * Similar API to Repository */ export declare class InMemoryCheckpointStateCache implements CheckpointStateCache { private readonly cache; /** Epoch -> Set<blockRoot> */ private readonly epochIndex; /** * Max number of epochs allowed in the cache */ private readonly maxEpochs; private readonly metrics; private preComputedCheckpoint; private preComputedCheckpointHits; constructor({ metrics }: { metrics?: Metrics | null; }, { maxEpochs }?: { maxEpochs?: number; }); getOrReload(cp: CheckpointHex, opts?: StateRegenerationOpts): Promise<CachedBeaconStateAllForks | null>; getStateOrBytes(cp: CheckpointHex): Promise<Uint8Array | CachedBeaconStateAllForks | null>; getOrReloadLatest(rootHex: string, maxEpoch: number, opts?: StateRegenerationOpts): Promise<CachedBeaconStateAllForks | null>; processState(): Promise<number>; get(cp: CheckpointHex, opts?: StateRegenerationOpts): CachedBeaconStateAllForks | null; add(cp: phase0.Checkpoint, item: CachedBeaconStateAllForks): void; /** * Searches for the latest cached state with a `root`, starting with `epoch` and descending */ getLatest(rootHex: RootHex, maxEpoch: Epoch, opts?: StateRegenerationOpts): CachedBeaconStateAllForks | null; /** * Update the precomputed checkpoint and return the number of his for the * previous one (if any). */ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null; pruneFinalized(finalizedEpoch: Epoch): void; prune(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void; delete(cp: phase0.Checkpoint): void; deleteAllEpochItems(epoch: Epoch): void; clear(): void; /** ONLY FOR DEBUGGING PURPOSES. For lodestar debug API */ dumpSummary(): routes.lodestar.StateCacheItem[]; getStates(): IterableIterator<CachedBeaconStateAllForks>; /** ONLY FOR DEBUGGING PURPOSES. For spec tests on error */ dumpCheckpointKeys(): string[]; } export declare function toCheckpointHex(checkpoint: phase0.Checkpoint): CheckpointHex; export declare function toCheckpointKey(cp: CheckpointHex): string; //# sourceMappingURL=inMemoryCheckpointsCache.d.ts.map