diff --git a/lib/src/Pos/Network/Block/Retrieval.hs b/lib/src/Pos/Network/Block/Retrieval.hs index 7899ca0f6ef..394492a1d3e 100644 --- a/lib/src/Pos/Network/Block/Retrieval.hs +++ b/lib/src/Pos/Network/Block/Retrieval.hs @@ -11,15 +11,15 @@ import Universum import Control.Concurrent.STM (TVar, newTVar, putTMVar, swapTMVar, swapTVar, tryReadTBQueue, tryReadTMVar, tryTakeTMVar) -import Control.Exception.Safe (handleAny) +import Control.Exception.Safe (IOException, handleAny) import Control.Lens (to) import Control.Monad.STM (retry) import qualified Data.List.NonEmpty as NE import Data.Time.Units (Second) -import Formatting (build, int, sformat, (%)) +import Formatting (build, int, sformat, shown, (%)) import Pos.Chain.Block (Block, BlockHeader, HasHeaderHash (..), - HeaderHash) + HeaderHash, headerHashF) import Pos.Chain.Genesis as Genesis (Config) import Pos.Chain.Txp (TxpConfiguration) import Pos.Core (difficultyL, isMoreDifficult) @@ -155,10 +155,14 @@ retrievalWorker genesisConfig txpConfig diffusion = do -- again. handleRecoveryE nodeId rHeader e = do -- REPORT:ERROR 'reportOrLogW' in block retrieval worker/recovery. - reportOrLogW (sformat - ("handleRecoveryE: error handling nodeId="%build%", header="%build%": ") - nodeId (headerHash rHeader)) e + reportOrLogW (sformat errfmt nodeId (headerHash rHeader)) e + `catch` handleIOException dropRecoveryHeaderAndRepeat genesisConfig diffusion nodeId + where + errfmt = "handleRecoveryE: error handling nodeId="%build%", header="%headerHashF%": " + + handleIOException :: IOException -> m () + handleIOException _ = logError $ sformat (errfmt%shown) nodeId (headerHash rHeader) e -- Recovery handling. We assume that header in the recovery variable is -- appropriate and just query headers/blocks. diff --git a/networking/src/Network/Broadcast/OutboundQueue.hs b/networking/src/Network/Broadcast/OutboundQueue.hs index 9e793184ab4..403d5e78d01 100644 --- a/networking/src/Network/Broadcast/OutboundQueue.hs +++ b/networking/src/Network/Broadcast/OutboundQueue.hs @@ -1036,9 +1036,7 @@ intDequeue outQ@OutQ{..} threadRegistry@TR{} sendMsg = do logFailure outQ FailedSend (Some p, err) intFailure outQ p sendStartTime err Nothing -> - return () - - logDebugOQ outQ $ debugSent p + logDebugOQ outQ $ debugSent p return (PacketDequeued theThread) return ()