Skip to content

Commit

Permalink
fix(audit): dont overwrite beta tracking payments
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Jun 4, 2024
1 parent e85b0aa commit 2b57591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions sn_auditor/src/dag_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
6 changes: 3 additions & 3 deletions sn_auditor/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 2b57591

Please sign in to comment.