mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-10 12:26:02 +00:00
09fabd04eb
* Provide deep copy for each transaction layer why: Localising changes. Selective deep copy was just overlooked. * Generalise vertex ID generator state reorg function `vidReorg()` why: makes it somewhat easier to handle when saving layers. * Provide dummy back end descriptor `NoneBackendRef` * Optional read-only filter between backend and transaction cache why: Some staging area for accumulating changes to the backend DB. This will eventually be an access layer for emulating a backend with multiple/historic state roots. * Re-factor `persistent()` with filter between backend/tx-cache => `stow()` why: The filter provides an abstraction from the physically stored data on disk. So, there can be several MPT instances using the same disk data with different state roots. Of course, all the MPT instances should not differ too much for practical reasons :). TODO: Filter administration tools need to be provided.
61 lines
2.2 KiB
Nim
61 lines
2.2 KiB
Nim
# Nimbus - Types, data structures and shared utilities used in network sync
|
|
#
|
|
# Copyright (c) 2018-2021 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.
|
|
|
|
## Iterators for persistent backend of the Aristo DB
|
|
## =================================================
|
|
##
|
|
## This module automatically pulls in the persistent backend library at the
|
|
## linking stage (e.g. `rocksdb`) which can be avoided for pure memory DB
|
|
## applications by importing `./aristo_walk/memory_only` (rather than
|
|
## `./aristo_walk/persistent`.)
|
|
##
|
|
import
|
|
../aristo_init/[aristo_rocksdb, persistent],
|
|
".."/[aristo_desc, aristo_init],
|
|
"."/[aristo_walk_private, memory_only]
|
|
export
|
|
aristo_rocksdb,
|
|
memory_only,
|
|
persistent
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Public iterators (all in one)
|
|
# ------------------------------------------------------------------------------
|
|
|
|
iterator walkVtxBe*(
|
|
T: type RdbBackendRef;
|
|
db: AristoDbRef;
|
|
): tuple[n: int, vid: VertexID, vtx: VertexRef] =
|
|
## Iterate over filtered RocksDB backend vertices. This function depends on
|
|
## the particular backend type name which must match the backend descriptor.
|
|
for (n,vid,vtx) in db.to(T).walkVtxBeImpl db:
|
|
yield (n,vid,vtx)
|
|
|
|
iterator walkKeyBe*(
|
|
T: type RdbBackendRef;
|
|
db: AristoDbRef;
|
|
): tuple[n: int, vid: VertexID, key: HashKey] =
|
|
## Similar to `walkVtxBe()` but for keys.
|
|
for (n,vid,key) in db.to(T).walkKeyBeImpl db:
|
|
yield (n,vid,key)
|
|
|
|
iterator walkIdgBe*(
|
|
T: type RdbBackendRef;
|
|
db: AristoDbRef;
|
|
): tuple[n: int, vid: VertexID, vGen: seq[VertexID]] =
|
|
## Similar to `walkVtxBe()` but for vertex ID generator states.
|
|
for (n,vid,vGen) in db.to(T).walkIdgBeImpl db:
|
|
yield (n,vid,vGen)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# End
|
|
# ------------------------------------------------------------------------------
|