mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-10-12 05:20:53 -04:00
Unify logging of broadcasted transactions
We eliminate unnecessary layers of indirection for broadcasting logic and force our callers to provide us with the `kind` of transaction that we are publishing. Eventually, we can replace this string with some type-system magic we can derive the name from the actual transaction. For now, we just require the caller to duplicate this information because it is faster and good enough TM.
This commit is contained in:
parent
3a503bf95f
commit
8c9b087e39
4 changed files with 44 additions and 66 deletions
|
@ -147,14 +147,20 @@ impl Wallet {
|
|||
self.inner.lock().await.network()
|
||||
}
|
||||
|
||||
pub async fn broadcast(&self, transaction: Transaction) -> Result<Txid> {
|
||||
/// Broadcast the given transaction to the network and emit a log statement
|
||||
/// if done so successfully.
|
||||
pub async fn broadcast(&self, transaction: Transaction, kind: &str) -> Result<Txid> {
|
||||
let txid = transaction.txid();
|
||||
|
||||
self.inner
|
||||
.lock()
|
||||
.await
|
||||
.broadcast(transaction)
|
||||
.with_context(|| format!("failed to broadcast transaction {}", txid))?;
|
||||
.with_context(|| {
|
||||
format!("failed to broadcast Bitcoin {} transaction {}", kind, txid)
|
||||
})?;
|
||||
|
||||
tracing::info!("Published Bitcoin {} transaction as {}", txid, kind);
|
||||
|
||||
Ok(txid)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue