From 2d878b9d10ae6937ea758c565ae6b7d4a7d44cfc Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 20 Sep 2022 11:32:50 +0400 Subject: [PATCH] fix(core): improve logging of dropped reply channels --- .../core/src/base_node/service/service.rs | 14 ++++++++------ .../core/src/mempool/service/service.rs | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/base_layer/core/src/base_node/service/service.rs b/base_layer/core/src/base_node/service/service.rs index 649b156c0a..9b97ce13d4 100644 --- a/base_layer/core/src/base_node/service/service.rs +++ b/base_layer/core/src/base_node/service/service.rs @@ -298,13 +298,13 @@ where B: BlockchainBackend + 'static let result = handle_incoming_block(inbound_nch, new_block).await; match result { + Ok(()) => {}, Err(BaseNodeServiceError::CommsInterfaceError(CommsInterfaceError::ChainStorageError( ChainStorageError::AddBlockOperationLocked, ))) => { // Special case, dont log this again as an error }, - Err(e) => error!(target: LOG_TARGET, "Failed to handle incoming block message: {:?}", e), - _ => {}, + Err(e) => error!(target: LOG_TARGET, "Failed to handle incoming block message: {}", e), } }); } @@ -324,10 +324,11 @@ where B: BlockchainBackend + 'static ); } let result = reply_tx.send(res); - if let Err(e) = result { + if let Err(res) = result { error!( target: LOG_TARGET, - "BaseNodeService failed to send reply to local request {:?}", e + "BaseNodeService failed to send reply to local request {:?}", + res.map(|r| r.to_string()).map_err(|e| e.to_string()) ); } }); @@ -339,10 +340,11 @@ where B: BlockchainBackend + 'static let (block, reply_tx) = block_context.split(); let result = reply_tx.send(inbound_nch.handle_block(Arc::new(block), None).await); - if let Err(e) = result { + if let Err(res) = result { error!( target: LOG_TARGET, - "BaseNodeService failed to send reply to local block submitter {:?}", e + "BaseNodeService failed to send reply to local block submitter {:?}", + res.map(|r| r.to_string()).map_err(|e| e.to_string()) ); } }); diff --git a/base_layer/core/src/mempool/service/service.rs b/base_layer/core/src/mempool/service/service.rs index f747484615..61d01e6fe3 100644 --- a/base_layer/core/src/mempool/service/service.rs +++ b/base_layer/core/src/mempool/service/service.rs @@ -107,12 +107,12 @@ impl MempoolService { // Incoming transaction messages from the Comms layer Some(transaction_msg) = inbound_transaction_stream.next() => { let result = handle_incoming_tx(&mut self.inbound_handlers, transaction_msg).await; - if let Err(e) = result { - error!( - target: LOG_TARGET, - "Failed to handle incoming transaction message: {:?}", e - ); - } + if let Err(e) = result { + error!( + target: LOG_TARGET, + "Failed to handle incoming transaction message: {:?}", e + ); + } } // Incoming local request messages from the LocalMempoolServiceInterface and other local services @@ -152,10 +152,11 @@ impl MempoolService { let (request, reply_tx) = request_context.split(); let result = reply_tx.send(inbound_handlers.handle_request(request).await); - if let Err(e) = result { + if let Err(res) = result { error!( target: LOG_TARGET, - "MempoolService failed to send reply to local request {:?}", e + "MempoolService failed to send reply to local request {:?}", + res.map(|r| r.to_string()).map_err(|e| e.to_string()) ); } }); @@ -166,7 +167,7 @@ impl MempoolService { task::spawn(async move { let result = inbound_handlers.handle_block_event(&block_event).await; if let Err(e) = result { - error!(target: LOG_TARGET, "Failed to handle base node block event: {:?}", e); + error!(target: LOG_TARGET, "Failed to handle base node block event: {}", e); } }); }