Skip to content

Commit

Permalink
3. refactor(state): move database reads and writes to a new zebra_db …
Browse files Browse the repository at this point in the history
…module (#3579)

* refactor(state): move disk_db reads to a new zebra_db module

* refactor(state): make finalized value pool method names consistent

* refactor(state): split database writes into the zebra_db module

* refactor(state): move the block batch method to DiskWriteBatch

* refactor(state): actually add the zebra_db module

Unfortunately, I've lost the interim changes to this file,
so this commit might be the only one that compiles.

* refactor(state): add a newly created file to the cached state CI job
  • Loading branch information
teor2345 authored Feb 23, 2022
1 parent fc7ecfe commit 22b8a60
Show file tree
Hide file tree
Showing 10 changed files with 672 additions and 565 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,17 @@ jobs:
persist-credentials: false
fetch-depth: '2'

# only run this job if the database format might have changed
- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v14.4
with:
files: |
/zebra-state/**/constants.rs
/zebra-state/**/finalized_state.rs
/zebra-state/**/disk_format.rs
/zebra-state/**/disk_db.rs
/zebra-state/**/finalized_state.rs
/zebra-state/**/constants.rs
/zebra-state/**/zebra_db.rs
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
Expand Down
694 changes: 145 additions & 549 deletions zebra-state/src/service/finalized_state.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion zebra-state/src/service/finalized_state/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ where

impl FinalizedState {
/// Allow to set up a fake value pool in the database for testing purposes.
pub fn set_current_value_pool(&self, fake_value_pool: ValueBalance<NonNegative>) {
pub fn set_finalized_value_pool(&self, fake_value_pool: ValueBalance<NonNegative>) {
let mut batch = DiskWriteBatch::new();
let value_pool_cf = self.db.cf_handle("tip_chain_value_pool").unwrap();

Expand Down
4 changes: 2 additions & 2 deletions zebra-state/src/service/finalized_state/disk_db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Module defining access to RocksDB via accessor traits.
//! Provides low-level access to RocksDB using some database-specific types.
//!
//! This module makes sure that:
//! - all disk writes happen inside a RocksDB transaction, and
//! - all disk writes happen inside a RocksDB transaction ([`WriteBatch`]), and
//! - format-specific invariants are maintained.
//!
//! # Correctness
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/finalized_state/disk_format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Module defining the serialization format for finalized data.
//! Serialization formats for finalized data.
//!
//! # Correctness
//!
Expand Down
Loading

0 comments on commit 22b8a60

Please sign in to comment.