From 2b5759182091f16cd4f5d61700241988a7f63329 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Tue, 4 Jun 2024 22:26:30 +0900 Subject: [PATCH] fix(audit): dont overwrite beta tracking payments --- sn_auditor/src/dag_db.rs | 12 ++++++++++-- sn_auditor/src/routes.rs | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sn_auditor/src/dag_db.rs b/sn_auditor/src/dag_db.rs index 12db768623..8452ea504c 100644 --- a/sn_auditor/src/dag_db.rs +++ b/sn_auditor/src/dag_db.rs @@ -374,14 +374,22 @@ impl SpendDagDb { let mut beta_tracking = self.beta_tracking.write().await; for (hash, p) in new_participants { let unkown_str = format!("unknown participant: {hash:?}"); - let payments = if let Some(prev_payments) = + let mut payments = if let Some(prev_payments) = beta_tracking.forwarded_payments.remove(&unkown_str) { prev_payments } else { BTreeSet::new() }; - let _ = beta_tracking.forwarded_payments.insert(p, payments); + + if let Some(existing) = beta_tracking + .forwarded_payments + .insert(p.clone(), payments.clone()) + { + warn!("Overwriting existing participant {p} with new participant {hash:?}"); + payments.extend(existing); + let _ = beta_tracking.forwarded_payments.insert(p.clone(), payments); + } } } Ok(()) diff --git a/sn_auditor/src/routes.rs b/sn_auditor/src/routes.rs index 2918c5001a..8f51a30923 100644 --- a/sn_auditor/src/routes.rs +++ b/sn_auditor/src/routes.rs @@ -116,14 +116,14 @@ pub(crate) async fn add_participant( } async fn track_new_participant(dag: &SpendDagDb, discord_id: String) -> Result<()> { - dag.track_new_beta_participants(BTreeSet::from_iter([discord_id.to_owned()])) - .await?; - // only append new ids if dag.is_participant_tracked(&discord_id).await? { return Ok(()); } + dag.track_new_beta_participants(BTreeSet::from_iter([discord_id.to_owned()])) + .await?; + let local_participants_file = dag.path.join(dag_db::BETA_PARTICIPANTS_FILENAME); if local_participants_file.exists() {