Refactor load_accounts to take a reference to a slice instead of vec (#34919)
This is in preparation for further refactoring of Bank::load_and_execute_transactions in a separate commit.
This commit is contained in:
parent
b11d41a3f7
commit
ef233eaaa7
|
@ -66,7 +66,7 @@ impl NonceFull {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn from_partial(
|
pub fn from_partial(
|
||||||
partial: NoncePartial,
|
partial: &NoncePartial,
|
||||||
message: &SanitizedMessage,
|
message: &SanitizedMessage,
|
||||||
accounts: &[TransactionAccount],
|
accounts: &[TransactionAccount],
|
||||||
rent_debits: &RentDebits,
|
rent_debits: &RentDebits,
|
||||||
|
@ -221,8 +221,8 @@ mod tests {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let full = NonceFull::from_partial(partial.clone(), &message, &accounts, &rent_debits)
|
let full =
|
||||||
.unwrap();
|
NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap();
|
||||||
assert_eq!(*full.address(), nonce_address);
|
assert_eq!(*full.address(), nonce_address);
|
||||||
assert_eq!(*full.account(), rent_collected_nonce_account);
|
assert_eq!(*full.account(), rent_collected_nonce_account);
|
||||||
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
|
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
|
||||||
|
@ -252,8 +252,8 @@ mod tests {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let full = NonceFull::from_partial(partial.clone(), &message, &accounts, &rent_debits)
|
let full =
|
||||||
.unwrap();
|
NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap();
|
||||||
assert_eq!(*full.address(), nonce_address);
|
assert_eq!(*full.address(), nonce_address);
|
||||||
assert_eq!(*full.account(), nonce_account);
|
assert_eq!(*full.account(), nonce_account);
|
||||||
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
|
assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature));
|
||||||
|
@ -264,7 +264,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
let message = new_sanitized_message(&instructions, Some(&nonce_address));
|
let message = new_sanitized_message(&instructions, Some(&nonce_address));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
NonceFull::from_partial(partial, &message, &[], &RentDebits::default())
|
NonceFull::from_partial(&partial, &message, &[], &RentDebits::default())
|
||||||
.unwrap_err(),
|
.unwrap_err(),
|
||||||
TransactionError::AccountNotFound,
|
TransactionError::AccountNotFound,
|
||||||
);
|
);
|
||||||
|
|
|
@ -365,7 +365,7 @@ pub(crate) mod tests {
|
||||||
inner_instructions: None,
|
inner_instructions: None,
|
||||||
durable_nonce_fee: Some(DurableNonceFee::from(
|
durable_nonce_fee: Some(DurableNonceFee::from(
|
||||||
&NonceFull::from_partial(
|
&NonceFull::from_partial(
|
||||||
rollback_partial,
|
&rollback_partial,
|
||||||
&SanitizedMessage::Legacy(LegacyMessage::new(message)),
|
&SanitizedMessage::Legacy(LegacyMessage::new(message)),
|
||||||
&[(pubkey, nonce_account)],
|
&[(pubkey, nonce_account)],
|
||||||
&rent_debits,
|
&rent_debits,
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub(super) fn load_accounts(
|
||||||
accounts_db: &AccountsDb,
|
accounts_db: &AccountsDb,
|
||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
txs: &[SanitizedTransaction],
|
txs: &[SanitizedTransaction],
|
||||||
lock_results: Vec<TransactionCheckResult>,
|
lock_results: &[TransactionCheckResult],
|
||||||
hash_queue: &BlockhashQueue,
|
hash_queue: &BlockhashQueue,
|
||||||
error_counters: &mut TransactionErrorMetrics,
|
error_counters: &mut TransactionErrorMetrics,
|
||||||
rent_collector: &RentCollector,
|
rent_collector: &RentCollector,
|
||||||
|
@ -123,7 +123,7 @@ pub(super) fn load_accounts(
|
||||||
|
|
||||||
(Ok(loaded_transaction), nonce)
|
(Ok(loaded_transaction), nonce)
|
||||||
}
|
}
|
||||||
(_, (Err(e), _nonce)) => (Err(e), None),
|
(_, (Err(e), _nonce)) => (Err(e.clone()), None),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ mod tests {
|
||||||
&accounts.accounts_db,
|
&accounts.accounts_db,
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&[sanitized_tx],
|
&[sanitized_tx],
|
||||||
vec![(Ok(()), None)],
|
&[(Ok(()), None)],
|
||||||
&hash_queue,
|
&hash_queue,
|
||||||
error_counters,
|
error_counters,
|
||||||
rent_collector,
|
rent_collector,
|
||||||
|
@ -1022,7 +1022,7 @@ mod tests {
|
||||||
&accounts.accounts_db,
|
&accounts.accounts_db,
|
||||||
&ancestors,
|
&ancestors,
|
||||||
&[tx],
|
&[tx],
|
||||||
vec![(Ok(()), None)],
|
&[(Ok(()), None)],
|
||||||
&hash_queue,
|
&hash_queue,
|
||||||
&mut error_counters,
|
&mut error_counters,
|
||||||
&rent_collector,
|
&rent_collector,
|
||||||
|
|
|
@ -5179,7 +5179,7 @@ impl Bank {
|
||||||
&self.rc.accounts.accounts_db,
|
&self.rc.accounts.accounts_db,
|
||||||
&self.ancestors,
|
&self.ancestors,
|
||||||
sanitized_txs,
|
sanitized_txs,
|
||||||
check_results,
|
&check_results,
|
||||||
&self.blockhash_queue.read().unwrap(),
|
&self.blockhash_queue.read().unwrap(),
|
||||||
&mut error_counters,
|
&mut error_counters,
|
||||||
&self.rent_collector,
|
&self.rent_collector,
|
||||||
|
|
|
@ -10989,7 +10989,7 @@ fn test_rent_state_list_len() {
|
||||||
&bank.accounts().accounts_db,
|
&bank.accounts().accounts_db,
|
||||||
&bank.ancestors,
|
&bank.ancestors,
|
||||||
&[sanitized_tx.clone()],
|
&[sanitized_tx.clone()],
|
||||||
vec![(Ok(()), None)],
|
&[(Ok(()), None)],
|
||||||
&bank.blockhash_queue.read().unwrap(),
|
&bank.blockhash_queue.read().unwrap(),
|
||||||
&mut error_counters,
|
&mut error_counters,
|
||||||
&bank.rent_collector,
|
&bank.rent_collector,
|
||||||
|
|
Loading…
Reference in New Issue