Skip to content

Commit 2f2cb53

Browse files
committed
chore: Apply Clippy lint redundant_pattern_matching
1 parent 189d6ab commit 2f2cb53

File tree

11 files changed

+18
-18
lines changed

11 files changed

+18
-18
lines changed

stackslib/src/burnchains/db.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,10 @@ impl BurnchainDB {
11931193
let ops: Vec<BlockstackOperationType> =
11941194
query_rows(&self.conn, qry, args).expect("FATAL: burnchain DB query error");
11951195
for op in ops {
1196-
if let Some(_) = indexer
1196+
if indexer
11971197
.find_burnchain_header_height(&op.burn_header_hash())
11981198
.expect("FATAL: burnchain DB query error")
1199+
.is_some()
11991200
{
12001201
// this is the op on the canonical fork
12011202
return Some(op);

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ impl NakamotoChainState {
24762476
) -> Result<bool, ChainstateError> {
24772477
test_debug!("Consider Nakamoto block {}", &block.block_id());
24782478
// do nothing if we already have this block
2479-
if let Some(_) = Self::get_block_header(headers_conn, &block.header.block_id())? {
2479+
if Self::get_block_header(headers_conn, &block.header.block_id())?.is_some() {
24802480
debug!("Already have block {}", &block.header.block_id());
24812481
return Ok(false);
24822482
}

stackslib/src/chainstate/stacks/boot/contract_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl BurnStateDB for TestSimBurnStateDB {
486486
height: u32,
487487
sortition_id: &SortitionId,
488488
) -> Option<(Vec<TupleData>, u128)> {
489-
if let Some(_) = self.get_burn_header_hash(height, sortition_id) {
489+
if self.get_burn_header_hash(height, sortition_id).is_some() {
490490
let first_block = self.get_burn_start_height();
491491
let prepare_len = self.get_pox_prepare_length();
492492
let rc_len = self.get_pox_reward_cycle_length();

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5147,7 +5147,7 @@ impl StacksChainState {
51475147
) {
51485148
Ok(miner_rewards_opt) => miner_rewards_opt,
51495149
Err(e) => {
5150-
if let Some(_) = miner_id_opt {
5150+
if miner_id_opt.is_some() {
51515151
return Err(e);
51525152
} else {
51535153
let msg = format!("Failed to load miner rewards: {:?}", &e);

stackslib/src/chainstate/stacks/db/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,10 +1839,7 @@ impl StacksChainState {
18391839
let nakamoto_staging_blocks_conn =
18401840
StacksChainState::open_nakamoto_staging_blocks(&nakamoto_staging_blocks_path, true)?;
18411841

1842-
let init_required = match fs::metadata(&clarity_state_index_marf) {
1843-
Ok(_) => false,
1844-
Err(_) => true,
1845-
};
1842+
let init_required = fs::metadata(&clarity_state_index_marf).is_err();
18461843

18471844
let state_index = StacksChainState::open_db(mainnet, chain_id, &header_index_root)?;
18481845

stackslib/src/chainstate/stacks/index/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl TrieFile {
213213
let mut set_sqlite_tmpdir = false;
214214
let mut old_tmpdir_opt = None;
215215
if let Some(parent_path) = Path::new(db_path).parent() {
216-
if let Err(_) = env::var("SQLITE_TMPDIR") {
216+
if env::var("SQLITE_TMPDIR").is_err() {
217217
debug!(
218218
"Sqlite will store temporary migration state in '{}'",
219219
parent_path.display()

stackslib/src/chainstate/stacks/index/test/marf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2190,7 +2190,7 @@ fn test_marf_begin_from_sentinel_twice() {
21902190
#[test]
21912191
fn test_marf_unconfirmed() {
21922192
let marf_path = "/tmp/test_marf_unconfirmed";
2193-
if let Ok(_) = std::fs::metadata(marf_path) {
2193+
if std::fs::metadata(marf_path).is_ok() {
21942194
std::fs::remove_file(marf_path).unwrap();
21952195
}
21962196
let marf_opts = MARFOpenOpts::default();

stackslib/src/clarity_cli.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl HeadersDB for CLIHeadersDB {
645645
) -> Option<BurnchainHeaderHash> {
646646
// mock it
647647
let conn = self.conn();
648-
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
648+
if get_cli_block_height(&conn, id_bhh).is_some() {
649649
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
650650
Some(BurnchainHeaderHash(hash_bytes.0))
651651
} else {
@@ -660,7 +660,7 @@ impl HeadersDB for CLIHeadersDB {
660660
) -> Option<ConsensusHash> {
661661
// mock it
662662
let conn = self.conn();
663-
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
663+
if get_cli_block_height(&conn, id_bhh).is_some() {
664664
let hash_bytes = Hash160::from_data(&id_bhh.0);
665665
Some(ConsensusHash(hash_bytes.0))
666666
} else {
@@ -674,7 +674,7 @@ impl HeadersDB for CLIHeadersDB {
674674
_epoch: &StacksEpochId,
675675
) -> Option<VRFSeed> {
676676
let conn = self.conn();
677-
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
677+
if get_cli_block_height(&conn, id_bhh).is_some() {
678678
// mock it, but make it unique
679679
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
680680
let hash_bytes_2 = Sha512Trunc256Sum::from_data(&hash_bytes.0);
@@ -690,7 +690,7 @@ impl HeadersDB for CLIHeadersDB {
690690
_epoch: &StacksEpochId,
691691
) -> Option<BlockHeaderHash> {
692692
let conn = self.conn();
693-
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
693+
if get_cli_block_height(&conn, id_bhh).is_some() {
694694
// mock it, but make it unique
695695
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
696696
let hash_bytes_2 = Sha512Trunc256Sum::from_data(&hash_bytes.0);

stackslib/src/clarity_vm/database/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,13 +737,15 @@ fn get_first_block_in_tenure<GTS: GetTenureStartId>(
737737
}
738738
}
739739
None => {
740-
if let Some(_) = get_stacks_header_column_from_table(
740+
if get_stacks_header_column_from_table(
741741
conn.conn(),
742742
id_bhh,
743743
"consensus_hash",
744744
&|r| ConsensusHash::from_row(r).expect("FATAL: malformed consensus_hash"),
745745
false,
746-
) {
746+
)
747+
.is_some()
748+
{
747749
return id_bhh.clone().into();
748750
} else {
749751
get_stacks_header_column_from_table(

stackslib/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ check if the associated microblocks can be downloaded
15231523
while next_arrival < stacks_blocks_arrival_order.len()
15241524
&& known_stacks_blocks.contains(&stacks_block_id)
15251525
{
1526-
if let Some(_) = stacks_blocks_available.get(&stacks_block_id) {
1526+
if stacks_blocks_available.get(&stacks_block_id).is_some() {
15271527
// load up the block
15281528
let stacks_block_opt = StacksChainState::load_block(
15291529
&old_chainstate.blocks_path,

0 commit comments

Comments
 (0)