Skip to content

Commit 391ebd1

Browse files
authored
clippy: fix cases signaled by unnecessary_unwrap lint (#10265)
* clippy(validator): use if let Some() to access peer_snapshot_hash on bootstrap * clippy(core): use if let Some() instead of unwrap * clippy(cli): fix clippy::unnecessary_unwrap * clippy(transaction-status-client-types): fix clippy::unnecessary_unwrap
1 parent 7ff36d5 commit 391ebd1

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

cli/src/cli.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -870,16 +870,16 @@ pub async fn process_command(config: &CliConfig<'_>) -> ProcessResult {
870870
println_name_value("Commitment:", &config.commitment.commitment.to_string());
871871
}
872872

873-
let rpc_client = if config.rpc_client.is_none() {
873+
let rpc_client = if let Some(rpc_client) = config.rpc_client.as_ref() {
874+
// Primarily for testing
875+
rpc_client.clone()
876+
} else {
874877
Arc::new(RpcClient::new_with_timeouts_and_commitment(
875878
config.json_rpc_url.to_string(),
876879
config.rpc_timeout,
877880
config.commitment,
878881
config.confirm_transaction_initial_timeout,
879882
))
880-
} else {
881-
// Primarily for testing
882-
config.rpc_client.as_ref().unwrap().clone()
883883
};
884884

885885
match &config.command {

core/src/tvu.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,11 @@ impl Tvu {
596596
self.cluster_slots_service.join()?;
597597
self.fetch_stage.join()?;
598598
self.shred_sigverify.join()?;
599-
if self.blockstore_cleanup_service.is_some() {
600-
self.blockstore_cleanup_service.unwrap().join()?;
599+
if let Some(cleanup_service) = self.blockstore_cleanup_service {
600+
cleanup_service.join()?;
601601
}
602-
if self.replay_stage.is_some() {
603-
self.replay_stage.unwrap().join()?;
602+
if let Some(replay_stage) = self.replay_stage {
603+
replay_stage.join()?;
604604
}
605605
self.cost_update_service.join()?;
606606
self.voting_service.join()?;

transaction-status-client-types/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,14 @@ impl TransactionStatus {
742742
match &self.confirmation_status {
743743
Some(status) => status.clone(),
744744
None => {
745-
if self.confirmations.is_none() {
746-
TransactionConfirmationStatus::Finalized
747-
} else if self.confirmations.unwrap() > 0 {
748-
TransactionConfirmationStatus::Confirmed
745+
if let Some(confirmations) = self.confirmations {
746+
if confirmations > 0 {
747+
TransactionConfirmationStatus::Confirmed
748+
} else {
749+
TransactionConfirmationStatus::Processed
750+
}
749751
} else {
750-
TransactionConfirmationStatus::Processed
752+
TransactionConfirmationStatus::Finalized
751753
}
752754
}
753755
}

validator/src/bootstrap.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,13 +1026,12 @@ fn retain_peer_snapshot_hashes_that_match_known_snapshot_hashes(
10261026
known_snapshot_hashes
10271027
.get(&peer_snapshot_hash.snapshot_hash.full)
10281028
.map(|known_incremental_hashes| {
1029-
if peer_snapshot_hash.snapshot_hash.incr.is_none() {
1029+
if let Some(incr) = peer_snapshot_hash.snapshot_hash.incr.as_ref() {
1030+
known_incremental_hashes.contains(incr)
1031+
} else {
10301032
// If the peer's full snapshot hashes match, but doesn't have any
10311033
// incremental snapshots, that's fine; keep 'em!
10321034
true
1033-
} else {
1034-
known_incremental_hashes
1035-
.contains(peer_snapshot_hash.snapshot_hash.incr.as_ref().unwrap())
10361035
}
10371036
})
10381037
.unwrap_or(false)

0 commit comments

Comments
 (0)