diff --git a/.cargo/config.toml b/.cargo/config.toml index 330d8612907..76bf55492d5 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -56,6 +56,9 @@ rustflags = [ "-Wmissing_docs", # TODOs: + # Fix this lint eventually. + "-Aclippy::result_large_err", + # `cargo fix` might help do these fixes, # or add a config.toml to sub-directories which should allow these lints, # or try allowing the lint in the specific module (lib.rs doesn't seem to work in some cases) diff --git a/zebra-state/src/service/finalized_state/disk_db.rs b/zebra-state/src/service/finalized_state/disk_db.rs index 64bace06213..ab20a62faa3 100644 --- a/zebra-state/src/service/finalized_state/disk_db.rs +++ b/zebra-state/src/service/finalized_state/disk_db.rs @@ -156,7 +156,7 @@ impl WriteDisk for DiskWriteBatch { } // TODO: convert zs_delete_range() to take std::ops::RangeBounds - // see zs_range_iter() for an example of the edge cases + // see zs_forward_range_iter() for an example of the edge cases fn zs_delete_range(&mut self, cf: &C, from: K, to: K) where C: rocksdb::AsColumnFamilyRef, @@ -329,7 +329,7 @@ impl ReadDisk for DiskDb { V: FromDisk, { // Reading individual values from iterators does not seem to cause database hangs. - self.zs_range_iter(cf, .., false).next() + self.zs_forward_range_iter(cf, ..).next() } #[allow(clippy::unwrap_in_result)] @@ -340,7 +340,7 @@ impl ReadDisk for DiskDb { V: FromDisk, { // Reading individual values from iterators does not seem to cause database hangs. - self.zs_range_iter(cf, .., true).next() + self.zs_reverse_range_iter(cf, ..).next() } #[allow(clippy::unwrap_in_result)] @@ -351,7 +351,7 @@ impl ReadDisk for DiskDb { V: FromDisk, { // Reading individual values from iterators does not seem to cause database hangs. - self.zs_range_iter(cf, lower_bound.., false).next() + self.zs_forward_range_iter(cf, lower_bound..).next() } #[allow(clippy::unwrap_in_result)] @@ -362,7 +362,7 @@ impl ReadDisk for DiskDb { V: FromDisk, { // Reading individual values from iterators does not seem to cause database hangs. - self.zs_range_iter(cf, ..=upper_bound, true).next() + self.zs_reverse_range_iter(cf, ..=upper_bound).next() } fn zs_items_in_range_ordered(&self, cf: &C, range: R) -> BTreeMap @@ -372,7 +372,7 @@ impl ReadDisk for DiskDb { V: FromDisk, R: RangeBounds, { - self.zs_range_iter(cf, range, false).collect() + self.zs_forward_range_iter(cf, range).collect() } fn zs_items_in_range_unordered(&self, cf: &C, range: R) -> HashMap @@ -382,7 +382,7 @@ impl ReadDisk for DiskDb { V: FromDisk, R: RangeBounds, { - self.zs_range_iter(cf, range, false).collect() + self.zs_forward_range_iter(cf, range).collect() } } @@ -402,18 +402,13 @@ impl DiskWriteBatch { } impl DiskDb { - /// Returns an iterator over the items in `cf` in `range`. - /// - /// Accepts a `reverse` argument. If it is `true`, creates the iterator with an - /// [`IteratorMode`](rocksdb::IteratorMode) of [`End`](rocksdb::IteratorMode::End), or - /// [`From`](rocksdb::IteratorMode::From) with [`Direction::Reverse`](rocksdb::Direction::Reverse). + /// Returns a forward iterator over the items in `cf` in `range`. /// /// Holding this iterator open might delay block commit transactions. - pub fn zs_range_iter( + pub fn zs_forward_range_iter( &self, cf: &C, range: R, - reverse: bool, ) -> impl Iterator + '_ where C: rocksdb::AsColumnFamilyRef, @@ -421,14 +416,12 @@ impl DiskDb { V: FromDisk, R: RangeBounds, { - self.zs_range_iter_with_direction(cf, range, reverse) + self.zs_range_iter_with_direction(cf, range, false) } /// Returns a reverse iterator over the items in `cf` in `range`. /// /// Holding this iterator open might delay block commit transactions. - /// - /// This code is copied from `zs_range_iter()`, but with the mode reversed. pub fn zs_reverse_range_iter( &self, cf: &C, diff --git a/zebra-state/src/service/finalized_state/disk_format/transparent.rs b/zebra-state/src/service/finalized_state/disk_format/transparent.rs index 534883c267e..46879f39aaf 100644 --- a/zebra-state/src/service/finalized_state/disk_format/transparent.rs +++ b/zebra-state/src/service/finalized_state/disk_format/transparent.rs @@ -420,13 +420,13 @@ impl AddressTransaction { /// address. Starts at the first UTXO, or at the `query` start height, whichever is greater. /// Ends at the maximum possible transaction index for the end height. /// - /// Used to look up transactions with [`DiskDb::zs_range_iter`][1]. + /// Used to look up transactions with [`DiskDb::zs_forward_range_iter`][1]. /// /// The transaction locations in the: /// - start bound might be invalid, if it is based on the `query` start height. /// - end bound will always be invalid. /// - /// But this is not an issue, since [`DiskDb::zs_range_iter`][1] will fetch all existing + /// But this is not an issue, since [`DiskDb::zs_forward_range_iter`][1] will fetch all existing /// (valid) values in the range. /// /// [1]: super::super::disk_db::DiskDb diff --git a/zebra-state/src/service/finalized_state/zebra_db/chain.rs b/zebra-state/src/service/finalized_state/zebra_db/chain.rs index 43f0d1ae1df..da737442cdd 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/chain.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/chain.rs @@ -78,7 +78,7 @@ impl ZebraDb { ) -> impl Iterator)> + '_ { let history_tree_cf = self.db.cf_handle("history_tree").unwrap(); - self.db.zs_range_iter(&history_tree_cf, .., false) + self.db.zs_forward_range_iter(&history_tree_cf, ..) } // Value pool methods diff --git a/zebra-state/src/service/finalized_state/zebra_db/shielded.rs b/zebra-state/src/service/finalized_state/zebra_db/shielded.rs index efeaedb0c0d..4bba75b1891 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/shielded.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/shielded.rs @@ -155,7 +155,7 @@ impl ZebraDb { &self, ) -> impl Iterator)> + '_ { let sprout_trees = self.db.cf_handle("sprout_note_commitment_tree").unwrap(); - self.db.zs_range_iter(&sprout_trees, .., false) + self.db.zs_forward_range_iter(&sprout_trees, ..) } // # Sapling trees @@ -209,7 +209,7 @@ impl ZebraDb { R: std::ops::RangeBounds, { let sapling_trees = self.db.cf_handle("sapling_note_commitment_tree").unwrap(); - self.db.zs_range_iter(&sapling_trees, range, false) + self.db.zs_forward_range_iter(&sapling_trees, range) } /// Returns the Sapling note commitment trees in the reversed range, in decreasing height order. @@ -259,7 +259,7 @@ impl ZebraDb { .unwrap(); self.db - .zs_range_iter(&sapling_subtrees, range, false) + .zs_forward_range_iter(&sapling_subtrees, range) .collect() } @@ -335,7 +335,7 @@ impl ZebraDb { R: std::ops::RangeBounds, { let orchard_trees = self.db.cf_handle("orchard_note_commitment_tree").unwrap(); - self.db.zs_range_iter(&orchard_trees, range, false) + self.db.zs_forward_range_iter(&orchard_trees, range) } /// Returns the Orchard note commitment trees in the reversed range, in decreasing height order. @@ -385,7 +385,7 @@ impl ZebraDb { .unwrap(); self.db - .zs_range_iter(&orchard_subtrees, range, false) + .zs_forward_range_iter(&orchard_subtrees, range) .collect() } diff --git a/zebra-state/src/service/finalized_state/zebra_db/transparent.rs b/zebra-state/src/service/finalized_state/zebra_db/transparent.rs index bbf15ea9111..7c45911824e 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/transparent.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/transparent.rs @@ -242,11 +242,7 @@ impl ZebraDb { AddressTransaction::address_iterator_range(address_location, query_height_range); self.db - .zs_range_iter( - &tx_loc_by_transparent_addr_loc, - transaction_location_range, - false, - ) + .zs_forward_range_iter(&tx_loc_by_transparent_addr_loc, transaction_location_range) .map(|(tx_loc, ())| tx_loc) .collect() }