Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handle mark spent #786

Merged
merged 8 commits into from
Apr 10, 2024
14 changes: 9 additions & 5 deletions zingolib/src/blaze/update_notes.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::error::ZingoLibResult;
use crate::wallet::MemoDownloadOption;
use crate::wallet::{
data::PoolNullifier, transactions::TxMapAndMaybeTrees, utils::txid_from_slice,
Expand Down Expand Up @@ -88,7 +89,8 @@ impl UpdateNotes {

let wallet_transactions = self.transaction_metadata_set.clone();
let h1 = tokio::spawn(async move {
let mut workers = FuturesUnordered::new();
let mut workers: FuturesUnordered<JoinHandle<ZingoLibResult<()>>> =
FuturesUnordered::new();

// Receive Txns that are sent to the wallet. We need to update the notes for this.
while let Some((
Expand Down Expand Up @@ -132,14 +134,14 @@ impl UpdateNotes {

// Record the future transaction, the one that has spent the nullifiers received in this transaction in the wallet
let status = ConfirmationStatus::Confirmed(spent_at_height);
let _ = wallet_transactions_write_unlocked.found_spent_nullifier(
wallet_transactions_write_unlocked.found_spent_nullifier(
transaction_id_spent_in,
status,
ts,
maybe_spend_nullifier,
transaction_id_spent_from,
output_index,
);
)?;

drop(wallet_transactions_write_unlocked);

Expand All @@ -156,21 +158,23 @@ impl UpdateNotes {
.send((transaction_id_spent_from, at_height))
.unwrap();
}
Ok(())
}));
}

// Wait for all the workers
while let Some(r) = workers.next().await {
r.unwrap();
r.unwrap()?;
}

//info!("Finished Note Update processing");
Ok(())
});

let h = tokio::spawn(async move {
let (r0, r1) = join!(h0, h1);
r0.map_err(|e| format!("{}", e))??;
r1.map_err(|e| format!("{}", e))
r1.map_err(|e| format!("{}", e))?
});

(h, blocks_done_transmitter, transmitter)
Expand Down
Loading