Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Report correct transaction_count after squash #3000

Merged
merged 2 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,7 @@ impl AccountsDB {
fn remove_parents(&self, fork: Fork) -> Vec<Fork> {
let mut info = self.fork_info.write().unwrap();
let fork_info = info.get_mut(&fork).unwrap();
let parents = fork_info.parents.split_off(0);
info.retain(|&f, _| !parents.contains(&f));
parents
fork_info.parents.split_off(0)
}

fn is_squashed(&self, fork: Fork) -> bool {
Expand Down
7 changes: 7 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,10 +1418,14 @@ mod tests {
0,
);
assert_eq!(parent.process_transaction(&tx_move_mint_to_1), Ok(()));
assert_eq!(parent.transaction_count(), 1);

let bank = Bank::new_from_parent(&parent);
assert_eq!(bank.transaction_count(), 0);
let tx_move_1_to_2 =
SystemTransaction::new_move(&key1, key2.pubkey(), 1, genesis_block.last_id(), 0);
assert_eq!(bank.process_transaction(&tx_move_1_to_2), Ok(()));
assert_eq!(bank.transaction_count(), 1);
assert_eq!(
parent.get_signature_status(&tx_move_1_to_2.signatures[0]),
None
Expand All @@ -1443,6 +1447,9 @@ mod tests {

// works iteration 0, no-ops on iteration 1 and 2
bank.squash();

assert_eq!(parent.transaction_count(), 1);
assert_eq!(bank.transaction_count(), 2);
}
}

Expand Down