From 5e55fda5f8c770b81a319ca61b1d3962fa4dcf9d Mon Sep 17 00:00:00 2001 From: Tadeuchi Date: Thu, 20 Apr 2023 12:16:58 +0200 Subject: [PATCH] feat: promise for commit and rollback --- src/cache/SortKeyCache.ts | 4 ++-- src/core/modules/StateEvaluator.ts | 2 -- src/core/modules/impl/CacheableStateEvaluator.ts | 4 ---- src/core/modules/impl/DefaultStateEvaluator.ts | 2 -- src/legacy/smartweave-global.ts | 6 +++--- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/cache/SortKeyCache.ts b/src/cache/SortKeyCache.ts index 6949d0d..4b7207a 100644 --- a/src/cache/SortKeyCache.ts +++ b/src/cache/SortKeyCache.ts @@ -53,9 +53,9 @@ export interface SortKeyCache { begin(): Promise; - rollback(): void; + rollback(): Promise; - commit(): void; + commit(): Promise; /** * used mostly for debugging, allows to dump the current content cache diff --git a/src/core/modules/StateEvaluator.ts b/src/core/modules/StateEvaluator.ts index 6e15c5c..51061c9 100644 --- a/src/core/modules/StateEvaluator.ts +++ b/src/core/modules/StateEvaluator.ts @@ -87,8 +87,6 @@ export interface StateEvaluator { lastCachedSortKey(): Promise; - allCachedContracts(): Promise; - setCache(cache: SortKeyCache>): void; getCache(): SortKeyCache>; diff --git a/src/core/modules/impl/CacheableStateEvaluator.ts b/src/core/modules/impl/CacheableStateEvaluator.ts index 5acfa18..19b4a62 100644 --- a/src/core/modules/impl/CacheableStateEvaluator.ts +++ b/src/core/modules/impl/CacheableStateEvaluator.ts @@ -224,10 +224,6 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator { return await this.cache.getLastSortKey(); } - async allCachedContracts(): Promise { - return await this.cache.keys(); - } - setCache(cache: SortKeyCache>): void { this.cache = cache; } diff --git a/src/core/modules/impl/DefaultStateEvaluator.ts b/src/core/modules/impl/DefaultStateEvaluator.ts index 2aa295a..62a1610 100644 --- a/src/core/modules/impl/DefaultStateEvaluator.ts +++ b/src/core/modules/impl/DefaultStateEvaluator.ts @@ -417,8 +417,6 @@ export abstract class DefaultStateEvaluator implements StateEvaluator { abstract lastCachedSortKey(): Promise; - abstract allCachedContracts(): Promise; - abstract setCache(cache: SortKeyCache>): void; abstract getCache(): SortKeyCache>; diff --git a/src/legacy/smartweave-global.ts b/src/legacy/smartweave-global.ts index d35c099..6c9249e 100644 --- a/src/legacy/smartweave-global.ts +++ b/src/legacy/smartweave-global.ts @@ -322,16 +322,16 @@ export class KV { async commit(): Promise { if (this._storage) { if (this._transaction.dryRun) { - this._storage.rollback(); + await this._storage.rollback(); } else { - this._storage.commit(); + await this._storage.commit(); } } } async rollback(): Promise { if (this._storage) { - this._storage.rollback(); + await this._storage.rollback(); } }