Skip to content

Commit

Permalink
Checked_add weightage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouzo committed Sep 23, 2024
1 parent 67792e5 commit 1c59be3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ain-ocean/src/indexer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fn map_price_aggregated(

let mut aggregated_total = Decimal::zero();
let mut aggregated_count = 0;
let mut aggregated_weightage = 0;
let mut aggregated_weightage = 0u8;

let oracles_len = oracles.len();
for oracle in oracles {
Expand All @@ -424,7 +424,12 @@ fn map_price_aggregated(
let time_diff = Decimal::from(feed.time) - Decimal::from(context.block.time);
if Decimal::abs(&time_diff) < dec!(3600) {
aggregated_count += 1;
aggregated_weightage += oracle.weightage;
aggregated_weightage =
aggregated_weightage
.checked_add(oracle.weightage)
.context(OtherSnafu {
msg: "Error adding oracle weightage",
})?;
log::trace!(
"SetOracleData weightage: {:?} * oracle_price.amount: {:?}",
aggregated_weightage,
Expand Down

0 comments on commit 1c59be3

Please sign in to comment.