Skip to content

Commit 57522f9

Browse files
committed
chore: Misc. style fixes
1 parent c88eea5 commit 57522f9

File tree

4 files changed

+13
-43
lines changed

4 files changed

+13
-43
lines changed

stacks-common/src/types/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,7 @@ impl Address for StacksAddress {
700700
}
701701

702702
fn from_string(s: &str) -> Option<StacksAddress> {
703-
let (version, bytes) = match c32_address_decode(s) {
704-
Ok((v, b)) => (v, b),
705-
Err(_) => {
706-
return None;
707-
}
708-
};
703+
let (version, bytes) = c32_address_decode(s).ok()?;
709704

710705
if bytes.len() != 20 {
711706
return None;

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,8 +2585,7 @@ impl StacksBlockBuilder {
25852585
event_observer: Option<&dyn MemPoolEventDispatcher>,
25862586
burnchain: &Burnchain,
25872587
) -> Result<(StacksBlock, ExecutionCost, u64), Error> {
2588-
if let TransactionPayload::Coinbase(..) = coinbase_tx.payload {
2589-
} else {
2588+
if !matches!(coinbase_tx.payload, TransactionPayload::Coinbase(..)) {
25902589
return Err(Error::MemPoolError(
25912590
"Not a coinbase transaction".to_string(),
25922591
));

stackslib/src/clarity_vm/database/marf.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,8 @@ impl ReadOnlyMarfStore<'_> {
294294
}
295295

296296
pub fn trie_exists_for_block(&mut self, bhh: &StacksBlockId) -> Result<bool, DatabaseError> {
297-
self.marf.with_conn(|conn| match conn.has_block(bhh) {
298-
Ok(res) => Ok(res),
299-
Err(e) => Err(DatabaseError::IndexError(e)),
300-
})
297+
self.marf
298+
.with_conn(|conn| conn.has_block(bhh).map_err(DatabaseError::IndexError))
301299
}
302300
}
303301

stackslib/src/core/mempool.rs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -492,35 +492,25 @@ impl FromStr for MemPoolWalkTxTypes {
492492
type Err = &'static str;
493493
fn from_str(s: &str) -> Result<Self, Self::Err> {
494494
match s {
495-
"TokenTransfer" => {
496-
return Ok(Self::TokenTransfer);
497-
}
498-
"SmartContract" => {
499-
return Ok(Self::SmartContract);
500-
}
501-
"ContractCall" => {
502-
return Ok(Self::ContractCall);
503-
}
504-
_ => {
505-
return Err("Unknown mempool tx walk type");
506-
}
495+
"TokenTransfer" => Ok(Self::TokenTransfer),
496+
"SmartContract" => Ok(Self::SmartContract),
497+
"ContractCall" => Ok(Self::ContractCall),
498+
_ => Err("Unknown mempool tx walk type"),
507499
}
508500
}
509501
}
510502

511503
impl MemPoolWalkTxTypes {
512504
pub fn all() -> HashSet<MemPoolWalkTxTypes> {
513-
[
505+
HashSet::from([
514506
MemPoolWalkTxTypes::TokenTransfer,
515507
MemPoolWalkTxTypes::SmartContract,
516508
MemPoolWalkTxTypes::ContractCall,
517-
]
518-
.into_iter()
519-
.collect()
509+
])
520510
}
521511

522512
pub fn only(selected: &[MemPoolWalkTxTypes]) -> HashSet<MemPoolWalkTxTypes> {
523-
selected.iter().map(|x| x.clone()).collect()
513+
selected.iter().cloned().collect()
524514
}
525515
}
526516

@@ -554,13 +544,7 @@ impl Default for MemPoolWalkSettings {
554544
consider_no_estimate_tx_prob: 5,
555545
nonce_cache_size: 1024 * 1024,
556546
candidate_retry_cache_size: 64 * 1024,
557-
txs_to_consider: [
558-
MemPoolWalkTxTypes::TokenTransfer,
559-
MemPoolWalkTxTypes::SmartContract,
560-
MemPoolWalkTxTypes::ContractCall,
561-
]
562-
.into_iter()
563-
.collect(),
547+
txs_to_consider: MemPoolWalkTxTypes::all(),
564548
filter_origins: HashSet::new(),
565549
tenure_cost_limit_per_block_percentage: None,
566550
}
@@ -573,13 +557,7 @@ impl MemPoolWalkSettings {
573557
consider_no_estimate_tx_prob: 5,
574558
nonce_cache_size: 1024 * 1024,
575559
candidate_retry_cache_size: 64 * 1024,
576-
txs_to_consider: [
577-
MemPoolWalkTxTypes::TokenTransfer,
578-
MemPoolWalkTxTypes::SmartContract,
579-
MemPoolWalkTxTypes::ContractCall,
580-
]
581-
.into_iter()
582-
.collect(),
560+
txs_to_consider: MemPoolWalkTxTypes::all(),
583561
filter_origins: HashSet::new(),
584562
tenure_cost_limit_per_block_percentage: None,
585563
}

0 commit comments

Comments
 (0)