feat: promise for commit and rollback

This commit is contained in:
Tadeuchi
2023-04-20 12:16:58 +02:00
committed by just_ppe
parent 6ad182f91d
commit 5e55fda5f8
5 changed files with 5 additions and 13 deletions

View File

@@ -53,9 +53,9 @@ export interface SortKeyCache<V> {
begin(): Promise<void>;
rollback(): void;
rollback(): Promise<void>;
commit(): void;
commit(): Promise<void>;
/**
* used mostly for debugging, allows to dump the current content cache

View File

@@ -87,8 +87,6 @@ export interface StateEvaluator {
lastCachedSortKey(): Promise<string | null>;
allCachedContracts(): Promise<string[]>;
setCache(cache: SortKeyCache<EvalStateResult<unknown>>): void;
getCache(): SortKeyCache<EvalStateResult<unknown>>;

View File

@@ -224,10 +224,6 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
return await this.cache.getLastSortKey();
}
async allCachedContracts(): Promise<string[]> {
return await this.cache.keys();
}
setCache(cache: SortKeyCache<EvalStateResult<unknown>>): void {
this.cache = cache;
}

View File

@@ -417,8 +417,6 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
abstract lastCachedSortKey(): Promise<string | null>;
abstract allCachedContracts(): Promise<string[]>;
abstract setCache(cache: SortKeyCache<EvalStateResult<unknown>>): void;
abstract getCache(): SortKeyCache<EvalStateResult<unknown>>;

View File

@@ -322,16 +322,16 @@ export class KV {
async commit(): Promise<void> {
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<void> {
if (this._storage) {
this._storage.rollback();
await this._storage.rollback();
}
}