mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Rust 1.95 lints (#9142)
N/A Adds lints for rust 1.95. Mostly cosmetic. 1. .zip(a.into_iter()) -> .zip(a) . Also a few more places where into_iter is not required 2. replace sort_by with sort_by_key 3. move if statements inside match block. 4. use checked_div instead of if statements. I think this is debatable in terms of being better, happy to remove it if others also feel its unnecessary Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
@@ -215,24 +215,22 @@ pub fn post_validator_monitor_metrics<T: BeaconChainTypes>(
|
||||
drop(val_metrics);
|
||||
|
||||
let attestations = attestation_hits + attestation_misses;
|
||||
let attestation_hit_percentage: f64 = if attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_hits / attestations) as f64
|
||||
};
|
||||
let attestation_hit_percentage: f64 = (100 * attestation_hits)
|
||||
.checked_div(attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let head_attestations = attestation_head_hits + attestation_head_misses;
|
||||
let attestation_head_hit_percentage: f64 = if head_attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_head_hits / head_attestations) as f64
|
||||
};
|
||||
let attestation_head_hit_percentage: f64 = (100 * attestation_head_hits)
|
||||
.checked_div(head_attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let target_attestations = attestation_target_hits + attestation_target_misses;
|
||||
let attestation_target_hit_percentage: f64 = if target_attestations == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(100 * attestation_target_hits / target_attestations) as f64
|
||||
};
|
||||
let attestation_target_hit_percentage: f64 = (100 * attestation_target_hits)
|
||||
.checked_div(target_attestations)
|
||||
.map(|f| f as f64)
|
||||
.unwrap_or(0.0);
|
||||
|
||||
let metrics = ValidatorMetrics {
|
||||
attestation_hits,
|
||||
|
||||
Reference in New Issue
Block a user