From 76b097ce9f642440262c2e9e7073592f11013782 Mon Sep 17 00:00:00 2001 From: Arya Date: Fri, 25 Oct 2024 02:17:57 -0400 Subject: [PATCH] Fixes lint, avoids reading coinbase transactions from disk --- zebra-state/src/service/finalized_state/disk_db.rs | 3 --- .../disk_format/upgrade/drop_tx_locs_by_spends.rs | 7 ++++++- .../disk_format/upgrade/track_tx_locs_by_spends.rs | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/zebra-state/src/service/finalized_state/disk_db.rs b/zebra-state/src/service/finalized_state/disk_db.rs index 4fb8b53a38c..69be5a4585f 100644 --- a/zebra-state/src/service/finalized_state/disk_db.rs +++ b/zebra-state/src/service/finalized_state/disk_db.rs @@ -32,9 +32,6 @@ use crate::{ Config, }; -#[cfg(not(feature = "indexer"))] -use crate::constants::STATE_DATABASE_KIND; - // Doc-only imports #[allow(unused_imports)] use super::{TypedColumnFamily, WriteTypedBatch}; diff --git a/zebra-state/src/service/finalized_state/disk_format/upgrade/drop_tx_locs_by_spends.rs b/zebra-state/src/service/finalized_state/disk_format/upgrade/drop_tx_locs_by_spends.rs index fa53d397052..cfc82b1aec1 100644 --- a/zebra-state/src/service/finalized_state/disk_format/upgrade/drop_tx_locs_by_spends.rs +++ b/zebra-state/src/service/finalized_state/disk_format/upgrade/drop_tx_locs_by_spends.rs @@ -42,7 +42,12 @@ pub fn run( let height = Height(height); let mut batch = DiskWriteBatch::new(); - for (_tx_loc, tx) in zebra_db.transactions_by_height(height) { + let transactions = zebra_db.transactions_by_location_range( + crate::TransactionLocation::from_index(height, 1) + ..=crate::TransactionLocation::max_for_height(height), + ); + + for (_tx_loc, tx) in transactions { if tx.is_coinbase() { continue; } diff --git a/zebra-state/src/service/finalized_state/disk_format/upgrade/track_tx_locs_by_spends.rs b/zebra-state/src/service/finalized_state/disk_format/upgrade/track_tx_locs_by_spends.rs index 175d670d69b..be754fac452 100644 --- a/zebra-state/src/service/finalized_state/disk_format/upgrade/track_tx_locs_by_spends.rs +++ b/zebra-state/src/service/finalized_state/disk_format/upgrade/track_tx_locs_by_spends.rs @@ -35,7 +35,12 @@ pub fn run( let mut batch = DiskWriteBatch::new(); let mut should_index_at_height = false; - for (tx_loc, tx) in zebra_db.transactions_by_height(height) { + let transactions = zebra_db.transactions_by_location_range( + crate::TransactionLocation::from_index(height, 1) + ..=crate::TransactionLocation::max_for_height(height), + ); + + for (tx_loc, tx) in transactions { if tx.is_coinbase() { continue; }