diff --git a/src/bin/inx-chronicle/stardust_inx/mod.rs b/src/bin/inx-chronicle/stardust_inx/mod.rs index f0643936c..a1251466e 100644 --- a/src/bin/inx-chronicle/stardust_inx/mod.rs +++ b/src/bin/inx-chronicle/stardust_inx/mod.rs @@ -49,6 +49,8 @@ pub async fn gather_analytics( ) -> Result<(), InxWorkerError> { let mut tasks = JoinSet::new(); + let len_before = analytics.len(); + for analytic in analytics.drain(..) { let mongodb = mongodb.clone(); let influxdb = influxdb.clone(); @@ -69,6 +71,12 @@ pub async fn gather_analytics( analytics.push(res.unwrap()?); } + debug_assert_eq!( + len_before, + analytics.len(), + "The number of analytics should never change." + ); + Ok(()) } @@ -117,13 +125,16 @@ impl InxWorker { debug!("Started listening to ledger updates via INX."); + #[cfg(feature = "analytics")] + let mut analytics = chronicle::db::collections::analytics::all_analytics(); + while let Some(ledger_update) = stream.try_next().await? { self.handle_ledger_update( &mut inx, ledger_update, &mut stream, #[cfg(feature = "analytics")] - &mut chronicle::db::collections::analytics::all_analytics(), + &mut analytics, ) .await?; }