import type { MaybePromise } from '../../../shared/src/types.ts'; import { type Hash } from '../hash.ts'; export type HeadChange = { new: Hash | undefined; old: Hash | undefined; }; export interface RefCountUpdatesDelegate { getRefCount: (hash: Hash) => MaybePromise; getRefs: (hash: Hash) => MaybePromise; /** * Should be implemented if the store lazily loads refs, returning whether * or not the chunks refs have already been counted (i.e. are reflected * in `getRefCount`). * * If defined then: * - `getRefs` should return undefined for refs that have not been loaded, * but should never return undefined for hashes in `putChunks`. * - it is assumed that chunks in `putChunks` may have been reachable before * the write, but may not have been counted. This method is used to * determine if they have been counted or not. If they have not been * counted, and are reachable with the write applied, the returned * ref count updates will include updates for counting them. * * If undefined then: * - `getRefs` should never return undefined * - it is assumed that the refs of any chunks which were reachable before * the write are already counted */ areRefsCounted?: (hash: Hash) => boolean; } /** * Computes how ref counts should be updated when a dag write is committed. * Does not modify the dag store. * @param headChanges Heads that were changed by the dag write. * @param putChunks Chunks that were put by the dag write. * @param delegate Delegate used for getting ref information from the dag store. * @returns Map from chunk Hash to changed ref counts. Chunks with a new ref * count of 0 should be deleted. All hashes in `putChunks` will have an entry * (which will be zero if the newly put chunk is not reachable from any head). */ export declare function computeRefCountUpdates(headChanges: Iterable, putChunks: ReadonlySet, delegate: RefCountUpdatesDelegate): Promise>; //# sourceMappingURL=gc.d.ts.map