Prevent u64 overflow when calculating current stake percentage (#15453)
(cherry picked from commit 5ae37b9675
)
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -241,9 +241,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
let total_stake = total_current_stake + total_delinquent_stake;
|
let total_stake = total_current_stake + total_delinquent_stake;
|
||||||
let current_stake_percent = total_current_stake * 100 / total_stake;
|
let current_stake_percent = total_current_stake as f64 * 100. / total_stake as f64;
|
||||||
info!(
|
info!(
|
||||||
"Current stake: {}% | Total stake: {}, current stake: {}, delinquent: {}",
|
"Current stake: {:.2}% | Total stake: {}, current stake: {}, delinquent: {}",
|
||||||
current_stake_percent,
|
current_stake_percent,
|
||||||
Sol(total_stake),
|
Sol(total_stake),
|
||||||
Sol(total_current_stake),
|
Sol(total_current_stake),
|
||||||
@ -271,10 +271,10 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.monitor_active_stake && current_stake_percent < 80 {
|
if config.monitor_active_stake && current_stake_percent < 80. {
|
||||||
failures.push((
|
failures.push((
|
||||||
"current-stake",
|
"current-stake",
|
||||||
format!("Current stake is {}%", current_stake_percent),
|
format!("Current stake is {:.2}%", current_stake_percent),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user