UNPKG

@x5e/gink

Version:

an eventually consistent database

85 lines (84 loc) 4.11 kB
import { AsOf, BundleInfo, Bytes, ChainStart, ClaimedChain, Entry, ScalarKey, Medallion, Muid, MuidTuple, Timestamp, BroadcastFunc, Movement, BundleView, KeyPair, Value, Placement } from "./typedefs"; import { HasMap } from "./HasMap"; import { Store } from "./Store"; import { TreeMap } from "jstreemap"; export declare class MemoryStore implements Store { private keepingHistory; ready: Promise<void>; private static readonly YEAR_2020; private foundBundleCallBacks; private trxns; private chainInfos; private activeChains; private clearances; private containers; private removals; private placements; private byKeyPlacement; private identities; private locations; private byName; private bySource; private byTarget; private verifyKeys; private secretKeys; private symmetricKeys; private accumulatorTotals; constructor(keepingHistory?: boolean); getBillionths(muid: Muid, asOf?: AsOf): Promise<bigint>; saveKeyPair(keyPair: KeyPair): Promise<void>; pullKeyPair(publicKey: Bytes): Promise<KeyPair>; acquireChain(identity: string): Promise<BundleInfo | null>; dumpEntries(): void; saveSymmetricKey(symmetricKey: Bytes): Promise<number>; getSymmetricKey(keyId: number): Promise<Bytes>; dropHistory(container?: Muid, before?: AsOf): void; getVerifyKey(chainInfo: [Medallion, ChainStart]): Promise<Bytes>; stopHistory(): void; startHistory(): void; getClaimedChains(): Promise<Map<Medallion, ClaimedChain>>; private claimChain; getChainIdentity(chainInfo: [Medallion, ChainStart]): Promise<string>; getChainTracker(): Promise<HasMap>; private getChainInfos; addBundle(bundle: BundleView, claimChain?: boolean): Promise<boolean>; private static bundleInfoToKey; applyMovement(movement: Movement): void; getContainerBytes(address: Muid): Promise<Bytes | undefined>; private asOfToTimestamp; getEntryByKey(container?: Muid, key?: ScalarKey | Muid | [Muid, Muid], asOf?: AsOf): Promise<Entry | undefined>; getEntryByKeyHelper(container?: Muid, key?: ScalarKey | Muid | [Muid, Muid], asOf?: AsOf): Entry | undefined; getBundles(callBack: (bundle: BundleView) => void): Promise<void>; getEntryById(entryMuid: Muid, asOf?: AsOf): Promise<Entry | undefined>; getEntryByIdSync(entryMuid: Muid): Entry | undefined; getKeyedEntries(container: Muid, asOf?: AsOf): Promise<Map<string, Entry>>; getContainersByName(name: string, asOf?: AsOf): Promise<Muid[]>; getContainerProperties(containerMuid: Muid, asOf?: AsOf): Promise<Map<string, Value>>; /** * Returns entry data for a List. * @param container to get entries for * @param through number to get, negative for starting from end * @param asOf show results as of a time in the past * @returns a promise of a list of ChangePairs */ getOrderedEntries(container: Muid, through?: number, asOf?: AsOf): Promise<Map<string, Entry>>; getOrderedEntriesSync(container: Muid, through?: number, asOf?: AsOf): Map<string, Entry>; getLocation(entry: Muid, asOf?: AsOf): Promise<Placement | undefined>; addEntry(entry: Entry): void; /** * Returns the timestamp of the last clearance for any given container. * @param containerId container muid as a string * @param asOf optional timestamp to query - finds the last clearance within the timeframe. * @returns the timestamp of the last clearance, or 0 if one wasn't found. */ getLastClearanceTime(containerId: string, asOf?: Timestamp): number; getEntriesBySourceOrTarget(vertex: Muid, source: boolean, asOf?: AsOf): Promise<Entry[]>; getEntriesBySourceOrTargetSync(vertex: Muid, source: boolean, asOf?: AsOf): Entry[]; getAllContainerTuples(): Promise<MuidTuple[]>; isSoftDeleted(entry: Entry, asOfTs: Timestamp): boolean; close(): Promise<void>; getAllEntryKeys(): Array<string>; getAllEntries(): Array<Entry>; getAllRemovals(): TreeMap<string, string>; addFoundBundleCallBack(callback: BroadcastFunc): void; }