Skip to content

Commit

Permalink
style: error transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Dec 18, 2024
1 parent 07cf97f commit 0b0b821
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions stackslib/src/chainstate/stacks/tests/block_construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5163,12 +5163,12 @@ 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),
Expand Down
22 changes: 11 additions & 11 deletions stackslib/src/core/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1720,10 +1720,10 @@ impl MemPoolDB {
let mut query_stmt_null = self
.db
.prepare(&sql)
.map_err(|err| Error::SqliteError(err))?;
.map_err(Error::SqliteError)?;
let mut null_iterator = query_stmt_null
.query(NO_PARAMS)
.map_err(|err| Error::SqliteError(err))?;
.map_err(Error::SqliteError)?;
let sql = "
SELECT txid, origin_nonce, origin_address, sponsor_nonce, sponsor_address, fee_rate
FROM mempool
Expand All @@ -1733,10 +1733,10 @@ impl MemPoolDB {
let mut query_stmt_fee = self
.db
.prepare(&sql)
.map_err(|err| Error::SqliteError(err))?;
.map_err(Error::SqliteError)?;
let mut fee_iterator = query_stmt_fee
.query(NO_PARAMS)
.map_err(|err| Error::SqliteError(err))?;
.map_err(Error::SqliteError)?;

// == Query for `NextNonceWithHighestFeeRate` mempool walk strategy
//
Expand Down Expand Up @@ -1789,7 +1789,7 @@ impl MemPoolDB {
let mut query_stmt_nonce_rank = self
.db
.prepare(&sql)
.map_err(|err| Error::SqliteError(err))?;
.map_err(Error::SqliteError)?;

let stop_reason = loop {
if start_time.elapsed().as_millis() > settings.max_walk_time_ms as u128 {
Expand All @@ -1814,9 +1814,9 @@ impl MemPoolDB {
let opt_tx = if start_with_no_estimate {
null_iterator
.next()
.map_err(|err| Error::SqliteError(err))?
.map_err(Error::SqliteError)?
} else {
fee_iterator.next().map_err(|err| Error::SqliteError(err))?
fee_iterator.next().map_err(Error::SqliteError)?
};
match opt_tx {
Some(row) => {
Expand All @@ -1827,11 +1827,11 @@ impl MemPoolDB {
match if start_with_no_estimate {
fee_iterator
.next()
.map_err(|err| Error::SqliteError(err))?
.map_err(Error::SqliteError)?
} else {
null_iterator
.next()
.map_err(|err| Error::SqliteError(err))?
.map_err(Error::SqliteError)?
} {
Some(row) => (
MemPoolTxInfoPartial::from_row(row)?,
Expand All @@ -1848,9 +1848,9 @@ impl MemPoolDB {
MemPoolWalkStrategy::NextNonceWithHighestFeeRate => {
match query_stmt_nonce_rank
.query(NO_PARAMS)
.map_err(|err| Error::SqliteError(err))?
.map_err(Error::SqliteError)?
.next()
.map_err(|err| Error::SqliteError(err))?
.map_err(Error::SqliteError)?
{
Some(row) => {
let tx = MemPoolTxInfoPartial::from_row(row)?;
Expand Down

0 comments on commit 0b0b821

Please sign in to comment.