2023-11-16 20:53:44 +00:00
|
|
|
# Nimbus
|
Core db update storage root management for sub tries (#1964)
* Aristo: Re-phrase `LayerDelta` and `LayerFinal` as object references
why:
Avoids copying in some cases
* Fix copyright header
* Aristo: Verify `leafTie.root` function argument for `merge()` proc
why:
Zero root will lead to inconsistent DB entry
* Aristo: Update failure condition for hash labels compiler `hashify()`
why:
Node need not be rejected as long as links are on the schedule. In
that case, `redo[]` is to become `wff.base[]` at a later stage.
This amends an earlier fix, part of #1952 by also testing against
the target nodes of the `wff.base[]` sets.
* Aristo: Add storage root glue record to `hashify()` schedule
why:
An account leaf node might refer to a non-resolvable storage root ID.
Storage root node chains will end up at the storage root. So the link
`storage-root->account-leaf` needs an extra item in the schedule.
* Aristo: fix error code returned by `fetchPayload()`
details:
Final error code is implied by the error code form the `hikeUp()`
function.
* CoreDb: Discard `createOk` argument in API `getRoot()` function
why:
Not needed for the legacy DB. For the `Arsto` DB, a lazy approach is
implemented where a stprage root node is created on-the-fly.
* CoreDb: Prevent `$$` logging in some cases
why:
Logging the function `$$` is not useful when it is used for internal
use, i.e. retrieving an an error text for logging.
* CoreDb: Add `tryHashFn()` to API for pretty printing
why:
Pretty printing must not change the hashification status for the
`Aristo` DB. So there is an independent API wrapper for getting the
node hash which never updated the hashes.
* CoreDb: Discard `update` argument in API `hash()` function
why:
When calling the API function `hash()`, the latest state is always
wanted. For a version that uses the current state as-is without checking,
the function `tryHash()` was added to the backend.
* CoreDb: Update opaque vertex ID objects for the `Aristo` backend
why:
For `Aristo`, vID objects encapsulate a numeric `VertexID`
referencing a vertex (rather than a node hash as used on the
legacy backend.) For storage sub-tries, there might be no initial
vertex known when the descriptor is created. So opaque vertex ID
objects are supported without a valid `VertexID` which will be
initalised on-the-fly when the first item is merged.
* CoreDb: Add pretty printer for opaque vertex ID objects
* Cosmetics, printing profiling data
* CoreDb: Fix segfault in `Aristo` backend when creating MPT descriptor
why:
Missing initialisation error
* CoreDb: Allow MPT to inherit shared context on `Aristo` backend
why:
Creates descriptors with different storage roots for the same
shared `Aristo` DB descriptor.
* Cosmetics, update diagnostic message items for `Aristo` backend
* Fix Copyright year
2024-01-11 19:11:38 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-11-16 20:53:44 +00:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
2024-06-05 18:17:50 +00:00
|
|
|
std/tables,
|
2023-11-16 20:53:44 +00:00
|
|
|
eth/common,
|
2024-04-16 20:39:11 +00:00
|
|
|
../../aristo as use_ari,
|
|
|
|
../../aristo/aristo_walk,
|
|
|
|
../../kvt as use_kvt,
|
|
|
|
../../kvt/[kvt_init/memory_only, kvt_walk],
|
2023-11-16 20:53:44 +00:00
|
|
|
".."/[base, base/base_desc],
|
2024-06-18 11:14:02 +00:00
|
|
|
./aristo_db/[common_desc, handlers_aristo, handlers_kvt]
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
import
|
|
|
|
../../aristo/aristo_init/memory_only as aristo_memory_only
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
# Caveat:
|
|
|
|
# additional direct include(s) -- not import(s) -- is placed near
|
|
|
|
# the end of this source file
|
2024-02-02 10:58:35 +00:00
|
|
|
|
2024-02-02 20:23:04 +00:00
|
|
|
# Annotation helper(s)
|
2023-11-16 20:53:44 +00:00
|
|
|
{.pragma: noRaise, gcsafe, raises: [].}
|
|
|
|
{.pragma: rlpRaise, gcsafe, raises: [AristoApiRlpError].}
|
|
|
|
|
|
|
|
export
|
|
|
|
AristoApiRlpError,
|
2024-04-03 15:48:35 +00:00
|
|
|
AristoCoreDbKvtBE,
|
|
|
|
isAristo
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
AristoCoreDbRef* = ref object of CoreDbRef
|
|
|
|
## Main descriptor
|
|
|
|
kdbBase: KvtBaseRef ## Kvt subsystem
|
|
|
|
adbBase: AristoBaseRef ## Aristo subsystem
|
2024-06-18 11:14:02 +00:00
|
|
|
#tracer: AristoTracerRef ## Currently active recorder
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
#AristoTracerRef = ref object of TraceRecorderRef
|
|
|
|
# ## Sub-handle for tracer
|
|
|
|
# parent: AristoCoreDbRef
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
proc newAristoVoidCoreDbRef*(): CoreDbRef {.noRaise.}
|
|
|
|
|
2023-11-16 20:53:44 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private tx and base methods
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
proc txMethods(
|
|
|
|
db: AristoCoreDbRef;
|
|
|
|
aTx: AristoTxRef;
|
|
|
|
kTx: KvtTxRef;
|
|
|
|
): CoreDbTxFns =
|
|
|
|
## To be constructed by some `CoreDbBaseFns` function
|
2024-03-18 19:40:23 +00:00
|
|
|
let
|
|
|
|
adbBase = db.adbBase
|
|
|
|
kdbBase = db.kdbBase
|
|
|
|
|
|
|
|
adbApi = adbBase.api
|
|
|
|
kdbApi = kdbBase.api
|
|
|
|
|
2023-11-16 20:53:44 +00:00
|
|
|
CoreDbTxFns(
|
2023-11-24 22:16:21 +00:00
|
|
|
levelFn: proc(): int =
|
|
|
|
aTx.level,
|
|
|
|
|
2024-06-05 20:52:04 +00:00
|
|
|
commitFn: proc() =
|
2023-11-16 20:53:44 +00:00
|
|
|
const info = "commitFn()"
|
2024-06-05 20:52:04 +00:00
|
|
|
adbApi.commit(aTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
kdbApi.commit(kTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
discard,
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-06-05 20:52:04 +00:00
|
|
|
rollbackFn: proc() =
|
2023-11-16 20:53:44 +00:00
|
|
|
const info = "rollbackFn()"
|
2024-06-05 20:52:04 +00:00
|
|
|
adbApi.rollback(aTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
kdbApi.rollback(kTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
discard,
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-06-05 20:52:04 +00:00
|
|
|
disposeFn: proc() =
|
2023-11-16 20:53:44 +00:00
|
|
|
const info = "disposeFn()"
|
2024-06-05 20:52:04 +00:00
|
|
|
if adbApi.isTop(aTx):
|
|
|
|
adbApi.rollback(aTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
if kdbApi.isTop(kTx):
|
|
|
|
kdbApi.rollback(kTx).isOkOr:
|
|
|
|
raiseAssert info & ": " & $error
|
|
|
|
discard)
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
when false: # currently disabled
|
|
|
|
proc cptMethods(
|
|
|
|
tracer: AristoTracerRef;
|
|
|
|
): CoreDbCaptFns =
|
|
|
|
let
|
|
|
|
tr = tracer # So it can savely be captured
|
|
|
|
db = tr.parent # Will not change and can be captured
|
|
|
|
log = tr.topInst() # Ditto
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
CoreDbCaptFns(
|
|
|
|
recorderFn: proc(): CoreDbRef =
|
|
|
|
db,
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
logDbFn: proc(): TableRef[Blob,Blob] =
|
|
|
|
log.kLog,
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
getFlagsFn: proc(): set[CoreDbCaptFlags] =
|
|
|
|
log.flags,
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
forgetFn: proc() =
|
|
|
|
if not tracer.pop():
|
|
|
|
tr.parent.tracer = AristoTracerRef(nil)
|
|
|
|
tr.restore())
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
proc baseMethods(db: AristoCoreDbRef): CoreDbBaseFns =
|
|
|
|
let
|
|
|
|
aBase = db.adbBase
|
|
|
|
kBase = db.kdbBase
|
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
when false: # currently disabled
|
|
|
|
proc tracerSetup(flags: set[CoreDbCaptFlags]): CoreDxCaptRef =
|
|
|
|
if db.tracer.isNil:
|
|
|
|
db.tracer = AristoTracerRef(parent: db)
|
|
|
|
db.tracer.init(kBase, aBase, flags)
|
|
|
|
else:
|
|
|
|
db.tracer.push(flags)
|
|
|
|
CoreDxCaptRef(methods: db.tracer.cptMethods)
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
proc persistent(bn: Opt[BlockNumber]): CoreDbRc[void] =
|
2024-04-19 18:37:27 +00:00
|
|
|
const info = "persistentFn()"
|
2024-06-03 20:10:35 +00:00
|
|
|
let sid =
|
|
|
|
if bn.isNone: 0u64
|
2024-06-14 07:31:08 +00:00
|
|
|
else: bn.unsafeGet
|
2024-04-19 18:37:27 +00:00
|
|
|
? kBase.persistent info
|
2024-06-03 20:10:35 +00:00
|
|
|
? aBase.persistent(sid, info)
|
2024-04-19 18:37:27 +00:00
|
|
|
ok()
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2023-11-16 20:53:44 +00:00
|
|
|
CoreDbBaseFns(
|
2024-06-14 11:19:48 +00:00
|
|
|
destroyFn: proc(eradicate: bool) =
|
|
|
|
aBase.destroy(eradicate)
|
|
|
|
kBase.destroy(eradicate),
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2023-11-24 22:16:21 +00:00
|
|
|
levelFn: proc(): int =
|
2024-04-19 18:37:27 +00:00
|
|
|
aBase.getLevel,
|
2023-11-24 22:16:21 +00:00
|
|
|
|
2024-06-17 13:29:07 +00:00
|
|
|
colStateEmptyFn: proc(col: CoreDbColRef): CoreDbRc[bool] =
|
|
|
|
aBase.rootHashEmpty(col, "rootHashFn()"),
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
colStateFn: proc(col: CoreDbColRef): CoreDbRc[Hash256] =
|
|
|
|
aBase.rootHash(col, "rootHashFn()"),
|
Core db update storage root management for sub tries (#1964)
* Aristo: Re-phrase `LayerDelta` and `LayerFinal` as object references
why:
Avoids copying in some cases
* Fix copyright header
* Aristo: Verify `leafTie.root` function argument for `merge()` proc
why:
Zero root will lead to inconsistent DB entry
* Aristo: Update failure condition for hash labels compiler `hashify()`
why:
Node need not be rejected as long as links are on the schedule. In
that case, `redo[]` is to become `wff.base[]` at a later stage.
This amends an earlier fix, part of #1952 by also testing against
the target nodes of the `wff.base[]` sets.
* Aristo: Add storage root glue record to `hashify()` schedule
why:
An account leaf node might refer to a non-resolvable storage root ID.
Storage root node chains will end up at the storage root. So the link
`storage-root->account-leaf` needs an extra item in the schedule.
* Aristo: fix error code returned by `fetchPayload()`
details:
Final error code is implied by the error code form the `hikeUp()`
function.
* CoreDb: Discard `createOk` argument in API `getRoot()` function
why:
Not needed for the legacy DB. For the `Arsto` DB, a lazy approach is
implemented where a stprage root node is created on-the-fly.
* CoreDb: Prevent `$$` logging in some cases
why:
Logging the function `$$` is not useful when it is used for internal
use, i.e. retrieving an an error text for logging.
* CoreDb: Add `tryHashFn()` to API for pretty printing
why:
Pretty printing must not change the hashification status for the
`Aristo` DB. So there is an independent API wrapper for getting the
node hash which never updated the hashes.
* CoreDb: Discard `update` argument in API `hash()` function
why:
When calling the API function `hash()`, the latest state is always
wanted. For a version that uses the current state as-is without checking,
the function `tryHash()` was added to the backend.
* CoreDb: Update opaque vertex ID objects for the `Aristo` backend
why:
For `Aristo`, vID objects encapsulate a numeric `VertexID`
referencing a vertex (rather than a node hash as used on the
legacy backend.) For storage sub-tries, there might be no initial
vertex known when the descriptor is created. So opaque vertex ID
objects are supported without a valid `VertexID` which will be
initalised on-the-fly when the first item is merged.
* CoreDb: Add pretty printer for opaque vertex ID objects
* Cosmetics, printing profiling data
* CoreDb: Fix segfault in `Aristo` backend when creating MPT descriptor
why:
Missing initialisation error
* CoreDb: Allow MPT to inherit shared context on `Aristo` backend
why:
Creates descriptors with different storage roots for the same
shared `Aristo` DB descriptor.
* Cosmetics, update diagnostic message items for `Aristo` backend
* Fix Copyright year
2024-01-11 19:11:38 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
colPrintFn: proc(vid: CoreDbColRef): string =
|
|
|
|
aBase.colPrint(vid),
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
errorPrintFn: proc(e: CoreDbErrorRef): string =
|
|
|
|
e.errorPrint(),
|
|
|
|
|
2024-06-05 20:52:04 +00:00
|
|
|
newKvtFn: proc(): CoreDbRc[CoreDxKvtRef] =
|
|
|
|
kBase.newKvtHandler("newKvtFn()"),
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
newCtxFn: proc(): CoreDbCtxRef =
|
2024-04-19 18:37:27 +00:00
|
|
|
aBase.ctx,
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
newCtxFromTxFn: proc(r: Hash256; k: CoreDbColType): CoreDbRc[CoreDbCtxRef] =
|
2024-03-21 10:45:57 +00:00
|
|
|
CoreDbCtxRef.init(db.adbBase, r, k),
|
|
|
|
|
|
|
|
swapCtxFn: proc(ctx: CoreDbCtxRef): CoreDbCtxRef =
|
2024-04-19 18:37:27 +00:00
|
|
|
aBase.swapCtx(ctx),
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-06-05 20:52:04 +00:00
|
|
|
beginFn: proc(): CoreDxTxRef =
|
2023-11-16 20:53:44 +00:00
|
|
|
const info = "beginFn()"
|
2024-06-05 20:52:04 +00:00
|
|
|
let
|
|
|
|
aTx = aBase.txBegin info
|
|
|
|
kTx = kBase.txBegin info
|
|
|
|
dsc = CoreDxTxRef(methods: db.txMethods(aTx, kTx))
|
|
|
|
db.bless(dsc),
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
# # currently disabled
|
|
|
|
# newCaptureFn: proc(flags:set[CoreDbCaptFlags]): CoreDbRc[CoreDxCaptRef] =
|
|
|
|
# ok(db.bless flags.tracerSetup()),
|
2024-04-19 18:37:27 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
persistentFn: proc(bn: Opt[BlockNumber]): CoreDbRc[void] =
|
2024-04-29 20:17:17 +00:00
|
|
|
persistent(bn))
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2024-04-16 20:39:11 +00:00
|
|
|
# Public constructor and helper
|
2023-11-16 20:53:44 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
proc create*(dbType: CoreDbType; kdb: KvtDbRef; adb: AristoDbRef): CoreDbRef =
|
2023-11-16 20:53:44 +00:00
|
|
|
## Constructor helper
|
|
|
|
|
|
|
|
# Local extensions
|
|
|
|
var db = AristoCoreDbRef()
|
|
|
|
db.adbBase = AristoBaseRef.init(db, adb)
|
|
|
|
db.kdbBase = KvtBaseRef.init(db, kdb)
|
|
|
|
|
|
|
|
# Base descriptor
|
|
|
|
db.dbType = dbType
|
2024-04-19 18:37:27 +00:00
|
|
|
db.methods = db.baseMethods()
|
|
|
|
db.bless()
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
proc newAristoMemoryCoreDbRef*(): CoreDbRef =
|
2024-04-16 20:39:11 +00:00
|
|
|
AristoDbMemory.create(
|
2024-04-19 18:37:27 +00:00
|
|
|
KvtDbRef.init(use_kvt.MemBackendRef),
|
|
|
|
AristoDbRef.init(use_ari.MemBackendRef))
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
proc newAristoVoidCoreDbRef*(): CoreDbRef =
|
2024-04-16 20:39:11 +00:00
|
|
|
AristoDbVoid.create(
|
2024-04-19 18:37:27 +00:00
|
|
|
KvtDbRef.init(use_kvt.VoidBackendRef),
|
|
|
|
AristoDbRef.init(use_ari.VoidBackendRef))
|
2023-11-16 20:53:44 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2024-03-07 19:24:05 +00:00
|
|
|
# Public helpers, e.g. for direct backend access
|
2023-11-16 20:53:44 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
func toAristoProfData*(
|
|
|
|
db: CoreDbRef;
|
|
|
|
): tuple[aristo: AristoDbProfListRef, kvt: KvtDbProfListRef] =
|
|
|
|
when CoreDbEnableApiProfiling:
|
|
|
|
if db.isAristo:
|
|
|
|
result.aristo = db.AristoCoreDbRef.adbBase.api.AristoApiProfRef.data
|
|
|
|
result.kvt = db.AristoCoreDbRef.kdbBase.api.KvtApiProfRef.data
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
func toAristoApi*(kvt: CoreDxKvtRef): KvtApiRef =
|
|
|
|
if kvt.parent.isAristo:
|
|
|
|
return AristoCoreDbRef(kvt.parent).kdbBase.api
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
func toAristoApi*(mpt: CoreDxMptRef): AristoApiRef =
|
|
|
|
if mpt.parent.isAristo:
|
|
|
|
return mpt.to(AristoApiRef)
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
func toAristo*(kBe: CoreDbKvtBackendRef): KvtDbRef =
|
|
|
|
if not kBe.isNil and kBe.parent.isAristo:
|
|
|
|
return kBe.AristoCoreDbKvtBE.kdb
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
func toAristo*(mBe: CoreDbMptBackendRef): AristoDbRef =
|
|
|
|
if not mBe.isNil and mBe.parent.isAristo:
|
|
|
|
return mBe.AristoCoreDbMptBE.adb
|
2023-11-16 20:53:44 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
proc toAristoSavedStateBlockNumber*(
|
2024-05-22 13:41:14 +00:00
|
|
|
mBe: CoreDbMptBackendRef;
|
|
|
|
): tuple[stateRoot: Hash256, blockNumber: BlockNumber] =
|
|
|
|
if not mBe.isNil and mBe.parent.isAristo:
|
2024-05-31 17:32:22 +00:00
|
|
|
let rc = mBe.parent.AristoCoreDbRef.adbBase.getSavedState()
|
|
|
|
if rc.isOk:
|
2024-06-14 07:31:08 +00:00
|
|
|
return (rc.value.src.to(Hash256), rc.value.serial.BlockNumber)
|
|
|
|
(EMPTY_ROOT_HASH, 0.BlockNumber)
|
2024-04-26 13:43:52 +00:00
|
|
|
|
2024-02-02 10:58:35 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public aristo iterators
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
include
|
|
|
|
./aristo_db/aristo_replicate
|
|
|
|
|
|
|
|
# ------------------------
|
|
|
|
|
|
|
|
iterator aristoKvtPairsVoid*(dsc: CoreDxKvtRef): (Blob,Blob) {.rlpRaise.} =
|
|
|
|
let
|
|
|
|
api = dsc.toAristoApi()
|
2024-05-07 19:59:27 +00:00
|
|
|
p = api.forkTx(dsc.to(KvtDbRef),0).valueOrApiError "aristoKvtPairs()"
|
2024-03-07 19:24:05 +00:00
|
|
|
defer: discard api.forget(p)
|
2024-04-16 20:39:11 +00:00
|
|
|
for (k,v) in use_kvt.VoidBackendRef.walkPairs p:
|
2024-03-07 19:24:05 +00:00
|
|
|
yield (k,v)
|
|
|
|
|
|
|
|
iterator aristoKvtPairsMem*(dsc: CoreDxKvtRef): (Blob,Blob) {.rlpRaise.} =
|
|
|
|
let
|
|
|
|
api = dsc.toAristoApi()
|
2024-05-07 19:59:27 +00:00
|
|
|
p = api.forkTx(dsc.to(KvtDbRef),0).valueOrApiError "aristoKvtPairs()"
|
2024-03-07 19:24:05 +00:00
|
|
|
defer: discard api.forget(p)
|
2024-04-16 20:39:11 +00:00
|
|
|
for (k,v) in use_kvt.MemBackendRef.walkPairs p:
|
2024-02-02 10:58:35 +00:00
|
|
|
yield (k,v)
|
|
|
|
|
2024-02-16 09:08:07 +00:00
|
|
|
iterator aristoMptPairs*(dsc: CoreDxMptRef): (Blob,Blob) {.noRaise.} =
|
2024-03-07 19:24:05 +00:00
|
|
|
let
|
2024-04-19 18:37:27 +00:00
|
|
|
api = dsc.to(AristoApiRef)
|
2024-03-07 19:24:05 +00:00
|
|
|
mpt = dsc.to(AristoDbRef)
|
2024-02-29 21:10:24 +00:00
|
|
|
for (k,v) in mpt.rightPairs LeafTie(root: dsc.rootID):
|
2024-03-07 19:24:05 +00:00
|
|
|
yield (api.pathAsBlob(k.path), api.serialise(mpt, v).valueOr(EmptyBlob))
|
2024-02-02 10:58:35 +00:00
|
|
|
|
|
|
|
iterator aristoReplicateMem*(dsc: CoreDxMptRef): (Blob,Blob) {.rlpRaise.} =
|
|
|
|
## Instantiation for `MemBackendRef`
|
2024-04-16 20:39:11 +00:00
|
|
|
for k,v in aristoReplicate[use_ari.MemBackendRef](dsc):
|
2024-02-02 10:58:35 +00:00
|
|
|
yield (k,v)
|
|
|
|
|
|
|
|
iterator aristoReplicateVoid*(dsc: CoreDxMptRef): (Blob,Blob) {.rlpRaise.} =
|
|
|
|
## Instantiation for `VoidBackendRef`
|
2024-04-16 20:39:11 +00:00
|
|
|
for k,v in aristoReplicate[use_ari.VoidBackendRef](dsc):
|
2024-02-02 10:58:35 +00:00
|
|
|
yield (k,v)
|
|
|
|
|
2023-11-16 20:53:44 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|