From dd3af8df9f917721ae610a0a63ea1238bc80612f Mon Sep 17 00:00:00 2001 From: Kiril Mihaylov <80464733+KirilMihaylov@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:48:31 +0300 Subject: [PATCH] feat(chain-ops): Log transaction response's error code on failed broadcast. --- chain-ops/src/task/broadcast.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/chain-ops/src/task/broadcast.rs b/chain-ops/src/task/broadcast.rs index 8d85535..cc2a292 100644 --- a/chain-ops/src/task/broadcast.rs +++ b/chain-ops/src/task/broadcast.rs @@ -112,17 +112,21 @@ where } fn log_tx_response(source: &str, tx_code: TxCode, response: &TxResponse) { - if tx_code.is_ok() { - log_broadcast_with_source!(info![source]( - hash = %response.txhash, - "Transaction broadcast successful.", - )); - } else { - log_broadcast_with_source!(error![source]( - hash = %response.txhash, - log = ?response.raw_log, - "Transaction broadcast failed!", - )); + match tx_code { + TxCode::Ok => { + log_broadcast_with_source!(info![source]( + hash = %response.txhash, + "Transaction broadcast successful.", + )); + }, + TxCode::Err(code) => { + log_broadcast_with_source!(error![source]( + hash = %response.txhash, + log = ?response.raw_log, + code = %code, + "Transaction broadcast failed!", + )); + }, } }