diff --git a/sn_auditor/src/dag_db.rs b/sn_auditor/src/dag_db.rs index a1bb786010..d570799c5d 100644 --- a/sn_auditor/src/dag_db.rs +++ b/sn_auditor/src/dag_db.rs @@ -303,6 +303,7 @@ impl SpendDagDb { }; let mut addrs_to_get = BTreeMap::new(); + let mut addrs_fetched = BTreeSet::new(); loop { // get expired utxos for re-attempt fetch @@ -350,16 +351,23 @@ impl SpendDagDb { ) })); } else if let Some(sender) = spend_processing.clone() { - let (reattempt_addrs, fetched_addrs) = client + let (reattempt_addrs, fetched_addrs, addrs_for_further_track) = client .crawl_to_next_utxos(&mut addrs_to_get, sender.clone(), *UTXO_REATTEMPT_SECONDS) .await; + let mut utxo_addresses = self.utxo_addresses.write().await; - for addr in fetched_addrs.iter() { - let _ = utxo_addresses.remove(addr); + for addr in fetched_addrs { + let _ = utxo_addresses.remove(&addr); + let _ = addrs_fetched.insert(addr); } for (addr, tuple) in reattempt_addrs { let _ = utxo_addresses.insert(addr, tuple); } + for (addr, amount) in addrs_for_further_track { + if !addrs_fetched.contains(&addr) { + let _ = addrs_to_get.entry(addr).or_insert((0, amount)); + } + } } else { panic!("There is no point in running the auditor if we are not collecting the DAG or collecting data through crawling. Please enable the `dag-collection` feature or provide beta program related arguments."); }; diff --git a/sn_client/src/audit/dag_crawling.rs b/sn_client/src/audit/dag_crawling.rs index e29760858e..7816eb2806 100644 --- a/sn_client/src/audit/dag_crawling.rs +++ b/sn_client/src/audit/dag_crawling.rs @@ -155,6 +155,7 @@ impl Client { ) -> ( BTreeMap, Vec, + BTreeSet<(SpendAddress, NanoTokens)>, ) { let mut failed_utxos = BTreeMap::new(); let mut tasks = JoinSet::new(); @@ -245,11 +246,7 @@ impl Client { } } - for (addr, amount) in addrs_for_further_track { - let _ = addrs_to_get.entry(addr).or_insert((0, amount)); - } - - (failed_utxos, fetched_addrs) + (failed_utxos, fetched_addrs, addrs_for_further_track) } /// Crawls the Spend Dag from a given SpendAddress recursively