2023-07-31 13:43:38 +00:00
|
|
|
Core database replacement wrapper object
|
|
|
|
========================================
|
|
|
|
This wrapper replaces the *TrieDatabaseRef* and its derivatives by the new
|
|
|
|
object *CoreDbRef*.
|
|
|
|
|
|
|
|
Relations to current *TrieDatabaseRef* implementation
|
|
|
|
-----------------------------------------------------
|
|
|
|
Here are some incomplete translations for objects and constructors.
|
|
|
|
|
|
|
|
### Object types:
|
|
|
|
|
|
|
|
| **Legacy notation** | **CoreDbRef based replacement** |
|
|
|
|
|:----------------------------|:--------------------------------------|
|
|
|
|
| | |
|
|
|
|
| ChainDB | (don't use/avoid) |
|
|
|
|
| ChainDbRef | CoreDbRef |
|
|
|
|
| TrieDatabaseRef | CoreDbKvtRef |
|
|
|
|
| HexaryTrie | CoreDbMptRef |
|
|
|
|
| SecureHexaryTrie | CoreDbPhkRef |
|
|
|
|
| DbTransaction | CoreDbTxRef |
|
|
|
|
| TransactionID | CoreDbTxID |
|
|
|
|
|
|
|
|
|
|
|
|
### Constructors:
|
|
|
|
|
|
|
|
| **Legacy notation** | **CoreDbRef based replacement** |
|
|
|
|
|:----------------------------|:--------------------------------------|
|
|
|
|
| | |
|
|
|
|
| trieDB newChainDB("..") | newCoreDbRef(LegacyDbPersistent,"..") |
|
|
|
|
| newMemoryDB() | newCoreDbRef(LegacyDbMemory) |
|
|
|
|
| -- | |
|
|
|
|
| initHexaryTrie(db,..) | db.mpt(..) (no pruning) |
|
|
|
|
| | db.mptPrune(..) (w/pruning true/false)|
|
|
|
|
| -- | |
|
|
|
|
| initSecureHexaryTrie(db,..) | db.phk(..) (no pruning) |
|
|
|
|
| | db.phkPrune(..) (w/pruning true/false)|
|
|
|
|
| -- | |
|
2023-08-02 20:46:41 +00:00
|
|
|
| newCaptureDB(db,memDB) | db.capture() (see below) |
|
2023-07-31 13:43:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
Usage of the replacement wrapper
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
### Objects pedigree:
|
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
CoreDbRef -- base descriptor
|
2023-07-31 13:43:38 +00:00
|
|
|
| | |
|
2024-03-21 10:45:57 +00:00
|
|
|
| | +--- CoreDbCtxRef -- MPT context descriptor
|
|
|
|
| | | |
|
|
|
|
| | | +-- CoreDbMptRef -- hexary trie instance
|
|
|
|
| | | | : :
|
|
|
|
| | | +-- CoreDbMptRef -- hexary trie instance
|
|
|
|
| | |
|
|
|
|
| | |
|
|
|
|
| | +---- CoreDbPhkRef -- pre-hashed key hexary trie instance
|
|
|
|
| | | : :
|
|
|
|
| | +---- CoreDbPhkRef -- pre-hashed key hexary trie instance
|
2023-07-31 13:43:38 +00:00
|
|
|
| |
|
|
|
|
| |
|
2024-03-21 10:45:57 +00:00
|
|
|
| +------ CoreDbKvtRef -- single static key-value table
|
2023-07-31 13:43:38 +00:00
|
|
|
|
|
|
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
+-------- CoreDbCaptRef -- tracer support descriptor
|
2023-07-31 13:43:38 +00:00
|
|
|
|
2024-03-21 10:45:57 +00:00
|
|
|
### Instantiating legacy standard database object descriptors works as follows:
|
2023-07-31 13:43:38 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
db = newCoreDbRef(..) # new base descriptor
|
|
|
|
mpt = db.mpt(..) # hexary trie/Merkle Patricia Tree
|
|
|
|
phk = db.phk(..) # pre-hashed key hexary trie/MPT
|
|
|
|
kvt = db.kvt # key-value table
|
|
|
|
|
|
|
|
### Tracer support setup by hiding the current *CoreDbRef* behind a replacement:
|
|
|
|
|
|
|
|
let
|
2023-08-04 11:10:09 +00:00
|
|
|
capture = db.capture()
|
2023-07-31 13:43:38 +00:00
|
|
|
db = capture.recorder # use the recorder in place of db
|
|
|
|
...
|
|
|
|
|
|
|
|
for key,value in capture.recorder.kvt:
|
|
|
|
... # process recorded data
|