Skip to content

Commit

Permalink
prioritization fee cache: remove not required locks (solana-labs#272)
Browse files Browse the repository at this point in the history
* prioritization fee cache: remove not required locks

* update HashMap to BTreeMap

* fix clippy

* add type alias

* apply name change

* check that cache is empty

* remove sleep

* remove outdated commented tests

* fmt

* extra warn
  • Loading branch information
fanatid committed Mar 26, 2024
1 parent 7c8a287 commit 80d3200
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 215 deletions.
12 changes: 6 additions & 6 deletions runtime/src/prioritization_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl PrioritizationFee {
pub fn update(
&mut self,
transaction_fee: u64,
writable_accounts: &[Pubkey],
writable_accounts: Vec<Pubkey>,
) -> Result<(), PrioritizationFeeError> {
let (_, update_time) = measure!(
{
Expand All @@ -177,9 +177,9 @@ impl PrioritizationFee {
self.min_transaction_fee = transaction_fee;
}

for write_account in writable_accounts.iter() {
for write_account in writable_accounts {
self.min_writable_account_fees
.entry(*write_account)
.entry(write_account)
.and_modify(|write_lock_fee| {
*write_lock_fee = std::cmp::min(*write_lock_fee, transaction_fee)
})
Expand Down Expand Up @@ -284,7 +284,7 @@ mod tests {
// [5, a, b ] --> [5, 5, 5, nil ]
{
assert!(prioritization_fee
.update(5, &[write_account_a, write_account_b])
.update(5, vec![write_account_a, write_account_b])
.is_ok());
assert_eq!(5, prioritization_fee.get_min_transaction_fee().unwrap());
assert_eq!(
Expand All @@ -310,7 +310,7 @@ mod tests {
// [9, b, c ] --> [5, 5, 5, 9 ]
{
assert!(prioritization_fee
.update(9, &[write_account_b, write_account_c])
.update(9, vec![write_account_b, write_account_c])
.is_ok());
assert_eq!(5, prioritization_fee.get_min_transaction_fee().unwrap());
assert_eq!(
Expand Down Expand Up @@ -339,7 +339,7 @@ mod tests {
// [2, a, c ] --> [2, 2, 5, 2 ]
{
assert!(prioritization_fee
.update(2, &[write_account_a, write_account_c])
.update(2, vec![write_account_a, write_account_c])
.is_ok());
assert_eq!(2, prioritization_fee.get_min_transaction_fee().unwrap());
assert_eq!(
Expand Down
Loading

0 comments on commit 80d3200

Please sign in to comment.