@ocap/statedb-memory
Version:
OCAP statedb adapter that uses memory as backend statedb, just for test purpose
42 lines (40 loc) • 1.46 kB
text/typescript
import { StateDB } from "@ocap/statedb";
import { IAccountState, IAssetFactoryState, IAssetState, IBalanceTable, IChainState, IDelegateState, IEvidenceState, IRollupBlock, IRollupTable, IStakeState, IStateTable, ITokenFactoryState, ITokenTable, ITxState } from "@ocap/types";
import Lokijs from "lokijs";
//#region src/db.d.ts
/**
* 内存 StateDB 实现
* 使用 LokiJS 作为内存存储引擎
*/
declare class MemoryStateDB extends StateDB {
name: string;
version: string;
db: Lokijs;
balance: IBalanceTable;
account: IStateTable<IAccountState>;
factory: IStateTable<IAssetFactoryState>;
stake: IStateTable<IStakeState>;
asset: IStateTable<IAssetState>;
delegation: IStateTable<IDelegateState>;
tx: IStateTable<ITxState>;
token: ITokenTable;
chain: IStateTable<IChainState>;
rollup: IRollupTable;
rollupBlock: IStateTable<IRollupBlock>;
evidence: IStateTable<IEvidenceState>;
tokenFactory: IStateTable<ITokenFactoryState>;
constructor();
/**
* Execute function - Memory adapter has no real transaction support
* This is a no-op wrapper that simply executes the callback
*
* @param fn - Function to execute (txn parameter will be null)
* @returns Result of the function
*/
runAsLambda<T>(fn: (txn: null) => T | Promise<T>, options?: {
onCommit?: (commitHash?: string) => void | Promise<void>;
}): Promise<T>;
close(): Promise<void>;
}
//#endregion
export { MemoryStateDB as default };