Skip to content

Commit

Permalink
remove deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoX911 committed Jan 17, 2025
1 parent 3874f53 commit 655eca6
Showing 1 changed file with 46 additions and 37 deletions.
83 changes: 46 additions & 37 deletions src/maker/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,18 +752,18 @@ pub(crate) fn recover_from_swap(
maker.config.network_port
);
} else if let Err(e) = maker.wallet.read()?.send_tx(&tx) {
log::info!(
"Can't send incoming contract: {} | {:?}",
tx.compute_txid(),
e
);
} else {
log::info!(
"[{}] Broadcasted Incoming Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}
log::info!(
"Can't send incoming contract: {} | {:?}",
tx.compute_txid(),
e
);
} else {
log::info!(
"[{}] Broadcasted Incoming Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}

let removed_incoming = maker
.wallet
Expand All @@ -779,38 +779,47 @@ pub(crate) fn recover_from_swap(

//broadcast all the outgoing contracts
for ((og_rs, tx), _) in outgoings.iter() {
if maker
let check_tx_result = maker
.wallet
.read()?
.rpc
.get_raw_transaction_info(&tx.compute_txid(), None)
.is_ok()
{
log::info!(
"[{}] Outgoing Contract already broadcasted",
maker.config.network_port
);
} else if let Err(e) = maker.wallet.read()?.send_tx(tx) {
.get_raw_transaction_info(&tx.compute_txid(), None);

match check_tx_result {
Ok(_) => {
log::info!(
"Can't send ougoing contract: {} | {:?}",
tx.compute_txid(),
e
"[{}] Outgoing Contract already broadcasted",
maker.config.network_port
);
if format!("{:?}", e).contains("bad-txns-inputs-missingorspent") {
// This means the funding utxo doesn't exist anymore. Just remove this coin.
log::info!("Removing outgoing swapcoin: {}", tx.compute_txid());
maker
.get_wallet()
.write()?
.remove_outgoing_swapcoin(og_rs)?;
}
Err(_) => {
let send_tx_result = maker.wallet.read()?.send_tx(tx);
match send_tx_result {
Ok(_) => {
log::info!(
"[{}] Broadcasted Outgoing Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}
Err(e) => {
log::info!(
"Can't send ougoing contract: {} | {:?}",
tx.compute_txid(),
e
);
if format!("{:?}", e).contains("bad-txns-inputs-missingorspent") {
// This means the funding utxo doesn't exist anymore. Just remove this coin.
maker
.get_wallet()
.write()?
.remove_outgoing_swapcoin(og_rs)?;
log::info!("Removed outgoing swapcoin: {}", tx.compute_txid());
}
}
}
} else {
log::info!(
"[{}] Broadcasted Outgoing Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}
}
}

// Save the wallet here before going into the expensive loop.
Expand Down

0 comments on commit 655eca6

Please sign in to comment.