2024-02-29 21:10:24 +00:00
|
|
|
# nimbus-eth1
|
|
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
|
|
|
## Stackable API for `Aristo`
|
|
|
|
## ==========================
|
|
|
|
|
|
|
|
|
|
|
|
import
|
2024-06-03 20:10:35 +00:00
|
|
|
std/times,
|
2024-06-22 20:33:37 +00:00
|
|
|
eth/common,
|
2024-02-29 21:10:24 +00:00
|
|
|
results,
|
2024-03-14 22:17:43 +00:00
|
|
|
./aristo_desc/desc_backend,
|
|
|
|
./aristo_init/memory_db,
|
2024-06-28 15:03:12 +00:00
|
|
|
"."/[aristo_delete, aristo_desc, aristo_fetch,
|
2024-06-27 19:21:01 +00:00
|
|
|
aristo_init, aristo_merge, aristo_path, aristo_profile, aristo_tx]
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
export
|
|
|
|
AristoDbProfListRef
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
const
|
|
|
|
AutoValidateApiHooks = defined(release).not
|
|
|
|
## No validatinon needed for production suite.
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
AristoPersistentBackendOk = AutoValidateApiHooks # and false
|
2024-03-14 22:17:43 +00:00
|
|
|
## Set true for persistent backend profiling (which needs an extra
|
|
|
|
## link library.)
|
|
|
|
|
|
|
|
when AristoPersistentBackendOk:
|
|
|
|
import ./aristo_init/rocks_db
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
# Annotation helper(s)
|
|
|
|
{.pragma: noRaise, gcsafe, raises: [].}
|
|
|
|
|
|
|
|
type
|
|
|
|
AristoApiCommitFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Given a *top level* handle, this function accepts all database
|
|
|
|
## operations performed through this handle and merges it to the
|
|
|
|
## previous layer. The previous transaction is returned if there
|
|
|
|
## was any.
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiDeleteAccountRecordFn* =
|
2024-06-18 19:30:01 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Delete the account leaf entry addressed by the argument `path`. If
|
|
|
|
## this leaf entry referres to a storage tree, this one will be deleted
|
|
|
|
## as well.
|
|
|
|
|
|
|
|
AristoApiDeleteGenericDataFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
root: VertexID;
|
|
|
|
path: openArray[byte];
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[bool,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-18 19:30:01 +00:00
|
|
|
## Delete the leaf data entry addressed by the argument `path`. The MPT
|
|
|
|
## sub-tree the leaf data entry is subsumed under is passed as argument
|
|
|
|
## `root` which must be greater than `VertexID(1)` and smaller than
|
|
|
|
## `LEAST_FREE_VID`.
|
2024-02-29 21:10:24 +00:00
|
|
|
##
|
2024-06-18 19:30:01 +00:00
|
|
|
## The return value is `true` if the argument `path` deleted was the last
|
|
|
|
## one and the tree does not exist anymore.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiDeleteGenericTreeFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
root: VertexID;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Variant of `deleteGenericData()` for purging the whole MPT sub-tree.
|
|
|
|
|
|
|
|
AristoApiDeleteStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 19:21:01 +00:00
|
|
|
stoPath: openArray[byte];
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[bool,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-18 19:30:01 +00:00
|
|
|
## For a given account argument `accPath`, this function deletes the
|
2024-06-27 19:21:01 +00:00
|
|
|
## argument `stoPath` from the associated storage tree (if any, at all.)
|
|
|
|
## If the if the argument `stoPath` deleted was the last one on the
|
|
|
|
## storage tree, account leaf referred to by `accPath` will be updated
|
|
|
|
## so that it will not refer to a storage tree anymore. In the latter
|
|
|
|
## case only the function will return `true`.
|
2024-06-18 19:30:01 +00:00
|
|
|
|
|
|
|
AristoApiDeleteStorageTreeFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Variant of `deleteStorageData()` for purging the whole storage tree
|
|
|
|
## associated to the account argument `accPath`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
AristoApiFetchLastSavedStateFn* =
|
|
|
|
proc(db: AristoDbRef
|
|
|
|
): Result[SavedState,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## The function returns the state of the last saved state. This is a
|
|
|
|
## Merkle hash tag for vertex with ID 1 and a bespoke `uint64` identifier
|
|
|
|
## (may be interpreted as block number.)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiFetchAccountRecordFn* =
|
2024-06-19 12:40:00 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[AristoAccount,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 19:21:01 +00:00
|
|
|
## Fetch an account record from the database indexed by `accPath`.
|
2024-06-19 12:40:00 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiFetchAccountStateFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-28 15:03:12 +00:00
|
|
|
updateOk: bool;
|
2024-06-27 09:01:26 +00:00
|
|
|
): Result[Hash256,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-28 15:03:12 +00:00
|
|
|
## Fetch the Merkle hash of the account root. Force update if the
|
|
|
|
## argument `updateOK` is set `true`.
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiFetchGenericDataFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
root: VertexID;
|
|
|
|
path: openArray[byte];
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[Blob,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## For a generic sub-tree starting at `root`, fetch the data record
|
|
|
|
## indexed by `path`.
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiFetchGenericStateFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
root: VertexID;
|
2024-06-28 15:03:12 +00:00
|
|
|
updateOk: bool;
|
2024-06-27 09:01:26 +00:00
|
|
|
): Result[Hash256,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-28 15:03:12 +00:00
|
|
|
## Fetch the Merkle hash of the argument `root`. Force update if the
|
|
|
|
## argument `updateOK` is set `true`.
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiFetchStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 19:21:01 +00:00
|
|
|
stoPath: openArray[byte];
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[Blob,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-19 12:40:00 +00:00
|
|
|
## For a storage tree related to account `accPath`, fetch the data
|
2024-06-27 19:21:01 +00:00
|
|
|
## record from the database indexed by `stoPath`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiFetchStorageStateFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-28 15:03:12 +00:00
|
|
|
updateOk: bool;
|
2024-06-27 09:01:26 +00:00
|
|
|
): Result[Hash256,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-28 15:03:12 +00:00
|
|
|
## Fetch the Merkle hash of the storage root related to `accPath`. Force
|
|
|
|
## update if the argument `updateOK` is set `true`.
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
AristoApiFindTxFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
vid: VertexID;
|
|
|
|
key: HashKey;
|
|
|
|
): Result[int,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Find the transaction where the vertex with ID `vid` exists and has
|
|
|
|
## the Merkle hash key `key`. If there is no transaction available,
|
|
|
|
## search in the filter and then in the backend.
|
|
|
|
##
|
|
|
|
## If the above procedure succeeds, an integer indicating the transaction
|
|
|
|
## level is returned:
|
|
|
|
##
|
|
|
|
## * `0` -- top level, current layer
|
|
|
|
## * `1`,`2`,`..` -- some transaction level further down the stack
|
|
|
|
## * `-1` -- the filter between transaction stack and database backend
|
|
|
|
## * `-2` -- the databse backend
|
|
|
|
##
|
|
|
|
## A successful return code might be used for the `forkTx()` call for
|
|
|
|
## creating a forked descriptor that provides the pair `(vid,key)`.
|
|
|
|
##
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiFinishFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-14 11:19:48 +00:00
|
|
|
eradicate = false;
|
2024-02-29 21:10:24 +00:00
|
|
|
) {.noRaise.}
|
2024-06-14 11:19:48 +00:00
|
|
|
## Backend destructor. The argument `eradicate` indicates that a full
|
2024-02-29 21:10:24 +00:00
|
|
|
## database deletion is requested. If set `false` the outcome might
|
|
|
|
## differ depending on the type of backend (e.g. the `BackendMemory`
|
2024-06-14 11:19:48 +00:00
|
|
|
## backend will always eradicate on close.)
|
2024-02-29 21:10:24 +00:00
|
|
|
##
|
|
|
|
## In case of distributed descriptors accessing the same backend, all
|
|
|
|
## distributed descriptors will be destroyed.
|
|
|
|
##
|
|
|
|
## This distructor may be used on already *destructed* descriptors.
|
|
|
|
|
|
|
|
AristoApiForgetFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Destruct the non centre argument `db` descriptor (see comments on
|
|
|
|
## `reCentre()` for details.)
|
|
|
|
##
|
|
|
|
## A non centre descriptor should always be destructed after use (see
|
|
|
|
## also# comments on `fork()`.)
|
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
AristoApiForkTxFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-05-03 17:38:17 +00:00
|
|
|
backLevel: int;
|
2024-02-29 21:10:24 +00:00
|
|
|
): Result[AristoDbRef,AristoError]
|
|
|
|
{.noRaise.}
|
2024-05-03 17:38:17 +00:00
|
|
|
## Fork a new descriptor obtained from parts of the argument database
|
|
|
|
## as described by arguments `db` and `backLevel`.
|
|
|
|
##
|
|
|
|
## If the argument `backLevel` is non-negative, the forked descriptor
|
|
|
|
## will provide the database view where the first `backLevel` transaction
|
|
|
|
## layers are stripped and the remaing layers are squashed into a single
|
|
|
|
## transaction.
|
|
|
|
##
|
|
|
|
## If `backLevel` is `-1`, a database descriptor with empty transaction
|
2024-06-03 20:10:35 +00:00
|
|
|
## layers will be provided where the `balancer` between database and
|
2024-05-03 17:38:17 +00:00
|
|
|
## transaction layers are kept in place.
|
|
|
|
##
|
|
|
|
## If `backLevel` is `-2`, a database descriptor with empty transaction
|
2024-06-03 20:10:35 +00:00
|
|
|
## layers will be provided without a `balancer`.
|
2024-05-03 17:38:17 +00:00
|
|
|
##
|
|
|
|
## The returned database descriptor will always have transaction level one.
|
|
|
|
## If there were no transactions that could be squashed, an empty
|
|
|
|
## transaction is added.
|
|
|
|
##
|
|
|
|
## Use `aristo_desc.forget()` to clean up this descriptor.
|
2024-04-26 13:43:52 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiHashifyFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[void,(VertexID,AristoError)]
|
|
|
|
{.noRaise.}
|
|
|
|
## Add keys to the `Patricia Trie` so that it becomes a `Merkle
|
|
|
|
## Patricia Tree`.
|
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiHasPathAccountFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 19:21:01 +00:00
|
|
|
## For an account record indexed by `accPath` query whether this record
|
2024-06-19 12:40:00 +00:00
|
|
|
## exists on the database.
|
|
|
|
|
|
|
|
AristoApiHasPathGenericFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
root: VertexID;
|
|
|
|
path: openArray[byte];
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## For a generic sub-tree starting at `root` and indexed by `path`,
|
|
|
|
## mquery whether this record exists on the database.
|
|
|
|
|
|
|
|
AristoApiHasPathStorageFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 19:21:01 +00:00
|
|
|
stoPath: openArray[byte];
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[bool,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-19 12:40:00 +00:00
|
|
|
## For a storage tree related to account `accPath`, query whether the
|
2024-06-27 19:21:01 +00:00
|
|
|
## data record indexed by `stoPath` exists on the database.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiHasStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 09:01:26 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## For a storage tree related to account `accPath`, query whether there
|
|
|
|
## is a non-empty data storage area at all.
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiIsTopFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): bool
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, returns `true` if the argument `tx` referes to the current
|
|
|
|
## top level transaction.
|
|
|
|
|
|
|
|
AristoApiLevelFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): int
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, non-negative nesting level (i.e. number of pending
|
|
|
|
## transactions)
|
|
|
|
|
|
|
|
AristoApiNForkedFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): int
|
|
|
|
{.noRaise.}
|
|
|
|
## Returns the number of non centre descriptors (see comments on
|
|
|
|
## `reCentre()` for details.) This function is a fast version of
|
|
|
|
## `db.forked.toSeq.len`.
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiMergeAccountRecordFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 09:01:26 +00:00
|
|
|
accRec: AristoAccount;
|
2024-06-18 11:14:02 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 09:01:26 +00:00
|
|
|
## Merge the key-value-pair argument `(accKey,accRec)` as an account
|
2024-06-18 11:14:02 +00:00
|
|
|
## ledger value, i.e. the the sub-tree starting at `VertexID(1)`.
|
|
|
|
|
|
|
|
AristoApiMergeGenericDataFn* =
|
|
|
|
proc( db: AristoDbRef;
|
|
|
|
root: VertexID;
|
|
|
|
path: openArray[byte];
|
|
|
|
data: openArray[byte];
|
2024-02-29 21:10:24 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-18 11:14:02 +00:00
|
|
|
## Variant of `mergeXXX()` for generic sub-trees, i.e. for arguments
|
|
|
|
## `root` greater than `VertexID(1)` and smaller than `LEAST_FREE_VID`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
AristoApiMergeStorageDataFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-07-03 08:14:26 +00:00
|
|
|
accPath: Hash256;
|
2024-06-27 19:21:01 +00:00
|
|
|
stoPath: openArray[byte];
|
2024-06-18 11:14:02 +00:00
|
|
|
stoData: openArray[byte];
|
2024-06-27 19:21:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Store the `stoData` data argument on the storage area addressed by
|
|
|
|
## `(accPath,stoPath)` where `accPath` is the account key (into the MPT)
|
|
|
|
## and `stoPath` is the slot path of the corresponding storage area.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
AristoApiPathAsBlobFn* =
|
|
|
|
proc(tag: PathID;
|
|
|
|
): Blob
|
|
|
|
{.noRaise.}
|
2024-03-21 10:45:57 +00:00
|
|
|
## Converts the `tag` argument to a sequence of an even number of
|
|
|
|
## nibbles represented by a `Blob`. If the argument `tag` represents
|
|
|
|
## an odd number of nibbles, a zero nibble is appendend.
|
|
|
|
##
|
|
|
|
## This function is useful only if there is a tacit agreement that all
|
|
|
|
## paths used to index database leaf values can be represented as
|
|
|
|
## `Blob`, i.e. `PathID` type paths with an even number of nibbles.
|
|
|
|
|
2024-04-29 20:17:17 +00:00
|
|
|
AristoApiPersistFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-03 20:10:35 +00:00
|
|
|
nxtSid = 0u64;
|
2024-04-29 20:17:17 +00:00
|
|
|
chunkedMpt = false;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Persistently store data onto backend database. If the system is
|
|
|
|
## running without a database backend, the function returns immediately
|
|
|
|
## with an error. The same happens if there is a pending transaction.
|
|
|
|
##
|
|
|
|
## The function merges all staged data from the top layer cache onto the
|
|
|
|
## backend stage area. After that, the top layer cache is cleared.
|
|
|
|
##
|
|
|
|
## Finally, the staged data are merged into the physical backend
|
2024-06-03 20:10:35 +00:00
|
|
|
## database and the staged data area is cleared.
|
2024-04-29 20:17:17 +00:00
|
|
|
##
|
2024-06-03 20:10:35 +00:00
|
|
|
## The argument `nxtSid` will be the ID for the next saved state record.
|
2024-04-29 20:17:17 +00:00
|
|
|
##
|
|
|
|
## Staging the top layer cache might fail with a partial MPT when it is
|
|
|
|
## set up from partial MPT chunks as it happens with `snap` sync
|
|
|
|
## processing. In this case, the `chunkedMpt` argument must be set
|
|
|
|
## `true` (see alse `fwdFilter()`.)
|
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
AristoApiReCentreFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-13 18:15:11 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
2024-03-21 10:45:57 +00:00
|
|
|
## Re-focus the `db` argument descriptor so that it becomes the centre.
|
|
|
|
## Nothing is done if the `db` descriptor is the centre, already.
|
|
|
|
##
|
|
|
|
## With several descriptors accessing the same backend database there is
|
|
|
|
## a single one that has write permission for the backend (regardless
|
|
|
|
## whether there is a backend, at all.) The descriptor entity with write
|
|
|
|
## permission is called *the centre*.
|
|
|
|
##
|
|
|
|
## After invoking `reCentre()`, the argument database `db` can only be
|
|
|
|
## destructed by `finish()` which also destructs all other descriptors
|
|
|
|
## accessing the same backend database. Descriptors where `isCentre()`
|
|
|
|
## returns `false` must be single destructed with `forget()`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
AristoApiRollbackFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Given a *top level* handle, this function discards all database
|
|
|
|
## operations performed for this transactio. The previous transaction
|
|
|
|
## is returned if there was any.
|
|
|
|
|
|
|
|
AristoApiTxBeginFn* =
|
|
|
|
proc(db: AristoDbRef
|
|
|
|
): Result[AristoTxRef,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Starts a new transaction.
|
|
|
|
##
|
|
|
|
## Example:
|
|
|
|
## ::
|
|
|
|
## proc doSomething(db: AristoDbRef) =
|
|
|
|
## let tx = db.begin
|
|
|
|
## defer: tx.rollback()
|
|
|
|
## ... continue using db ...
|
|
|
|
## tx.commit()
|
|
|
|
|
|
|
|
AristoApiTxTopFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[AristoTxRef,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, returns top level transaction if there is any.
|
|
|
|
|
|
|
|
AristoApiRef* = ref AristoApiObj
|
|
|
|
AristoApiObj* = object of RootObj
|
|
|
|
## Useful set of `Aristo` fuctions that can be filtered, stacked etc.
|
|
|
|
commit*: AristoApiCommitFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
deleteAccountRecord*: AristoApiDeleteAccountRecordFn
|
2024-06-18 19:30:01 +00:00
|
|
|
deleteGenericData*: AristoApiDeleteGenericDataFn
|
|
|
|
deleteGenericTree*: AristoApiDeleteGenericTreeFn
|
|
|
|
deleteStorageData*: AristoApiDeleteStorageDataFn
|
|
|
|
deleteStorageTree*: AristoApiDeleteStorageTreeFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
fetchLastSavedState*: AristoApiFetchLastSavedStateFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
fetchAccountRecord*: AristoApiFetchAccountRecordFn
|
|
|
|
fetchAccountState*: AristoApiFetchAccountStateFn
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchGenericData*: AristoApiFetchGenericDataFn
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchGenericState*: AristoApiFetchGenericStateFn
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchStorageData*: AristoApiFetchStorageDataFn
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchStorageState*: AristoApiFetchStorageStateFn
|
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
findTx*: AristoApiFindTxFn
|
2024-02-29 21:10:24 +00:00
|
|
|
finish*: AristoApiFinishFn
|
|
|
|
forget*: AristoApiForgetFn
|
2024-05-03 17:38:17 +00:00
|
|
|
forkTx*: AristoApiForkTxFn
|
2024-06-19 12:40:00 +00:00
|
|
|
hasPathAccount*: AristoApiHasPathAccountFn
|
|
|
|
hasPathGeneric*: AristoApiHasPathGenericFn
|
|
|
|
hasPathStorage*: AristoApiHasPathStorageFn
|
2024-06-27 09:01:26 +00:00
|
|
|
hasStorageData*: AristoApiHasStorageDataFn
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
isTop*: AristoApiIsTopFn
|
|
|
|
level*: AristoApiLevelFn
|
|
|
|
nForked*: AristoApiNForkedFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
mergeAccountRecord*: AristoApiMergeAccountRecordFn
|
2024-06-18 11:14:02 +00:00
|
|
|
mergeGenericData*: AristoApiMergeGenericDataFn
|
|
|
|
mergeStorageData*: AristoApiMergeStorageDataFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
pathAsBlob*: AristoApiPathAsBlobFn
|
2024-04-29 20:17:17 +00:00
|
|
|
persist*: AristoApiPersistFn
|
2024-03-21 10:45:57 +00:00
|
|
|
reCentre*: AristoApiReCentreFn
|
2024-02-29 21:10:24 +00:00
|
|
|
rollback*: AristoApiRollbackFn
|
|
|
|
txBegin*: AristoApiTxBeginFn
|
|
|
|
txTop*: AristoApiTxTopFn
|
|
|
|
|
|
|
|
|
|
|
|
AristoApiProfNames* = enum
|
|
|
|
## Index/name mapping for profile slots
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfTotal = "total"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfCommitFn = "commit"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfDeleteAccountRecordFn = "deleteAccountRecord"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteGenericDataFn = "deleteGnericData"
|
|
|
|
AristoApiProfDeleteGenericTreeFn = "deleteGnericTree"
|
|
|
|
AristoApiProfDeleteStorageDataFn = "deleteStorageData"
|
|
|
|
AristoApiProfDeleteStorageTreeFn = "deleteStorageTree"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfFetchLastSavedStateFn = "fetchLastSavedState"
|
|
|
|
|
|
|
|
AristoApiProfFetchAccountRecordFn = "fetchAccountRecord"
|
|
|
|
AristoApiProfFetchAccountStateFn = "fetchAccountState"
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchGenericDataFn = "fetchGenericData"
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchGenericStateFn = "fetchGenericState"
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchStorageDataFn = "fetchStorageData"
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchStorageStateFn = "fetchStorageState"
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfFindTxFn = "findTx"
|
|
|
|
AristoApiProfFinishFn = "finish"
|
|
|
|
AristoApiProfForgetFn = "forget"
|
|
|
|
AristoApiProfForkTxFn = "forkTx"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathAccountFn = "hasPathAccount"
|
|
|
|
AristoApiProfHasPathGenericFn = "hasPathGeneric"
|
|
|
|
AristoApiProfHasPathStorageFn = "hasPathStorage"
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfHasStorageDataFn = "hasStorageData"
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfIsTopFn = "isTop"
|
|
|
|
AristoApiProfLevelFn = "level"
|
|
|
|
AristoApiProfNForkedFn = "nForked"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfMergeAccountRecordFn = "mergeAccountRecord"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfMergeGenericDataFn = "mergeGenericData"
|
|
|
|
AristoApiProfMergeStorageDataFn = "mergeStorageData"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfPathAsBlobFn = "pathAsBlob"
|
|
|
|
AristoApiProfPersistFn = "persist"
|
|
|
|
AristoApiProfReCentreFn = "reCentre"
|
|
|
|
AristoApiProfRollbackFn = "rollback"
|
|
|
|
AristoApiProfTxBeginFn = "txBegin"
|
|
|
|
AristoApiProfTxTopFn = "txTop"
|
|
|
|
|
|
|
|
AristoApiProfBeGetVtxFn = "be/getVtx"
|
|
|
|
AristoApiProfBeGetKeyFn = "be/getKey"
|
|
|
|
AristoApiProfBeGetTuvFn = "be/getTuv"
|
|
|
|
AristoApiProfBeGetLstFn = "be/getLst"
|
|
|
|
AristoApiProfBePutVtxFn = "be/putVtx"
|
|
|
|
AristoApiProfBePutKeyFn = "be/putKey"
|
|
|
|
AristoApiProfBePutTuvFn = "be/putTuv"
|
|
|
|
AristoApiProfBePutLstFn = "be/putLst"
|
|
|
|
AristoApiProfBePutEndFn = "be/putEnd"
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
AristoApiProfRef* = ref object of AristoApiRef
|
|
|
|
## Profiling API extension of `AristoApiObj`
|
|
|
|
data*: AristoDbProfListRef
|
|
|
|
be*: BackendRef
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private helpers
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
when AutoValidateApiHooks:
|
|
|
|
proc validate(api: AristoApiObj|AristoApiRef) =
|
|
|
|
doAssert not api.commit.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.deleteAccountRecord.isNil
|
2024-06-18 19:30:01 +00:00
|
|
|
doAssert not api.deleteGenericData.isNil
|
|
|
|
doAssert not api.deleteGenericTree.isNil
|
|
|
|
doAssert not api.deleteStorageData.isNil
|
|
|
|
doAssert not api.deleteStorageTree.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
doAssert not api.fetchLastSavedState.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.fetchAccountRecord.isNil
|
|
|
|
doAssert not api.fetchAccountState.isNil
|
2024-06-19 12:40:00 +00:00
|
|
|
doAssert not api.fetchGenericData.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
doAssert not api.fetchGenericState.isNil
|
2024-06-19 12:40:00 +00:00
|
|
|
doAssert not api.fetchStorageData.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
doAssert not api.fetchStorageState.isNil
|
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
doAssert not api.findTx.isNil
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.finish.isNil
|
|
|
|
doAssert not api.forget.isNil
|
2024-05-03 17:38:17 +00:00
|
|
|
doAssert not api.forkTx.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
doAssert not api.hasPathAccount.isNil
|
|
|
|
doAssert not api.hasPathGeneric.isNil
|
|
|
|
doAssert not api.hasPathStorage.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
doAssert not api.hasStorageData.isNil
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.isTop.isNil
|
|
|
|
doAssert not api.level.isNil
|
|
|
|
doAssert not api.nForked.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.mergeAccountRecord.isNil
|
2024-06-18 11:14:02 +00:00
|
|
|
doAssert not api.mergeGenericData.isNil
|
|
|
|
doAssert not api.mergeStorageData.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.pathAsBlob.isNil
|
2024-04-29 20:17:17 +00:00
|
|
|
doAssert not api.persist.isNil
|
2024-03-21 10:45:57 +00:00
|
|
|
doAssert not api.reCentre.isNil
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.rollback.isNil
|
|
|
|
doAssert not api.txBegin.isNil
|
|
|
|
doAssert not api.txTop.isNil
|
|
|
|
|
2024-03-14 22:17:43 +00:00
|
|
|
proc validate(prf: AristoApiProfRef) =
|
2024-03-07 19:24:05 +00:00
|
|
|
prf.AristoApiRef.validate
|
|
|
|
doAssert not prf.data.isNil
|
2024-03-14 22:17:43 +00:00
|
|
|
|
|
|
|
proc dup(be: BackendRef): BackendRef =
|
|
|
|
case be.kind:
|
|
|
|
of BackendMemory:
|
|
|
|
return MemBackendRef(be).dup
|
|
|
|
|
2024-06-13 18:15:11 +00:00
|
|
|
of BackendRocksDB, BackendRdbHosting:
|
2024-03-14 22:17:43 +00:00
|
|
|
when AristoPersistentBackendOk:
|
|
|
|
return RdbBackendRef(be).dup
|
|
|
|
|
|
|
|
of BackendVoid:
|
|
|
|
discard
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public API constuctors
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func init*(api: var AristoApiObj) =
|
|
|
|
## Initialise an `api` argument descriptor
|
|
|
|
##
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
|
|
|
api.reset
|
2024-02-29 21:10:24 +00:00
|
|
|
api.commit = commit
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.deleteAccountRecord = deleteAccountRecord
|
2024-06-18 19:30:01 +00:00
|
|
|
api.deleteGenericData = deleteGenericData
|
|
|
|
api.deleteGenericTree = deleteGenericTree
|
|
|
|
api.deleteStorageData = deleteStorageData
|
|
|
|
api.deleteStorageTree = deleteStorageTree
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
api.fetchLastSavedState = fetchLastSavedState
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.fetchAccountRecord = fetchAccountRecord
|
|
|
|
api.fetchAccountState = fetchAccountState
|
2024-06-19 12:40:00 +00:00
|
|
|
api.fetchGenericData = fetchGenericData
|
2024-06-27 09:01:26 +00:00
|
|
|
api.fetchGenericState = fetchGenericState
|
2024-06-19 12:40:00 +00:00
|
|
|
api.fetchStorageData = fetchStorageData
|
2024-06-27 09:01:26 +00:00
|
|
|
api.fetchStorageState = fetchStorageState
|
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
api.findTx = findTx
|
2024-02-29 21:10:24 +00:00
|
|
|
api.finish = finish
|
|
|
|
api.forget = forget
|
2024-05-03 17:38:17 +00:00
|
|
|
api.forkTx = forkTx
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
api.hasPathAccount = hasPathAccount
|
|
|
|
api.hasPathGeneric = hasPathGeneric
|
|
|
|
api.hasPathStorage = hasPathStorage
|
2024-06-27 09:01:26 +00:00
|
|
|
api.hasStorageData = hasStorageData
|
|
|
|
|
2024-06-17 12:18:50 +00:00
|
|
|
api.isTop = isTop
|
2024-02-29 21:10:24 +00:00
|
|
|
api.level = level
|
|
|
|
api.nForked = nForked
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.mergeAccountRecord = mergeAccountRecord
|
2024-06-18 11:14:02 +00:00
|
|
|
api.mergeGenericData = mergeGenericData
|
|
|
|
api.mergeStorageData = mergeStorageData
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
api.pathAsBlob = pathAsBlob
|
2024-04-29 20:17:17 +00:00
|
|
|
api.persist = persist
|
2024-03-21 10:45:57 +00:00
|
|
|
api.reCentre = reCentre
|
2024-02-29 21:10:24 +00:00
|
|
|
api.rollback = rollback
|
|
|
|
api.txBegin = txBegin
|
|
|
|
api.txTop = txTop
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
|
|
|
api.validate
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
func init*(T: type AristoApiRef): T =
|
|
|
|
new result
|
|
|
|
result[].init()
|
|
|
|
|
|
|
|
func dup*(api: AristoApiRef): AristoApiRef =
|
2024-03-07 19:24:05 +00:00
|
|
|
result = AristoApiRef(
|
2024-06-18 19:30:01 +00:00
|
|
|
commit: api.commit,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
deleteAccountRecord: api.deleteAccountRecord,
|
2024-06-18 19:30:01 +00:00
|
|
|
deleteGenericData: api.deleteGenericData,
|
|
|
|
deleteGenericTree: api.deleteGenericTree,
|
|
|
|
deleteStorageData: api.deleteStorageData,
|
|
|
|
deleteStorageTree: api.deleteStorageTree,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
fetchLastSavedState: api.fetchLastSavedState,
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchAccountRecord: api.fetchAccountRecord,
|
|
|
|
fetchAccountState: api.fetchAccountState,
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchGenericData: api.fetchGenericData,
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchGenericState: api.fetchGenericState,
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchStorageData: api.fetchStorageData,
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchStorageState: api.fetchStorageState,
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
findTx: api.findTx,
|
|
|
|
finish: api.finish,
|
|
|
|
forget: api.forget,
|
|
|
|
forkTx: api.forkTx,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
hasPathAccount: api.hasPathAccount,
|
|
|
|
hasPathGeneric: api.hasPathGeneric,
|
|
|
|
hasPathStorage: api.hasPathStorage,
|
2024-06-27 09:01:26 +00:00
|
|
|
hasStorageData: api.hasStorageData,
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
isTop: api.isTop,
|
|
|
|
level: api.level,
|
|
|
|
nForked: api.nForked,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
mergeAccountRecord: api.mergeAccountRecord,
|
2024-06-18 19:30:01 +00:00
|
|
|
mergeGenericData: api.mergeGenericData,
|
|
|
|
mergeStorageData: api.mergeStorageData,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
pathAsBlob: api.pathAsBlob,
|
|
|
|
persist: api.persist,
|
|
|
|
reCentre: api.reCentre,
|
|
|
|
rollback: api.rollback,
|
|
|
|
txBegin: api.txBegin,
|
|
|
|
txTop: api.txTop)
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
|
|
|
api.validate
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public profile API constuctor
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func init*(
|
|
|
|
T: type AristoApiProfRef;
|
|
|
|
api: AristoApiRef;
|
|
|
|
be = BackendRef(nil);
|
|
|
|
): T =
|
|
|
|
## This constructor creates a profiling API descriptor to be derived from
|
|
|
|
## an initialised `api` argument descriptor. For profiling the DB backend,
|
|
|
|
## the field `.be` of the result descriptor must be assigned to the
|
|
|
|
## `.backend` field of the `AristoDbRef` descriptor.
|
|
|
|
##
|
|
|
|
## The argument desctiptors `api` and `be` will not be modified and can be
|
|
|
|
## used to restore the previous set up.
|
|
|
|
##
|
|
|
|
let
|
|
|
|
data = AristoDbProfListRef(
|
|
|
|
list: newSeq[AristoDbProfData](1 + high(AristoApiProfNames).ord))
|
|
|
|
profApi = T(data: data)
|
|
|
|
|
|
|
|
template profileRunner(n: AristoApiProfNames, code: untyped): untyped =
|
|
|
|
let start = getTime()
|
|
|
|
code
|
|
|
|
data.update(n.ord, getTime() - start)
|
|
|
|
|
|
|
|
profApi.commit =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfCommitFn.profileRunner:
|
|
|
|
result = api.commit(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.deleteAccountRecord =
|
2024-06-18 19:30:01 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfDeleteAccountRecordFn.profileRunner:
|
|
|
|
result = api.deleteAccountRecord(a, b)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
profApi.deleteGenericData =
|
|
|
|
proc(a: AristoDbRef; b: VertexID; c: openArray[byte]): auto =
|
|
|
|
AristoApiProfDeleteGenericDataFn.profileRunner:
|
|
|
|
result = api.deleteGenericData(a, b, c)
|
|
|
|
|
|
|
|
profApi.deleteGenericTree =
|
|
|
|
proc(a: AristoDbRef; b: VertexID): auto =
|
|
|
|
AristoApiProfDeleteGenericTreeFn.profileRunner:
|
|
|
|
result = api.deleteGenericTree(a, b)
|
|
|
|
|
|
|
|
profApi.deleteStorageData =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b, c: openArray[byte]): auto =
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteStorageDataFn.profileRunner:
|
|
|
|
result = api.deleteStorageData(a, b, c)
|
|
|
|
|
|
|
|
profApi.deleteStorageTree =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]): auto =
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteStorageTreeFn.profileRunner:
|
|
|
|
result = api.deleteStorageTree(a, b)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
profApi.fetchLastSavedState =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfFetchLastSavedStateFn.profileRunner:
|
|
|
|
result = api.fetchLastSavedState(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.fetchAccountRecord =
|
2024-06-19 12:40:00 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchAccountRecordFn.profileRunner:
|
|
|
|
result = api.fetchAccountRecord(a, b)
|
|
|
|
|
|
|
|
profApi.fetchAccountState =
|
2024-06-28 15:03:12 +00:00
|
|
|
proc(a: AristoDbRef; b: bool): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchAccountStateFn.profileRunner:
|
2024-06-28 15:03:12 +00:00
|
|
|
result = api.fetchAccountState(a, b)
|
2024-06-19 12:40:00 +00:00
|
|
|
|
|
|
|
profApi.fetchGenericData =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: AristoDbRef; b: VertexID; c: openArray[byte]): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchGenericDataFn.profileRunner:
|
|
|
|
result = api.fetchGenericData(a, b, c)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.fetchGenericState =
|
2024-06-28 15:03:12 +00:00
|
|
|
proc(a: AristoDbRef; b: VertexID; c: bool): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchGenericStateFn.profileRunner:
|
2024-06-28 15:03:12 +00:00
|
|
|
result = api.fetchGenericState(a, b, c)
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
profApi.fetchStorageData =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b, c: openArray[byte]): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchStorageDataFn.profileRunner:
|
|
|
|
result = api.fetchStorageData(a, b, c)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.fetchStorageState =
|
2024-06-28 15:03:12 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]; c: bool): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchStorageStateFn.profileRunner:
|
2024-06-28 15:03:12 +00:00
|
|
|
result = api.fetchStorageState(a, b, c)
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
profApi.findTx =
|
|
|
|
proc(a: AristoDbRef; b: VertexID; c: HashKey): auto =
|
|
|
|
AristoApiProfFindTxFn.profileRunner:
|
|
|
|
result = api.findTx(a, b, c)
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.finish =
|
|
|
|
proc(a: AristoDbRef; b = false) =
|
|
|
|
AristoApiProfFinishFn.profileRunner:
|
|
|
|
api.finish(a, b)
|
|
|
|
|
|
|
|
profApi.forget =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfForgetFn.profileRunner:
|
|
|
|
result = api.forget(a)
|
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
profApi.forkTx =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b: int): auto =
|
2024-05-03 17:38:17 +00:00
|
|
|
AristoApiProfForkTxFn.profileRunner:
|
2024-06-27 19:21:01 +00:00
|
|
|
result = api.forkTx(a, b)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
profApi.hasPathAccount =
|
|
|
|
proc(a: AristoDbRef; b: openArray[byte]): auto =
|
|
|
|
AristoApiProfHasPathAccountFn.profileRunner:
|
|
|
|
result = api.hasPathAccount(a, b)
|
|
|
|
|
|
|
|
profApi.hasPathGeneric =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: AristoDbRef; b: VertexID; c: openArray[byte]): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathGenericFn.profileRunner:
|
|
|
|
result = api.hasPathGeneric(a, b, c)
|
|
|
|
|
|
|
|
profApi.hasPathStorage =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b, c: openArray[byte]): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathStorageFn.profileRunner:
|
|
|
|
result = api.hasPathStorage(a, b, c)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.hasStorageData =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfHasStorageDataFn.profileRunner:
|
|
|
|
result = api.hasStorageData(a, b)
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.isTop =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfIsTopFn.profileRunner:
|
|
|
|
result = api.isTop(a)
|
|
|
|
|
|
|
|
profApi.level =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfLevelFn.profileRunner:
|
|
|
|
result = api.level(a)
|
|
|
|
|
|
|
|
profApi.nForked =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfNForkedFn.profileRunner:
|
|
|
|
result = api.nForked(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.mergeAccountRecord =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b: openArray[byte]; c: AristoAccount): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfMergeAccountRecordFn.profileRunner:
|
|
|
|
result = api.mergeAccountRecord(a, b, c)
|
2024-06-18 11:14:02 +00:00
|
|
|
|
|
|
|
profApi.mergeGenericData =
|
|
|
|
proc(a: AristoDbRef; b: VertexID, c, d: openArray[byte]): auto =
|
|
|
|
AristoApiProfMergeGenericDataFn.profileRunner:
|
|
|
|
result = api.mergeGenericData(a, b, c, d)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
profApi.mergeStorageData =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: AristoDbRef; b, c, d: openArray[byte]): auto =
|
2024-06-18 11:14:02 +00:00
|
|
|
AristoApiProfMergeStorageDataFn.profileRunner:
|
|
|
|
result = api.mergeStorageData(a, b, c, d)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
profApi.pathAsBlob =
|
|
|
|
proc(a: PathID): auto =
|
|
|
|
AristoApiProfPathAsBlobFn.profileRunner:
|
|
|
|
result = api.pathAsBlob(a)
|
|
|
|
|
2024-04-29 20:17:17 +00:00
|
|
|
profApi.persist =
|
2024-06-03 20:10:35 +00:00
|
|
|
proc(a: AristoDbRef; b = 0u64; c = false): auto =
|
2024-04-29 20:17:17 +00:00
|
|
|
AristoApiProfPersistFn.profileRunner:
|
|
|
|
result = api.persist(a, b, c)
|
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
profApi.reCentre =
|
2024-06-13 18:15:11 +00:00
|
|
|
proc(a: AristoDbRef): auto =
|
2024-03-21 10:45:57 +00:00
|
|
|
AristoApiProfReCentreFn.profileRunner:
|
2024-06-13 18:15:11 +00:00
|
|
|
result = api.reCentre(a)
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.rollback =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfRollbackFn.profileRunner:
|
|
|
|
result = api.rollback(a)
|
|
|
|
|
|
|
|
profApi.txBegin =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfTxBeginFn.profileRunner:
|
|
|
|
result = api.txBegin(a)
|
|
|
|
|
|
|
|
profApi.txTop =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfTxTopFn.profileRunner:
|
|
|
|
result = api.txTop(a)
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
let beDup = be.dup()
|
|
|
|
if beDup.isNil:
|
|
|
|
profApi.be = be
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
else:
|
|
|
|
beDup.getVtxFn =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: VertexID): auto =
|
|
|
|
AristoApiProfBeGetVtxFn.profileRunner:
|
|
|
|
result = be.getVtxFn(a)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBeGetVtxFn.ord].masked = true
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
beDup.getKeyFn =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: VertexID): auto =
|
|
|
|
AristoApiProfBeGetKeyFn.profileRunner:
|
|
|
|
result = be.getKeyFn(a)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBeGetKeyFn.ord].masked = true
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-14 11:19:48 +00:00
|
|
|
beDup.getTuvFn =
|
2024-04-22 19:02:22 +00:00
|
|
|
proc(): auto =
|
2024-06-14 11:19:48 +00:00
|
|
|
AristoApiProfBeGetTuvFn.profileRunner:
|
|
|
|
result = be.getTuvFn()
|
|
|
|
data.list[AristoApiProfBeGetTuvFn.ord].masked = true
|
2024-04-22 19:02:22 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
beDup.getLstFn =
|
|
|
|
proc(): auto =
|
|
|
|
AristoApiProfBeGetLstFn.profileRunner:
|
|
|
|
result = be.getLstFn()
|
|
|
|
data.list[AristoApiProfBeGetLstFn.ord].masked = true
|
|
|
|
|
2024-04-22 19:02:22 +00:00
|
|
|
beDup.putVtxFn =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: PutHdlRef; b: VertexID, c: VertexRef) =
|
2024-04-22 19:02:22 +00:00
|
|
|
AristoApiProfBePutVtxFn.profileRunner:
|
2024-06-27 19:21:01 +00:00
|
|
|
be.putVtxFn(a, b, c)
|
2024-04-22 19:02:22 +00:00
|
|
|
data.list[AristoApiProfBePutVtxFn.ord].masked = true
|
|
|
|
|
|
|
|
beDup.putKeyFn =
|
2024-06-27 19:21:01 +00:00
|
|
|
proc(a: PutHdlRef; b: VertexID, c: HashKey) =
|
2024-04-22 19:02:22 +00:00
|
|
|
AristoApiProfBePutKeyFn.profileRunner:
|
2024-06-27 19:21:01 +00:00
|
|
|
be.putKeyFn(a, b, c)
|
2024-04-22 19:02:22 +00:00
|
|
|
data.list[AristoApiProfBePutKeyFn.ord].masked = true
|
|
|
|
|
2024-06-14 11:19:48 +00:00
|
|
|
beDup.putTuvFn =
|
|
|
|
proc(a: PutHdlRef; b: VertexID) =
|
|
|
|
AristoApiProfBePutTuvFn.profileRunner:
|
|
|
|
be.putTuvFn(a,b)
|
|
|
|
data.list[AristoApiProfBePutTuvFn.ord].masked = true
|
2024-04-22 19:02:22 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
beDup.putLstFn =
|
|
|
|
proc(a: PutHdlRef; b: SavedState) =
|
|
|
|
AristoApiProfBePutLstFn.profileRunner:
|
|
|
|
be.putLstFn(a,b)
|
|
|
|
data.list[AristoApiProfBePutLstFn.ord].masked = true
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
beDup.putEndFn =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: PutHdlRef): auto =
|
|
|
|
AristoApiProfBePutEndFn.profileRunner:
|
|
|
|
result = be.putEndFn(a)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBePutEndFn.ord].masked = true
|
|
|
|
|
|
|
|
profApi.be = beDup
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
2024-03-14 22:17:43 +00:00
|
|
|
profApi.validate
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|