Skip to content

Commit

Permalink
fix: switch to single-threaded claiming (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse authored Mar 28, 2024
1 parent 21f6d70 commit f7703e1
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lib/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ impl Wallet {
thread::sleep(Duration::from_secs(5));
let ongoing_swaps = cloned.swap_persister.list_ongoing_swaps().unwrap();

thread::scope(|scope| {
for swap in ongoing_swaps {
scope.spawn(|| {
if let OngoingSwap::Receive {
id,
preimage,
redeem_script,
blinding_key,
..
} = swap
{
match cloned.try_claim(&preimage, &redeem_script, &blinding_key, None) {
Ok(_) => cloned.swap_persister.resolve_ongoing_swap(&id).unwrap(),
Err(e) => warn!("Could not claim yet. Err: {e}"),
}
}
});
for swap in ongoing_swaps {
if let OngoingSwap::Receive {
id,
preimage,
redeem_script,
blinding_key,
..
} = swap
{
match cloned.try_claim(&preimage, &redeem_script, &blinding_key, None) {
Ok(_) => cloned.swap_persister.resolve_ongoing_swap(&id).unwrap(),
Err(e) => warn!("Could not claim yet. Err: {e}"),
}
}
});
}
});

Ok(())
Expand Down

0 comments on commit f7703e1

Please sign in to comment.