UNPKG

@x5e/gink

Version:

an eventually consistent database

64 lines (63 loc) 3.12 kB
import { Medallion, ChainStart, Bytes, AsOf, ScalarKey, BroadcastFunc, BundleView, KeyPair, Value, Placement, MuidTuple } from "./typedefs"; import { BundleInfo, Muid, Entry } from "./typedefs"; import { MemoryStore } from "./MemoryStore"; import { Store } from "./Store"; import { LockableLog } from "./LockableLog"; import { HasMap } from "./HasMap"; export declare class LogBackedStore extends LockableLog implements Store { readonly filename: string; readonly exclusive: boolean; private internalStore; private bundlesProcessed; private hasMap; private claimedChains; private identities; private memoryLock; private redTo; private fileWatcher; private foundBundleCallBacks; private opened; private closed; private logBackedStoreReady; /** * * @param filename file to store transactions and chain ownership information * @param exclusive if true, lock the file until closing store, otherwise only lock as-needed. */ constructor(filename: string, exclusive?: boolean, internalStore?: MemoryStore); get ready(): Promise<void>; getBillionths(muid: Muid, asOf?: AsOf): Promise<bigint>; getVerifyKey(chainInfo: [Medallion, ChainStart]): Promise<Bytes>; saveKeyPair(keyPair: KeyPair): Promise<void>; pullKeyPair(publicKey: Bytes): Promise<KeyPair>; saveSymmetricKey(symmetricKey: Bytes): Promise<number>; getSymmetricKey(keyId: number): Promise<Bytes>; private initializeLogBackedStore; close(): Promise<void>; private pullDataFromFile; getContainerProperties(containerMuid: Muid, asOf?: AsOf): Promise<Map<string, Value>>; getOrderedEntries(container: Muid, through?: number, asOf?: AsOf): Promise<Map<string, Entry>>; getEntriesBySourceOrTarget(vertex: Muid, source: boolean, asOf?: AsOf): Promise<Entry[]>; getBundlesProcessed(): Promise<number>; getLocation(entry: Muid, asOf?: AsOf): Promise<Placement>; addBundle(bundle: BundleView, claimChain?: boolean): Promise<Boolean>; acquireChain(identity: string): Promise<BundleInfo | null>; private claimChain; getChainIdentity(chainInfo: [Medallion, ChainStart]): Promise<string>; getChainTracker(): Promise<HasMap>; getBundles(callBack: (bundle: BundleView) => void): Promise<void>; getContainerBytes(address: Muid): Promise<Bytes | undefined>; getEntryByKey(container?: Muid, key?: ScalarKey, asOf?: AsOf): Promise<Entry | undefined>; getKeyedEntries(container: Muid, asOf?: AsOf): Promise<Map<string, Entry>>; getEntryById(entryMuid: Muid, asOf?: AsOf): Promise<Entry | undefined>; getAllEntries(): Promise<Entry[]>; getContainersByName(name: string, asOf?: AsOf): Promise<Muid[]>; getAllContainerTuples(): Promise<MuidTuple[]>; /** * Add a callback if you want another function to run when a new * bundle is pulled from the log file. * @param callback a function to be called when a new bundle has been * received from the log file. It needs to take one argument, bundleInfo */ addFoundBundleCallBack(callback: BroadcastFunc): void; }