import { StateServiceClient } from "../../services/state/state-service-client.js"; import { UpdateServiceClient } from "../../services/update/update-service-client.js"; import { QueryCacheStore } from "../cache/query-cache-store.js"; import { ContractRow } from "../model-types.js"; import { ContractCacheArgs, ContractCacheInspection, ContractCacheResult } from "../query-client.js"; type ActiveContractsReader = Pick & Partial>; type CacheUpdateReader = Pick; /** Budgets for patching a warm snapshot forward from the update stream instead of re-downloading the ACS. */ export interface GrpcContractCacheDeltaOptions { /** * BETA: delta refresh is opt-in. When absent or false, every re-warm performs the full ACS download * regardless of the other options here. */ readonly enabled?: boolean; /** Skip the delta attempt outright when the ledger has run further than this past the snapshot. */ readonly maxOffsetGap?: number; /** Abandon the delta (fall back to a full download) after this many applied updates. */ readonly maxUpdates?: number; } /** Per-contract creation facts the contractType join needs; stored so cached reads never re-fetch the ACS. */ export interface GrpcCachedCreationMetadata { readonly contractId: string; readonly packageName: string; readonly representativePackageId: string | null; } /** Internal point-in-time active-contract cache lookup used by query planning. */ export interface GrpcCachedContractSnapshot { readonly activeAtOffset: string; readonly contracts: readonly ContractRow[]; readonly creationMetadata: readonly GrpcCachedCreationMetadata[]; } export declare class GrpcContractCache { private readonly stateService; private readonly store; private readonly ttlMs; private readonly endpointScope; private readonly now; private readonly maxPageSize?; private readonly updateService?; private readonly delta; private readonly inflight; constructor(stateService: ActiveContractsReader, store: QueryCacheStore, ttlMs: number, endpointScope: string, now?: () => number, maxPageSize?: number | undefined, updateService?: CacheUpdateReader | undefined, delta?: GrpcContractCacheDeltaOptions); cacheContracts(args?: ContractCacheArgs): Promise; readContractsAsync(args?: ContractCacheArgs): Promise; readSnapshotAsync(args?: ContractCacheArgs): Promise; invalidateContractsCache(args?: ContractCacheArgs): Promise; /** Measures the cached snapshot against the current ledger end, without changing anything. */ inspectContractsCacheAsync(args?: ContractCacheArgs): Promise; private populateAsync; /** * Patches the base snapshot forward from the update stream instead of re-downloading the ACS. Returns * undefined — meaning "do the full download instead" — whenever correctness cannot be proven cheaply: * pruning past the base offset, an offset gap or update count beyond the configured budgets, any * reassignment or topology change in the window (multi-synchronizer moves cannot be patched safely), an * exercised event where ACS_DELTA promises none, or an archive/create inconsistent with the base rows. */ private tryDeltaRefreshAsync; private readDeltaWindowAsync; private writeSnapshotAsync; private fullRefreshAsync; private clearInflight; } export declare function normalizeParties(args?: ContractCacheArgs): readonly string[] | undefined; export {};