diff --git a/zebra-state/src/service.rs b/zebra-state/src/service.rs index 4a1ddec3bb2..523f4cd2db0 100644 --- a/zebra-state/src/service.rs +++ b/zebra-state/src/service.rs @@ -812,7 +812,7 @@ impl StateService { /// Returns true if the block hash is queued or has been sent to be validated and committed. /// Returns false otherwise. fn is_block_queued(&self, hash: &block::Hash) -> bool { - self.queued_non_finalized_blocks.contains(hash) + self.queued_non_finalized_blocks.contains_block_hash(hash) || self.queued_finalized_blocks.contains_key(hash) || self.sent_blocks.contains(hash) } @@ -1082,12 +1082,12 @@ impl Service for StateService { let read_service = self.read_service.clone(); async move { - let response = read::non_finalized_state_contains_hash( + let response = read::non_finalized_state_contains_block_hash( &read_service.latest_non_finalized_state(), hash, ) .or(is_block_queued.then_some(KnownBlock::Queue)) - .or_else(|| read::finalized_state_contains_hash(&read_service.db, hash)); + .or_else(|| read::finalized_state_contains_block_hash(&read_service.db, hash)); // The work is done in the future. timer.finish(module_path!(), line!(), "Request::KnownBlock"); diff --git a/zebra-state/src/service/read.rs b/zebra-state/src/service/read.rs index aa63033167b..c63b36d25d7 100644 --- a/zebra-state/src/service/read.rs +++ b/zebra-state/src/service/read.rs @@ -34,9 +34,9 @@ pub use block::{ any_utxo, block, block_header, transaction, transaction_hashes_for_block, unspent_utxo, utxo, }; pub use find::{ - best_tip, block_locator, chain_contains_hash, depth, finalized_state_contains_hash, + best_tip, block_locator, chain_contains_hash, depth, finalized_state_contains_block_hash, find_chain_hashes, find_chain_headers, hash_by_height, height_by_hash, next_median_time_past, - non_finalized_state_contains_hash, tip, tip_height, + non_finalized_state_contains_block_hash, tip, tip_height, }; pub use tree::{orchard_tree, sapling_tree}; diff --git a/zebra-state/src/service/read/find.rs b/zebra-state/src/service/read/find.rs index bb7a2e32882..78f9121d4cb 100644 --- a/zebra-state/src/service/read/find.rs +++ b/zebra-state/src/service/read/find.rs @@ -103,12 +103,12 @@ where /// Returns the location of the block if present in the non-finalized state. /// Returns None if the block hash is not found in the non-finalized state. -pub fn non_finalized_state_contains_hash( +pub fn non_finalized_state_contains_block_hash( non_finalized_state: &NonFinalizedState, hash: block::Hash, ) -> Option { let mut chains_iter = non_finalized_state.chain_set.iter().rev(); - let is_hash_in_chain = |chain: &Arc| chain.contains(&hash); + let is_hash_in_chain = |chain: &Arc| chain.contains_block_hash(&hash); // Equivalent to `chain_set.iter().next_back()` in `NonFinalizedState.best_chain()` method. let best_chain = chains_iter.next(); @@ -122,7 +122,7 @@ pub fn non_finalized_state_contains_hash( /// Returns the location of the block if present in the finalized state. /// Returns None if the block hash is not found in the finalized state. -pub fn finalized_state_contains_hash(db: &ZebraDb, hash: block::Hash) -> Option { +pub fn finalized_state_contains_block_hash(db: &ZebraDb, hash: block::Hash) -> Option { db.contains_hash(hash).then_some(KnownBlock::BestChain) }