Skip to content

Commit

Permalink
cli::stake: Remove allow(clippy::arithmetic_side_effects) (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-bobyr authored Apr 22, 2024
1 parent c87b830 commit af4759e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::arithmetic_side_effects)]

use {
crate::{
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
Expand Down Expand Up @@ -2474,7 +2472,12 @@ pub fn get_epoch_boundary_timestamps(
break block_time;
}
Err(_) => {
epoch_start_slot += 1;
// TODO This is wrong. We should not just increase the slot index if the RPC
// request failed. It could have failed for a number of reasons, including, for
// example a network failure.
epoch_start_slot = epoch_start_slot
.checked_add(1)
.ok_or("Reached last slot that fits into u64")?;
}
}
};
Expand All @@ -2488,7 +2491,8 @@ pub fn make_cli_reward(
) -> Option<CliEpochReward> {
let wallclock_epoch_duration = epoch_end_time.checked_sub(epoch_start_time)?;
if reward.post_balance > reward.amount {
let rate_change = reward.amount as f64 / (reward.post_balance - reward.amount) as f64;
let rate_change =
reward.amount as f64 / (reward.post_balance.saturating_sub(reward.amount)) as f64;

let wallclock_epochs_per_year =
(SECONDS_PER_DAY * 365) as f64 / wallclock_epoch_duration as f64;
Expand Down

0 comments on commit af4759e

Please sign in to comment.