Skip to content

Commit

Permalink
chore: Apply Clippy lint redundant_pattern_matching
Browse files Browse the repository at this point in the history
  • Loading branch information
jbencin committed Jan 23, 2025
1 parent 189d6ab commit 2f2cb53
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
3 changes: 2 additions & 1 deletion stackslib/src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,10 @@ impl BurnchainDB {
let ops: Vec<BlockstackOperationType> =
query_rows(&self.conn, qry, args).expect("FATAL: burnchain DB query error");
for op in ops {
if let Some(_) = indexer
if indexer
.find_burnchain_header_height(&op.burn_header_hash())
.expect("FATAL: burnchain DB query error")
.is_some()
{
// this is the op on the canonical fork
return Some(op);
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/nakamoto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ impl NakamotoChainState {
) -> Result<bool, ChainstateError> {
test_debug!("Consider Nakamoto block {}", &block.block_id());
// do nothing if we already have this block
if let Some(_) = Self::get_block_header(headers_conn, &block.header.block_id())? {
if Self::get_block_header(headers_conn, &block.header.block_id())?.is_some() {
debug!("Already have block {}", &block.header.block_id());
return Ok(false);
}
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/boot/contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ impl BurnStateDB for TestSimBurnStateDB {
height: u32,
sortition_id: &SortitionId,
) -> Option<(Vec<TupleData>, u128)> {
if let Some(_) = self.get_burn_header_hash(height, sortition_id) {
if self.get_burn_header_hash(height, sortition_id).is_some() {
let first_block = self.get_burn_start_height();
let prepare_len = self.get_pox_prepare_length();
let rc_len = self.get_pox_reward_cycle_length();
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/db/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5147,7 +5147,7 @@ impl StacksChainState {
) {
Ok(miner_rewards_opt) => miner_rewards_opt,
Err(e) => {
if let Some(_) = miner_id_opt {
if miner_id_opt.is_some() {
return Err(e);
} else {
let msg = format!("Failed to load miner rewards: {:?}", &e);
Expand Down
5 changes: 1 addition & 4 deletions stackslib/src/chainstate/stacks/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,7 @@ impl StacksChainState {
let nakamoto_staging_blocks_conn =
StacksChainState::open_nakamoto_staging_blocks(&nakamoto_staging_blocks_path, true)?;

let init_required = match fs::metadata(&clarity_state_index_marf) {
Ok(_) => false,
Err(_) => true,
};
let init_required = fs::metadata(&clarity_state_index_marf).is_err();

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

Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/index/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl TrieFile {
let mut set_sqlite_tmpdir = false;
let mut old_tmpdir_opt = None;
if let Some(parent_path) = Path::new(db_path).parent() {
if let Err(_) = env::var("SQLITE_TMPDIR") {
if env::var("SQLITE_TMPDIR").is_err() {
debug!(
"Sqlite will store temporary migration state in '{}'",
parent_path.display()
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/index/test/marf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ fn test_marf_begin_from_sentinel_twice() {
#[test]
fn test_marf_unconfirmed() {
let marf_path = "/tmp/test_marf_unconfirmed";
if let Ok(_) = std::fs::metadata(marf_path) {
if std::fs::metadata(marf_path).is_ok() {
std::fs::remove_file(marf_path).unwrap();
}
let marf_opts = MARFOpenOpts::default();
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/clarity_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ impl HeadersDB for CLIHeadersDB {
) -> Option<BurnchainHeaderHash> {
// mock it
let conn = self.conn();
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
if get_cli_block_height(&conn, id_bhh).is_some() {
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
Some(BurnchainHeaderHash(hash_bytes.0))
} else {
Expand All @@ -660,7 +660,7 @@ impl HeadersDB for CLIHeadersDB {
) -> Option<ConsensusHash> {
// mock it
let conn = self.conn();
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
if get_cli_block_height(&conn, id_bhh).is_some() {
let hash_bytes = Hash160::from_data(&id_bhh.0);
Some(ConsensusHash(hash_bytes.0))
} else {
Expand All @@ -674,7 +674,7 @@ impl HeadersDB for CLIHeadersDB {
_epoch: &StacksEpochId,
) -> Option<VRFSeed> {
let conn = self.conn();
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
if get_cli_block_height(&conn, id_bhh).is_some() {
// mock it, but make it unique
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
let hash_bytes_2 = Sha512Trunc256Sum::from_data(&hash_bytes.0);
Expand All @@ -690,7 +690,7 @@ impl HeadersDB for CLIHeadersDB {
_epoch: &StacksEpochId,
) -> Option<BlockHeaderHash> {
let conn = self.conn();
if let Some(_) = get_cli_block_height(&conn, id_bhh) {
if get_cli_block_height(&conn, id_bhh).is_some() {
// mock it, but make it unique
let hash_bytes = Sha512Trunc256Sum::from_data(&id_bhh.0);
let hash_bytes_2 = Sha512Trunc256Sum::from_data(&hash_bytes.0);
Expand Down
6 changes: 4 additions & 2 deletions stackslib/src/clarity_vm/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,15 @@ fn get_first_block_in_tenure<GTS: GetTenureStartId>(
}
}
None => {
if let Some(_) = get_stacks_header_column_from_table(
if get_stacks_header_column_from_table(
conn.conn(),
id_bhh,
"consensus_hash",
&|r| ConsensusHash::from_row(r).expect("FATAL: malformed consensus_hash"),
false,
) {
)
.is_some()
{
return id_bhh.clone().into();
} else {
get_stacks_header_column_from_table(
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ check if the associated microblocks can be downloaded
while next_arrival < stacks_blocks_arrival_order.len()
&& known_stacks_blocks.contains(&stacks_block_id)
{
if let Some(_) = stacks_blocks_available.get(&stacks_block_id) {
if stacks_blocks_available.get(&stacks_block_id).is_some() {
// load up the block
let stacks_block_opt = StacksChainState::load_block(
&old_chainstate.blocks_path,
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/tests/inv/nakamoto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn peer_get_nakamoto_invs<'a>(

loop {
peer.step_with_ibd(false).unwrap();
if let Ok(..) = shutdown_recv.try_recv() {
if shutdown_recv.try_recv().is_ok() {
break;
}
}
Expand Down

0 comments on commit 2f2cb53

Please sign in to comment.