separate account locks validation from creating the locks (#28292)
This commit is contained in:
parent
50985f79a1
commit
3781c0668f
|
@ -199,13 +199,8 @@ impl SanitizedTransaction {
|
|||
&self,
|
||||
tx_account_lock_limit: usize,
|
||||
) -> Result<TransactionAccountLocks> {
|
||||
if self.message.has_duplicates() {
|
||||
Err(TransactionError::AccountLoadedTwice)
|
||||
} else if self.message.account_keys().len() > tx_account_lock_limit {
|
||||
Err(TransactionError::TooManyAccountLocks)
|
||||
} else {
|
||||
Ok(self.get_account_locks_unchecked())
|
||||
}
|
||||
Self::validate_account_locks(self.message(), tx_account_lock_limit)?;
|
||||
Ok(self.get_account_locks_unchecked())
|
||||
}
|
||||
|
||||
/// Return the list of accounts that must be locked during processing this transaction.
|
||||
|
@ -281,4 +276,18 @@ impl SanitizedTransaction {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Validate a transaction message against locked accounts
|
||||
fn validate_account_locks(
|
||||
message: &SanitizedMessage,
|
||||
tx_account_lock_limit: usize,
|
||||
) -> Result<()> {
|
||||
if message.has_duplicates() {
|
||||
Err(TransactionError::AccountLoadedTwice)
|
||||
} else if message.account_keys().len() > tx_account_lock_limit {
|
||||
Err(TransactionError::TooManyAccountLocks)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue