nimbus-eth1/nimbus/db/ledger
Jordan Hrycaj 0d73637f14
Core db simplify new api storage modes (#2075)
* Aristo+Kvt: Fix backend `dup()` function in api setup

why:
  Backend object is subject to an inheritance cascade which was not
  taken care of, before. Only the base object was duplicated.

* Kvt: Simplify DB clone/peers management

* Aristo: Simplify DB clone/peers management

* Aristo: Adjust unit test for working with memory DB only

why:
  This currently causes some memory corruption persumably in the
  `libc` background layer.

* CoredDb+Kvt: Simplify API for KVT

why:
  Simplified storage models (was over engineered) for better performance
  and code maintenance.

* CoredDb+Aristo: Simplify API for `Aristo`

why:
  Only single database state needed here. Accessing a similar state will
  be implemented from outside this module using a context layer. This
  gives better performance and improves code maintenance.

* Fix Copyright headers

* CoreDb: Turn off API tracking

why:
  CI would ot go through. Was accidentally turned on.
2024-03-14 22:17:43 +00:00
..
backend Implement getAccessList of db/ledger (#2055) 2024-02-29 18:16:47 +07:00
base Coredb use stackable api for aristo backend (#2060) 2024-02-29 21:10:24 +00:00
README.md Ledger abstraction for accounts cache (#1824) 2023-10-18 20:27:22 +01:00
accounts_cache.nim Implement getAccessList of db/ledger (#2055) 2024-02-29 18:16:47 +07:00
accounts_ledger.nim Core db simplify new api storage modes (#2075) 2024-03-14 22:17:43 +00:00
base.nim Coredb use stackable api for aristo backend (#2060) 2024-02-29 21:10:24 +00:00
base_iterators.nim Core db+ledger aristo backend update (#2006) 2024-02-02 20:23:04 +00:00
distinct_ledgers.nim Core db simplify new api storage modes (#2075) 2024-03-14 22:17:43 +00:00

README.md

The file accounts_cache.nim has been relocated

Background

The new LedgerRef module unifies different implementations of the accounts_cache. It is intended to be used as new base method for all of the AccountsCache implementations. Only constructors differ, depending on the implementation.

This was needed to accomodate for different CoreDb API paradigms. While the overloaded legacy AccountsCache implementation is just a closure based wrapper around the accounts_cache module, the overloaded AccountsLedgerRef is a closure based wrapper around the accounts_ledger module with the new CoreDb API returning Result[] values and saparating the meaning of trie root hash and trie root reference.

This allows to use the legacy hexary database (with the new CoreDb API) as well as the Aristo database (only supported on new API.)

Instructions

Legacy notation LedgerRef replacement Comment
import accounts_cache import ledger preferred method,
AccountsCache.init(..) AccountsCache.init(..) wraps AccountsCache
methods
or
import ledger/accounts_cache stay with legacy
AccountsCache.init(..) version of
AccountsCache
--
fn(ac: AccountsCache) fn(ac: LedgerRef) function example for
preferred wrapper
or method
fn(ac: AccountsCache) with legacy version,
no change here

The constructor decides which CoreDb API is to be used

Legacy API constructor new API Constructor
import ledger import ledger
let w = AccountsCache.init(..) let w = AccountsLedgerRef.init(..)