forked from warp-contracts/warp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
125 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { CacheKey, PruneStats, SortKeyCacheResult } from './SortKeyCache'; | ||
|
||
/** | ||
* A cache that stores its values per dedicated key and sort key. | ||
* A sort key is a value that the SmartWeave protocol is using | ||
* to sort contract transactions ({@link LexicographicalInteractionsSorter}. | ||
* | ||
* All values should be stored in a lexicographical order (per key) - | ||
* sorted by the sort key. | ||
*/ | ||
export interface BasicSortKeyCache<V> { | ||
getLessOrEqual(key: string, sortKey: string): Promise<SortKeyCacheResult<V> | null>; | ||
|
||
/** | ||
* returns value stored for a given key and last sortKey | ||
*/ | ||
getLast(key: string): Promise<SortKeyCacheResult<V> | null>; | ||
|
||
/** | ||
* returns last cached sort key - takes all keys into account | ||
*/ | ||
getLastSortKey(): Promise<string | null>; | ||
|
||
/** | ||
* returns value for the key and exact sortKey | ||
*/ | ||
get(cacheKey: CacheKey): Promise<SortKeyCacheResult<V> | null>; | ||
|
||
/** | ||
* puts new value in cache under given {@link CacheKey.key} and {@link CacheKey.sortKey}. | ||
*/ | ||
put(cacheKey: CacheKey, value: V): Promise<void>; | ||
|
||
/** | ||
* removes all data stored under a specified key | ||
*/ | ||
delete(key: string): Promise<void>; | ||
|
||
open(): Promise<void>; | ||
|
||
close(): Promise<void>; | ||
|
||
begin(): Promise<void>; | ||
|
||
rollback(): Promise<void>; | ||
|
||
commit(): Promise<void>; | ||
|
||
/** | ||
* used mostly for debugging, allows to dump the current content cache | ||
* It's slow. | ||
*/ | ||
dump(): Promise<any>; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
|
||
/** | ||
* returns underlying storage (LevelDB, LMDB, sqlite...) | ||
* - useful for performing low-level operations | ||
*/ | ||
storage<S>(): S; | ||
|
||
/** | ||
* leaves n-latest (i.e. with latest (in lexicographic order) sort keys) | ||
* entries for each cached key | ||
* | ||
* @param entriesStored - how many latest entries should be left | ||
* for each cached key | ||
* | ||
* @retun PruneStats if getting them doesn't introduce a delay, null otherwise | ||
*/ | ||
prune(entriesStored: number): Promise<PruneStats | null>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.