Skip to content

Commit

Permalink
fix(analytics): computation of daily active addresses (#1005)
Browse files Browse the repository at this point in the history
* fix(analytics): computation of daily active addresses

* add debug assert

* fmt

Co-authored-by: /alex/ <alexander.schmidt@iota.org>
  • Loading branch information
grtlr and Alex6323 authored Jan 10, 2023
1 parent 08c9fb4 commit 77e3537
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/bin/inx-chronicle/stardust_inx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(())
}

Expand Down Expand Up @@ -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?;
}
Expand Down

0 comments on commit 77e3537

Please sign in to comment.