implements copy-on-write for vote-accounts (#19362)
Bank::vote_accounts redundantly clones vote-accounts HashMap even though an immutable reference will suffice: https://github.com/solana-labs/solana/blob/95c998a19/runtime/src/bank.rs#L5174-L5186 This commit implements copy-on-write semantics for vote-accounts by wrapping the underlying HashMap in Arc<...>.
This commit is contained in:
@@ -183,8 +183,8 @@ impl AggregateCommitmentService {
|
||||
|
||||
let mut commitment = HashMap::new();
|
||||
let mut rooted_stake: Vec<(Slot, u64)> = Vec::new();
|
||||
for (_, (lamports, account)) in bank.vote_accounts().into_iter() {
|
||||
if lamports == 0 {
|
||||
for (lamports, account) in bank.vote_accounts().values() {
|
||||
if *lamports == 0 {
|
||||
continue;
|
||||
}
|
||||
if let Ok(vote_state) = account.vote_state().as_ref() {
|
||||
@@ -193,7 +193,7 @@ impl AggregateCommitmentService {
|
||||
&mut rooted_stake,
|
||||
vote_state,
|
||||
ancestors,
|
||||
lamports,
|
||||
*lamports,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user