nimbus-eth1/nimbus/db/kvt/kvt_desc/desc_structural.nim
Jordan Hrycaj 54f784bef1
Kvt remodel tx and forked descriptors (#2168)
* Aristo: Generalise alien/guest interface for piggiback on database

* Aristo: Code cosmetics

* CoreDb+Kvt: Update transaction API

why:
  Use single addressable function `forkTx(backLevel: int)` as used
  in `Aristo`. So `Kvt` can be synced simultaneously to `Aristo`.

also:
  Refactored `kvt_tx.nim` in a similar fashion to `Aristo`.

* Kvt: Replace `LayerDelta` object by reference

why:
  Will be needed when introducing filters

* Kvt: Remodel backend filter facility similar to `Aristo`

why:
  This allows to operate on several KVT instances simultaneously.

* CoreDb+Kvt: Fix on-disk storage

why:
  Overlooked name change: `stow()` => `persist()` for permanent storage

* Fix copyright headers
2024-05-07 19:59:27 +00:00

46 lines
1.5 KiB
Nim

# nimbus-eth1
# Copyright (c) 2023-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.
## Kvt DB -- structural data types
## ===============================
##
{.push raises: [].}
import
std/tables,
eth/common
type
LayerDeltaRef* = ref object
## Delta tables relative to previous layer
sTab*: Table[Blob,Blob] ## Structural data table
LayerRef* = ref object
## Kvt database layer structures. Any layer holds the full
## change relative to the backend.
delta*: LayerDeltaRef ## Structural tables held as deltas
txUid*: uint ## Transaction identifier if positive
# ------------------------------------------------------------------------------
# Public helpers (misc)
# ------------------------------------------------------------------------------
func init*(T: type LayerRef): T =
## Constructor, returns empty layer
T(delta: LayerDeltaRef())
func dup*(ly: LayerDeltaRef): LayerDeltaRef =
## Duplicate/copy
LayerDeltaRef(sTab: ly.sTab)
# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------