remove redundant internal functions (#29035)
remove redundant _internal functions
This commit is contained in:
parent
fd3b5d08d7
commit
0809a4df78
|
@ -160,22 +160,8 @@ impl CostTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn would_fit(&self, tx_cost: &TransactionCost) -> Result<(), CostTrackerError> {
|
fn would_fit(&self, tx_cost: &TransactionCost) -> Result<(), CostTrackerError> {
|
||||||
self.would_fit_internal(
|
let cost: u64 = tx_cost.sum();
|
||||||
tx_cost.writable_accounts.iter(),
|
let vote_cost = if tx_cost.is_simple_vote { cost } else { 0 };
|
||||||
tx_cost.sum(),
|
|
||||||
tx_cost.is_simple_vote,
|
|
||||||
tx_cost.account_data_size,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn would_fit_internal<'a>(
|
|
||||||
&self,
|
|
||||||
write_lock_accounts: impl Iterator<Item = &'a Pubkey>,
|
|
||||||
cost: u64,
|
|
||||||
is_vote: bool,
|
|
||||||
account_data_size: u64,
|
|
||||||
) -> Result<(), CostTrackerError> {
|
|
||||||
let vote_cost = if is_vote { cost } else { 0 };
|
|
||||||
|
|
||||||
// check against the total package cost
|
// check against the total package cost
|
||||||
if self.block_cost.saturating_add(cost) > self.block_cost_limit {
|
if self.block_cost.saturating_add(cost) > self.block_cost_limit {
|
||||||
|
@ -194,7 +180,9 @@ impl CostTracker {
|
||||||
|
|
||||||
// NOTE: Check if the total accounts data size is exceeded *before* the block accounts data
|
// NOTE: Check if the total accounts data size is exceeded *before* the block accounts data
|
||||||
// size. This way, transactions are not unnecessarily retried.
|
// size. This way, transactions are not unnecessarily retried.
|
||||||
let account_data_size = self.account_data_size.saturating_add(account_data_size);
|
let account_data_size = self
|
||||||
|
.account_data_size
|
||||||
|
.saturating_add(tx_cost.account_data_size);
|
||||||
if let Some(account_data_size_limit) = self.account_data_size_limit {
|
if let Some(account_data_size_limit) = self.account_data_size_limit {
|
||||||
if account_data_size > account_data_size_limit {
|
if account_data_size > account_data_size_limit {
|
||||||
return Err(CostTrackerError::WouldExceedAccountDataTotalLimit);
|
return Err(CostTrackerError::WouldExceedAccountDataTotalLimit);
|
||||||
|
@ -206,7 +194,7 @@ impl CostTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check each account against account_cost_limit,
|
// check each account against account_cost_limit,
|
||||||
for account_key in write_lock_accounts {
|
for account_key in tx_cost.writable_accounts.iter() {
|
||||||
match self.cost_by_writable_accounts.get(account_key) {
|
match self.cost_by_writable_accounts.get(account_key) {
|
||||||
Some(chained_cost) => {
|
Some(chained_cost) => {
|
||||||
if chained_cost.saturating_add(cost) > self.account_cost_limit {
|
if chained_cost.saturating_add(cost) > self.account_cost_limit {
|
||||||
|
@ -223,23 +211,8 @@ impl CostTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_transaction_cost(&mut self, tx_cost: &TransactionCost) {
|
fn add_transaction_cost(&mut self, tx_cost: &TransactionCost) {
|
||||||
self.add_transaction_cost_internal(
|
self.add_transaction_execution_cost(tx_cost, tx_cost.sum());
|
||||||
tx_cost.writable_accounts.iter(),
|
saturating_add_assign!(self.account_data_size, tx_cost.account_data_size);
|
||||||
tx_cost.sum(),
|
|
||||||
tx_cost.is_simple_vote,
|
|
||||||
tx_cost.account_data_size,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_transaction_cost_internal<'a>(
|
|
||||||
&mut self,
|
|
||||||
write_lock_accounts: impl Iterator<Item = &'a Pubkey>,
|
|
||||||
cost: u64,
|
|
||||||
is_vote: bool,
|
|
||||||
account_data_size: u64,
|
|
||||||
) {
|
|
||||||
self.add_transaction_execution_cost_internal(write_lock_accounts, is_vote, cost);
|
|
||||||
saturating_add_assign!(self.account_data_size, account_data_size);
|
|
||||||
saturating_add_assign!(self.transaction_count, 1);
|
saturating_add_assign!(self.transaction_count, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,20 +227,7 @@ impl CostTracker {
|
||||||
|
|
||||||
/// Apply additional actual execution units to cost_tracker
|
/// Apply additional actual execution units to cost_tracker
|
||||||
fn add_transaction_execution_cost(&mut self, tx_cost: &TransactionCost, adjustment: u64) {
|
fn add_transaction_execution_cost(&mut self, tx_cost: &TransactionCost, adjustment: u64) {
|
||||||
self.add_transaction_execution_cost_internal(
|
for account_key in tx_cost.writable_accounts.iter() {
|
||||||
tx_cost.writable_accounts.iter(),
|
|
||||||
tx_cost.is_simple_vote,
|
|
||||||
adjustment,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_transaction_execution_cost_internal<'a>(
|
|
||||||
&mut self,
|
|
||||||
write_lock_accounts: impl Iterator<Item = &'a Pubkey>,
|
|
||||||
is_vote: bool,
|
|
||||||
adjustment: u64,
|
|
||||||
) {
|
|
||||||
for account_key in write_lock_accounts {
|
|
||||||
let account_cost = self
|
let account_cost = self
|
||||||
.cost_by_writable_accounts
|
.cost_by_writable_accounts
|
||||||
.entry(*account_key)
|
.entry(*account_key)
|
||||||
|
@ -275,7 +235,7 @@ impl CostTracker {
|
||||||
*account_cost = account_cost.saturating_add(adjustment);
|
*account_cost = account_cost.saturating_add(adjustment);
|
||||||
}
|
}
|
||||||
self.block_cost = self.block_cost.saturating_add(adjustment);
|
self.block_cost = self.block_cost.saturating_add(adjustment);
|
||||||
if is_vote {
|
if tx_cost.is_simple_vote {
|
||||||
self.vote_cost = self.vote_cost.saturating_add(adjustment);
|
self.vote_cost = self.vote_cost.saturating_add(adjustment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue