Avoid cloning Vec<Entry> when calling entries_to_test_shreds() (#22093)

This commit is contained in:
Yueh-Hsuan Chiang
2021-12-24 12:32:43 -08:00
committed by GitHub
parent 2ab4f34c02
commit b89cd8cd1a
9 changed files with 42 additions and 48 deletions

View File

@ -2564,7 +2564,7 @@ mod tests {
poh_recorder.lock().unwrap().set_bank(&bank);
let shreds = entries_to_test_shreds(entries, bank.slot(), 0, true, 0);
let shreds = entries_to_test_shreds(&entries, bank.slot(), 0, true, 0);
blockstore.insert_shreds(shreds, None, false).unwrap();
blockstore.set_roots(std::iter::once(&bank.slot())).unwrap();

View File

@ -302,7 +302,7 @@ pub mod test {
blockhashes.insert(slot, entries.last().unwrap().hash);
let mut shreds = solana_ledger::blockstore::entries_to_test_shreds(
entries.clone(),
&entries,
slot,
parent.unwrap_or(slot),
is_slot_complete,

View File

@ -3389,7 +3389,7 @@ pub mod tests {
), // should cause AccountNotFound error
],
);
entries_to_test_shreds(vec![entry], slot, slot.saturating_sub(1), false, 0)
entries_to_test_shreds(&[entry], slot, slot.saturating_sub(1), false, 0)
});
assert_matches!(
@ -3419,7 +3419,7 @@ pub mod tests {
blockhash,
)],
);
entries_to_test_shreds(vec![entry], slot, slot.saturating_sub(1), false, 0)
entries_to_test_shreds(&[entry], slot, slot.saturating_sub(1), false, 0)
});
if let Err(BlockstoreProcessorError::InvalidBlock(block_error)) = res {
@ -3439,7 +3439,7 @@ pub mod tests {
let too_few_hashes_tick = Entry::new(&blockhash, hashes_per_tick - 1, vec![]);
entries_to_test_shreds(
vec![too_few_hashes_tick],
&[too_few_hashes_tick],
slot,
slot.saturating_sub(1),
false,
@ -3463,7 +3463,7 @@ pub mod tests {
let slot = bank.slot();
let hashes_per_tick = bank.hashes_per_tick().unwrap_or(0);
entries_to_test_shreds(
entry::create_ticks(bank.ticks_per_slot() + 1, hashes_per_tick, blockhash),
&entry::create_ticks(bank.ticks_per_slot() + 1, hashes_per_tick, blockhash),
slot,
slot.saturating_sub(1),
false,
@ -3483,7 +3483,7 @@ pub mod tests {
let slot = bank.slot();
let hashes_per_tick = bank.hashes_per_tick().unwrap_or(0);
entries_to_test_shreds(
entry::create_ticks(bank.ticks_per_slot() - 1, hashes_per_tick, blockhash),
&entry::create_ticks(bank.ticks_per_slot() - 1, hashes_per_tick, blockhash),
slot,
slot.saturating_sub(1),
true,
@ -3505,7 +3505,7 @@ pub mod tests {
let slot = bank.slot();
let hashes_per_tick = bank.hashes_per_tick().unwrap_or(0);
entries_to_test_shreds(
entry::create_ticks(bank.ticks_per_slot(), hashes_per_tick, blockhash),
&entry::create_ticks(bank.ticks_per_slot(), hashes_per_tick, blockhash),
slot,
slot.saturating_sub(1),
false,
@ -3533,7 +3533,7 @@ pub mod tests {
let tx = system_transaction::transfer(funded_keypair, &keypair.pubkey(), 2, blockhash);
let trailing_entry = entry::next_entry(&last_entry_hash, 1, vec![tx]);
entries.push(trailing_entry);
entries_to_test_shreds(entries, slot, slot.saturating_sub(1), true, 0)
entries_to_test_shreds(&entries, slot, slot.saturating_sub(1), true, 0)
});
if let Err(BlockstoreProcessorError::InvalidBlock(block_error)) = res {

View File

@ -1819,7 +1819,7 @@ mod tests {
info!("creating shreds");
let mut last_print = Instant::now();
for i in 1..10 {
let shreds = blockstore::entries_to_test_shreds(entries.clone(), i, i - 1, true, 1);
let shreds = blockstore::entries_to_test_shreds(&entries, i, i - 1, true, 1);
blockstore.insert_shreds(shreds, None, true).unwrap();
if last_print.elapsed().as_millis() > 5000 {
info!("inserted {}", i);