From 0fde0d737938517d4b8cba4f65420987c66c508c Mon Sep 17 00:00:00 2001 From: carllin Date: Thu, 25 Jun 2020 16:39:55 -0700 Subject: [PATCH] Add ancestor iterator to lib.rs (#10813) Co-authored-by: Carl --- ledger/src/ancestor_iterator.rs | 6 ++---- ledger/src/lib.rs | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ledger/src/ancestor_iterator.rs b/ledger/src/ancestor_iterator.rs index ee61f9ddd7..0c01757d6e 100644 --- a/ledger/src/ancestor_iterator.rs +++ b/ledger/src/ancestor_iterator.rs @@ -25,7 +25,7 @@ impl<'a> Iterator for AncestorIterator<'a> { type Item = Slot; fn next(&mut self) -> Option { - let current = self.current.clone(); + let current = self.current; current.map(|slot| { if slot != 0 { self.current = self.blockstore.meta(slot).unwrap().and_then(|slot_meta| { @@ -101,9 +101,7 @@ mod tests { fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 4, fork_point, fork_hash); // Test correctness - assert!(AncestorIterator::new(0, &blockstore) - .collect::>() - .is_empty()); + assert!(AncestorIterator::new(0, &blockstore).next().is_none()); assert_eq!( AncestorIterator::new(4, &blockstore).collect::>(), vec![1, 0] diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index 318b2be998..b034f8d3c3 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -2,6 +2,7 @@ pub mod bank_forks_utils; pub mod block_error; #[macro_use] pub mod blockstore; +pub mod ancestor_iterator; pub mod blockstore_db; pub mod blockstore_meta; pub mod blockstore_processor;