File tree Expand file tree Collapse file tree
rs/nns/governance/src/timer_tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,8 +82,8 @@ pub(crate) fn compute_average_icp_xdr_rate(
8282 if count == 0 {
8383 return None ;
8484 }
85- let sum: u64 = filtered. into_iter ( ) . sum ( ) ;
86- Some ( sum / count)
85+ let sum: u128 = filtered. into_iter ( ) . map ( |r| r as u128 ) . sum ( ) ;
86+ Some ( ( sum / count as u128 ) as u64 )
8787}
8888
8989/// Compute the new maturity modulation in permyriad.
@@ -256,6 +256,16 @@ impl UpdateIcpXdrRateRelatedData {
256256 return None ;
257257 }
258258
259+ // Verify that XRC returned a rate for the day we requested. If not, the rate
260+ // won't fill the expected slot and backfill would loop on the same day.
261+ if exchange_rate. timestamp != timestamp {
262+ println ! (
263+ "{}UpdateIcpXdrRateRelatedData: requested timestamp {} but XRC returned {}; ignoring." ,
264+ LOG_PREFIX , timestamp, exchange_rate. timestamp
265+ ) ;
266+ return None ;
267+ }
268+
259269 let rate = SampledPrice :: from ( & exchange_rate) ;
260270 if rate. xdr_permyriad_per_icp == 0 {
261271 println ! (
You can’t perform that action at this time.
0 commit comments