Skip to content

Commit

Permalink
Get the latest history tree not the tip height history tree
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 authored Nov 21, 2023
1 parent cfd2db8 commit f7a43b7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions zebra-state/src/service/finalized_state/zebra_db/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ impl ZebraDb {
let mut history_tree: Option<Arc<HistoryTree>> = self.db.zs_get(&history_tree_cf, &());

if history_tree.is_none() {
let tip_height = self
.finalized_tip_height()
.expect("just checked for an empty database");

history_tree = self.db.zs_get(&history_tree_cf, &tip_height);
// In Zebra 1.4.0 and later, we only update the history tip tree when it has changed (for every block after heartwood).
// But we write with a `()` key, not a height key.
// So we need to look for the most recent update height if the `()` key has never been written.
history_tree = self.db.zs_last_key_value(&history_tree_cf);

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Install zebrad from lockfile without cache on ubuntu-latest

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Test stable on macos-latest

mismatched types

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

mismatched types

error[E0308]: mismatched types --> zebra-state/src/service/finalized_state/zebra_db/chain.rs:65:28 | 59 | let mut history_tree: Option<Arc<HistoryTree>> = self.db.zs_get(&history_tree_cf, &()); | ------------------------ expected due to this type ... 65 | history_tree = self.db.zs_last_key_value(&history_tree_cf); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Arc<HistoryTree>>`, found `Option<(_, _)>` | = note: expected enum `std::option::Option<std::sync::Arc<zebra_chain::history_tree::HistoryTree>>` found enum `std::option::Option<(_, _)>`

Check failure on line 65 in zebra-state/src/service/finalized_state/zebra_db/chain.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

mismatched types

error[E0308]: mismatched types --> zebra-state/src/service/finalized_state/zebra_db/chain.rs:65:28 | 59 | let mut history_tree: Option<Arc<HistoryTree>> = self.db.zs_get(&history_tree_cf, &()); | ------------------------ expected due to this type ... 65 | history_tree = self.db.zs_last_key_value(&history_tree_cf); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Arc<HistoryTree>>`, found `Option<(_, _)>` | = note: expected enum `std::option::Option<std::sync::Arc<zebra_chain::history_tree::HistoryTree>>` found enum `std::option::Option<(_, _)>`
}

history_tree.unwrap_or_default()
Expand Down

0 comments on commit f7a43b7

Please sign in to comment.