Skip to content

Commit

Permalink
[linting] using cargo clippy recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Nov 30, 2023
1 parent 3590b10 commit 34b2bdb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
11 changes: 5 additions & 6 deletions insurance-engine/src/bin/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ fn main() -> anyhow::Result<()> {
&args.output_insured_event_collection,
)?;

let stake_meta_filter = match args.whitelist_stake_authority {
Some(whitelisted_stake_authorities) => Some(stake_authorities_filter(HashSet::from_iter(
whitelisted_stake_authorities,
))),
_ => None,
};
let stake_meta_filter = args
.whitelist_stake_authority
.map(|whitelisted_stake_authorities| {
stake_authorities_filter(HashSet::from_iter(whitelisted_stake_authorities))
});

info!("Generating insurance claim collection...");
let insurance_claim_collection = generate_insurance_claim_collection(
Expand Down
25 changes: 11 additions & 14 deletions insurance-engine/src/insurance_claims.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity)]
use std::collections::HashSet;

use snapshot_parser::stake_meta::StakeMeta;
Expand Down Expand Up @@ -81,21 +82,17 @@ pub fn generate_insurance_claim_collection(
.map(|s| s.active_delegation_lamports)
.sum();

let claim: Option<u64> =
match insured_event_collection.events_by_validator(&vote_account) {
Some(events) => Some(events.iter().map(|e| e.claim_amount(stake)).sum()),
_ => None,
};
let claim: Option<u64> = insured_event_collection
.events_by_validator(&vote_account)
.map(|events| events.iter().map(|e| e.claim_amount(stake)).sum());

claim.and_then(|claim| {
Some(InsuranceClaim {
withdraw_authority,
stake_authority,
vote_account,
stake_accounts,
stake,
claim,
})
claim.map(|claim| InsuranceClaim {
withdraw_authority,
stake_authority,
vote_account,
stake_accounts,
stake,
claim,
})
},
)
Expand Down
2 changes: 1 addition & 1 deletion insurance-engine/src/insured_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn generate_insured_event_collection(
.flatten()
.collect();

if events.len() > 0 {
if !events.is_empty() {
Some((v.vote_account.clone(), events))
} else {
None
Expand Down

0 comments on commit 34b2bdb

Please sign in to comment.