Add ancestor iterator to lib.rs (#10813) (#10817)

Co-authored-by: Carl <carl@solana.com>
(cherry picked from commit 0fde0d7379)

Co-authored-by: carllin <wumu727@gmail.com>
This commit is contained in:
mergify[bot]
2020-06-26 01:02:51 +00:00
committed by GitHub
parent d130adf582
commit f4d70e78b6
2 changed files with 3 additions and 4 deletions

View File

@ -25,7 +25,7 @@ impl<'a> Iterator for AncestorIterator<'a> {
type Item = Slot;
fn next(&mut self) -> Option<Self::Item> {
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::<Vec<Slot>>()
.is_empty());
assert!(AncestorIterator::new(0, &blockstore).next().is_none());
assert_eq!(
AncestorIterator::new(4, &blockstore).collect::<Vec<Slot>>(),
vec![1, 0]

View File

@ -3,6 +3,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;