Skip to content

Commit

Permalink
fix(auditor): not to re-attempt fetched spend
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Oct 8, 2024
1 parent 0d52e8b commit 0dd2246
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 11 additions & 3 deletions sn_auditor/src/dag_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.");
};
Expand Down
7 changes: 2 additions & 5 deletions sn_client/src/audit/dag_crawling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl Client {
) -> (
BTreeMap<SpendAddress, (u64, Instant, NanoTokens)>,
Vec<SpendAddress>,
BTreeSet<(SpendAddress, NanoTokens)>,
) {
let mut failed_utxos = BTreeMap::new();
let mut tasks = JoinSet::new();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0dd2246

Please sign in to comment.