Make set roots an iterator (#18357)

This commit is contained in:
carllin
2021-07-01 20:02:40 -07:00
committed by GitHub
parent d951916d40
commit 0eca92de18
11 changed files with 58 additions and 46 deletions

View File

@ -2639,7 +2639,7 @@ mod tests {
let shreds = entries_to_test_shreds(entries, bank.slot(), 0, true, 0);
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(&[bank.slot()]).unwrap();
blockstore.set_roots(std::iter::once(&bank.slot())).unwrap();
let (transaction_status_sender, transaction_status_receiver) = unbounded();
let transaction_status_service = TransactionStatusService::new(

View File

@ -1336,7 +1336,7 @@ pub fn reconcile_blockstore_roots_with_tower(
"Reconciling slots as root based on tower root: {:?} ({}..{}) ",
new_roots, tower_root, last_blockstore_root
);
blockstore.set_roots(&new_roots)?;
blockstore.set_roots(new_roots.iter())?;
} else {
// This indicates we're in bad state; but still don't panic here.
// That's because we might have a chance of recovering properly with
@ -3176,7 +3176,7 @@ pub mod test {
blockstore.insert_shreds(shreds, None, false).unwrap();
let (shreds, _) = make_slot_entries(4, 1, 42);
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(&[3]).unwrap();
blockstore.set_roots(std::iter::once(&3)).unwrap();
assert!(!blockstore.is_root(0));
assert!(!blockstore.is_root(1));
assert!(blockstore.is_root(3));

View File

@ -316,7 +316,7 @@ mod test {
assert!(optimistic_confirmation_verifier.unchecked_slots.is_empty());
// If we know set the root in blockstore, should return nothing
blockstore.set_roots(&[1, 3]).unwrap();
blockstore.set_roots(vec![1, 3].iter()).unwrap();
optimistic_confirmation_verifier.add_new_optimistic_confirmed_slots(optimistic_slots);
assert!(optimistic_confirmation_verifier
.verify_for_unrooted_optimistic_slots(&bank7, &blockstore)

View File

@ -1348,7 +1348,7 @@ impl ReplayStage {
// get dropped.
leader_schedule_cache.set_root(rooted_banks.last().unwrap());
blockstore
.set_roots(&rooted_slots)
.set_roots(rooted_slots.iter())
.expect("Ledger set roots failed");
let highest_confirmed_root = Some(
block_commitment_cache