Limiting the number of heavy accounts in the block

This commit is contained in:
godmodegalactus 2024-01-29 12:03:28 +01:00
parent 295277fbf0
commit 92bf5f84d2
No known key found for this signature in database
GPG Key ID: 22DA4A30887FDA3C
1 changed files with 17 additions and 0 deletions

View File

@ -704,8 +704,25 @@ impl PostgresSession {
],
);
pin_mut!(writer);
const LIMIT: usize = 100;
let mut nb_read_accounts : usize = 0;
let mut nb_write_accounts : usize = 0;
for account_usage in block_info.heavily_locked_accounts.iter() {
if nb_read_accounts >= LIMIT && nb_write_accounts >= LIMIT {
break;
}
let is_writable = account_usage.is_write_locked;
if is_writable {
if nb_write_accounts >= LIMIT {
continue;
}
nb_write_accounts += 1;
} else {
if nb_read_accounts >= LIMIT {
continue;
}
nb_read_accounts += 1;
}
let mut args: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(6);
let pf_json = serde_json::to_string(&account_usage.prioritization_fee_data)?;
args.push(&account_usage.key);