@ocap/statedb-memory 1.29.5 → 1.29.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/db.d.mts CHANGED
@@ -33,7 +33,10 @@ declare class MemoryStateDB extends StateDB {
33
33
  * @param fn - Function to execute (txn parameter will be null)
34
34
  * @returns Result of the function
35
35
  */
36
- runAsLambda<T>(fn: (txn: null) => T | Promise<T>): Promise<T>;
36
+ runAsLambda<T>(fn: (txn: null) => T | Promise<T>, options?: {
37
+ onCommit?: (commitHash?: string) => void | Promise<void>;
38
+ }): Promise<T>;
39
+ close(): Promise<void>;
37
40
  }
38
41
  //#endregion
39
42
  export { MemoryStateDB as default };
package/esm/db.mjs CHANGED
@@ -101,9 +101,14 @@ var MemoryStateDB = class extends StateDB {
101
101
  * @param fn - Function to execute (txn parameter will be null)
102
102
  * @returns Result of the function
103
103
  */
104
- async runAsLambda(fn) {
105
- return fn(null);
104
+ async runAsLambda(fn, options) {
105
+ const result = await fn(null);
106
+ if (options?.onCommit) try {
107
+ await options.onCommit();
108
+ } catch (_err) {}
109
+ return result;
106
110
  }
111
+ async close() {}
107
112
  };
108
113
  var db_default = MemoryStateDB;
109
114
 
package/esm/package.mjs CHANGED
@@ -54,7 +54,8 @@ var package_default = {
54
54
  "lint": "biome check",
55
55
  "lint:fix": "biome check --write",
56
56
  "test": "bun test",
57
- "coverage": "npm run test -- --coverage"
57
+ "coverage": "npm run test -- --coverage",
58
+ "clean": "rm -rf lib esm"
58
59
  },
59
60
  gitHead: "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
60
61
  dependencies: {
package/lib/db.cjs CHANGED
@@ -104,9 +104,14 @@ var MemoryStateDB = class extends _ocap_statedb.StateDB {
104
104
  * @param fn - Function to execute (txn parameter will be null)
105
105
  * @returns Result of the function
106
106
  */
107
- async runAsLambda(fn) {
108
- return fn(null);
107
+ async runAsLambda(fn, options) {
108
+ const result = await fn(null);
109
+ if (options?.onCommit) try {
110
+ await options.onCommit();
111
+ } catch (_err) {}
112
+ return result;
109
113
  }
114
+ async close() {}
110
115
  };
111
116
  var db_default = MemoryStateDB;
112
117
 
package/lib/db.d.cts CHANGED
@@ -33,7 +33,10 @@ declare class MemoryStateDB extends StateDB {
33
33
  * @param fn - Function to execute (txn parameter will be null)
34
34
  * @returns Result of the function
35
35
  */
36
- runAsLambda<T>(fn: (txn: null) => T | Promise<T>): Promise<T>;
36
+ runAsLambda<T>(fn: (txn: null) => T | Promise<T>, options?: {
37
+ onCommit?: (commitHash?: string) => void | Promise<void>;
38
+ }): Promise<T>;
39
+ close(): Promise<void>;
37
40
  }
38
41
  //#endregion
39
42
  export { MemoryStateDB as default };
package/lib/package.cjs CHANGED
@@ -55,7 +55,8 @@ var package_default = {
55
55
  "lint": "biome check",
56
56
  "lint:fix": "biome check --write",
57
57
  "test": "bun test",
58
- "coverage": "npm run test -- --coverage"
58
+ "coverage": "npm run test -- --coverage",
59
+ "clean": "rm -rf lib esm"
59
60
  },
60
61
  gitHead: "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
61
62
  dependencies: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/statedb-memory",
3
3
  "description": "OCAP statedb adapter that uses memory as backend statedb, just for test purpose",
4
- "version": "1.29.5",
4
+ "version": "1.29.6",
5
5
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ArcBlock/blockchain/issues",
@@ -14,7 +14,7 @@
14
14
  "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)"
15
15
  ],
16
16
  "devDependencies": {
17
- "@ocap/statedb-test": "1.29.5",
17
+ "@ocap/statedb-test": "1.29.6",
18
18
  "@types/lokijs": "^1.5.14"
19
19
  },
20
20
  "homepage": "https://github.com/ArcBlock/blockchain/tree/master/statedb/memory",
@@ -59,14 +59,15 @@
59
59
  "lint": "biome check",
60
60
  "lint:fix": "biome check --write",
61
61
  "test": "bun test",
62
- "coverage": "npm run test -- --coverage"
62
+ "coverage": "npm run test -- --coverage",
63
+ "clean": "rm -rf lib esm"
63
64
  },
64
65
  "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
65
66
  "dependencies": {
66
- "@ocap/state": "1.29.5",
67
- "@ocap/statedb": "1.29.5",
68
- "@ocap/types": "1.29.5",
69
- "@ocap/util": "1.29.5",
67
+ "@ocap/state": "1.29.6",
68
+ "@ocap/statedb": "1.29.6",
69
+ "@ocap/types": "1.29.6",
70
+ "@ocap/util": "1.29.6",
70
71
  "debug": "^4.4.3",
71
72
  "lodash": "^4.17.23",
72
73
  "lokijs": "^1.5.12"