Skip to content

Commit

Permalink
chore: make fetching tx fee more resilliant
Browse files Browse the repository at this point in the history
it looks like we sometimes have a timing issue when fetching a tx because the publishment was not yet finalized, with this we simply retry after one second
  • Loading branch information
bonomat committed Sep 6, 2023
1 parent 7a81e12 commit f7b3e1a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions mobile/native/src/channel_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,21 @@ impl ChannelFeePaymentSubscriber {

let txid = ln_dlc::get_funding_transaction(channel_id)?;

let transaction: EsploraTransaction = tokio::task::block_in_place(|| {
Handle::current().block_on(fetch_funding_transaction(txid))
})?;
let transaction: EsploraTransaction = tokio::task::block_in_place(
|| match Handle::current().block_on(fetch_funding_transaction(txid)) {
Ok(tx) => Ok(tx),
Err(err) => {
tracing::warn!(
tx_id = txid.to_string(),
"Could not fetch opening transaction due to {err:#}, retrying after a short sleep."
);
Handle::current().block_on(async {
tokio::time::sleep(Duration::from_secs(1)).await;
fetch_funding_transaction(txid).await
})
}
},
)?;
tracing::debug!("Successfully fetched transaction fees of {} for new inbound channel with id {channel_id_as_str}", transaction.fee);
self.set_open_channel_info(channel_id, transaction);
Ok(())
Expand Down

0 comments on commit f7b3e1a

Please sign in to comment.