@@ -10,12 +10,13 @@ import Universum
1010
1111import Control.Concurrent.STM (putTMVar , swapTMVar , tryReadTBQueue , tryReadTMVar ,
1212 tryTakeTMVar , readTBQueue , TBQueue )
13- import Control.Exception.Safe (handleAny )
13+ import Control.Exception (IOException )
14+ import Control.Exception.Safe (catch , handleAny )
1415import Control.Lens (to )
1516import Control.Monad.STM (retry )
1617import qualified Data.List.NonEmpty as NE
1718import Data.Time.Units (Second )
18- import Formatting (build , int , sformat , (%) )
19+ import Formatting (build , int , sformat , shown , (%) )
1920import Mockable (delay )
2021import qualified System.Metrics.Gauge as Gauge
2122import System.Wlog (logDebug , logError , logInfo , logWarning )
@@ -26,7 +27,8 @@ import Pos.Block.Network.Logic (BlockNetLogicException (..), handleBlo
2627 triggerRecovery )
2728import Pos.Block.RetrievalQueue (BlockRetrievalQueueTag , BlockRetrievalTask (.. ))
2829import Pos.Block.Types (RecoveryHeaderTag )
29- import Pos.Core (Block , HasHeaderHash (.. ), HeaderHash , difficultyL , isMoreDifficult )
30+ import Pos.Core (Block , HasHeaderHash (.. ), HeaderHash , difficultyL , headerHashF ,
31+ isMoreDifficult )
3032import Pos.Core.Block (BlockHeader )
3133import Pos.Core.Chrono (NE , OldestFirst (.. ), _OldestFirst )
3234import Pos.Crypto (ProtocolMagic , shortHashF )
@@ -147,10 +149,15 @@ retrievalWorker pm diffusion = do
147149 -- again.
148150 handleRecoveryE nodeId rHeader e = do
149151 -- REPORT:ERROR 'reportOrLogW' in block retrieval worker/recovery.
150- reportOrLogW (sformat
151- (" handleRecoveryE: error handling nodeId=" % build% " , header=" % build% " : " )
152- nodeId (headerHash rHeader)) e
152+ reportOrLogW (sformat errfmt nodeId (headerHash rHeader)) e
153+ `catch` handleIOException
153154 dropRecoveryHeaderAndRepeat pm diffusion nodeId
155+ where
156+ errfmt = " handleRecoveryE: error handling nodeId=" % build% " , header=" % headerHashF% " : "
157+
158+ handleIOException :: IOException -> m ()
159+ handleIOException _ = logError $ sformat (errfmt% shown) nodeId (headerHash rHeader) e
160+
154161
155162 -- Recovery handling. We assume that header in the recovery variable is
156163 -- appropriate and just query headers/blocks.
0 commit comments