Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move mempool fee check #5777

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions base_layer/core/src/mempool/mempool_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ impl MempoolStorage {
.map(|k| k.excess_sig.get_signature().to_hex())
.unwrap_or_else(|| "None?!".into());
let timer = Instant::now();
// This check is almost free, so lets check this before we do any expensive validation.
if tx.body.get_total_fee().as_u64() < self.unconfirmed_pool.config.min_fee {
debug!(target: LOG_TARGET, "Tx: ({}) fee too low, rejecting",tx_id);
return Ok(TxStorageResponse::NotStoredFeeTooLow);
}
debug!(target: LOG_TARGET, "Inserting tx into mempool: {}", tx_id);
match self.validator.validate(&tx) {
Ok(()) => {
Expand All @@ -88,10 +93,6 @@ impl MempoolStorage {
);
let timer = Instant::now();
SWvheerden marked this conversation as resolved.
Show resolved Hide resolved
let weight = self.get_transaction_weighting();
if tx.body.get_total_fee().as_u64() < self.unconfirmed_pool.config.min_fee {
debug!(target: LOG_TARGET, "Tx: ({}) fee too low, rejecting",tx_id);
return Ok(TxStorageResponse::NotStoredFeeTooLow);
}
self.unconfirmed_pool.insert(tx, None, &weight)?;
debug!(
target: LOG_TARGET,
Expand All @@ -104,10 +105,6 @@ impl MempoolStorage {
Err(ValidationError::UnknownInputs(dependent_outputs)) => {
if self.unconfirmed_pool.contains_all_outputs(&dependent_outputs) {
let weight = self.get_transaction_weighting();
if tx.body.get_total_fee().as_u64() < self.unconfirmed_pool.config.min_fee {
debug!(target: LOG_TARGET, "Tx: ({}) fee too low, rejecting",tx_id);
return Ok(TxStorageResponse::NotStoredFeeTooLow);
}
self.unconfirmed_pool.insert(tx, Some(dependent_outputs), &weight)?;
Ok(TxStorageResponse::UnconfirmedPool)
} else {
Expand Down