Skip to content

Commit

Permalink
style: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Dec 18, 2024
1 parent c24c2ad commit 07cf97f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions stackslib/src/chainstate/stacks/tests/block_construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5163,20 +5163,20 @@ fn mempool_walk_test_next_nonce_with_highest_fee_rate_strategy() {
//
// tuple shape: (origin_address_index, origin_nonce, sponsor_address_index, sponsor_nonce, fee_rate)
let test_vectors = vec![
(0, 0, 0, 0, 100.0), // Old origin nonce - ignored
(0, 1, 0, 1, 200.0), // Old origin nonce - ignored
(0, 0, 0, 0, 100.0), // Old origin nonce - ignored
(0, 1, 0, 1, 200.0), // Old origin nonce - ignored
(0, 2, 0, 2, 300.0),
(0, 3, 0, 3, 400.0),
(0, 4, 3, 0, 500.0), // Nonce 0 for address 3 is not in the table but will be valid on MARF
(1, 0, 1, 0, 400.0), // Old origin nonce - ignored
(0, 4, 3, 0, 500.0), // Nonce 0 for address 3 is not in the table but will be valid on MARF
(1, 0, 1, 0, 400.0), // Old origin nonce - ignored
(1, 1, 3, 1, 600.0),
(1, 2, 3, 2, 700.0),
(1, 3, 3, 3, 800.0),
(1, 4, 1, 4, 1200.0),
(2, 3, 2, 3, 9000.0), // Old origin nonce - ignored
(2, 4, 2, 4, 9000.0), // Old origin nonce - ignored
(2, 5, 2, 5, 9000.0), // Old origin nonce - ignored
(2, 6, 4, 0, 900.0), // Old sponsor nonce - ignored
(2, 6, 4, 0, 900.0), // Old sponsor nonce - ignored
(2, 6, 4, 1, 1000.0),
(2, 7, 4, 2, 800.0),
(2, 8, 2, 8, 1000.0),
Expand Down
16 changes: 10 additions & 6 deletions stackslib/src/core/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ impl MemPoolDB {
LEFT JOIN nonces AS no ON m.origin_address = no.address
LEFT JOIN nonces AS ns ON m.sponsor_address = ns.address
WHERE (no.address IS NULL OR m.origin_nonce = no.nonce)
AND (ns.address IS NULL OR m.sponsor_nonce = ns.nonce)
AND (ns.address IS NULL OR m.sponsor_nonce = ns.nonce)
),
address_nonce_ranked AS (
SELECT *,
Expand Down Expand Up @@ -1808,8 +1808,8 @@ impl MemPoolDB {
// When the retry list is empty, read from the mempool db depending on the configured miner strategy
match settings.strategy {
MemPoolWalkStrategy::GlobalFeeRate => {
let start_with_no_estimate =
tx_consideration_sampler.sample(&mut rng) < settings.consider_no_estimate_tx_prob;
let start_with_no_estimate = tx_consideration_sampler.sample(&mut rng)
< settings.consider_no_estimate_tx_prob;
// randomly select from either the null fee-rate transactions or those with fee-rate estimates.
let opt_tx = if start_with_no_estimate {
null_iterator
Expand All @@ -1819,11 +1819,15 @@ impl MemPoolDB {
fee_iterator.next().map_err(|err| Error::SqliteError(err))?
};
match opt_tx {
Some(row) => (MemPoolTxInfoPartial::from_row(row)?, start_with_no_estimate),
Some(row) => {
(MemPoolTxInfoPartial::from_row(row)?, start_with_no_estimate)
}
None => {
// If the selected iterator is empty, check the other
match if start_with_no_estimate {
fee_iterator.next().map_err(|err| Error::SqliteError(err))?
fee_iterator
.next()
.map_err(|err| Error::SqliteError(err))?
} else {
null_iterator
.next()
Expand Down Expand Up @@ -1852,7 +1856,7 @@ impl MemPoolDB {
let tx = MemPoolTxInfoPartial::from_row(row)?;
let update_estimate = tx.fee_rate.is_none();
(tx, update_estimate)
},
}
None => {
debug!("No more transactions to consider in mempool");
break MempoolIterationStopReason::NoMoreCandidates;
Expand Down

0 comments on commit 07cf97f

Please sign in to comment.