Skip to content

Commit 313b4e2

Browse files
authored
Merge pull request #3317 from Pana/doc/db
doc: add docs about db related crates
2 parents 4d75471 + 8b4adfd commit 313b4e2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/repo/layout.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,20 @@ Other utility crates:
5959

6060
### dbs
6161

62-
The [dbs](../../crates/dbs) directory contains the database crates.
62+
All database-related code is located under [dbs](../../crates/dbs), which contains the core logic for the entire node's data storage. Specifically, it mainly includes two major categories of data: blockchain (block header, block body, receipt) and state (state trie, storage trie), as well as some indexing and development data (trace).
63+
64+
The underlying layer primarily uses rocksdb, and also uses sqlite to store some snapshot-related data.
65+
66+
1. kvdb-rocksdb: Rust wrapper for rocksdb, which depends on third-party crates (kvdb, rocksdb) at the underlying layer
67+
2. db: Mainly provides the open_database method, which returns a db instance that can be used for data reading and writing
68+
3. db-errors: Database operation error definitions
69+
4. **storage**: The main implementation of the state database, including mpt, mpt snapshot and other logic, providing lower-level read/write interfaces `StateTrait`. This crate is the core code for state storage
70+
5. statedb: Simple wrapper around storage, providing higher-level read interfaces `StateDbExt`
71+
72+
Additionally, the upper-level modules that call the db module mainly consist of two parts:
73+
74+
1. crates/cfxcore/core/src/block_data_manager: Encapsulates all data read/write interfaces
75+
2. crates/execution/executor/src/state: The state object of the execution module, which essentially wraps StateDb and provides account state reading and updating interfaces for EVM.
6376

6477
### network
6578

0 commit comments

Comments
 (0)