@@ -9,10 +9,7 @@ import cats.instances.future._
99import cats .instances .option ._
1010import cats .syntax .either ._
1111import io .iohk .ethereum .blockchain .sync .PeersClient ._
12- import io .iohk .ethereum .blockchain .sync .regular .BlockFetcherState .{
13- AwaitingBodiesToBeIgnored ,
14- AwaitingHeadersToBeIgnored
15- }
12+ import io .iohk .ethereum .blockchain .sync .regular .BlockFetcherState .{AwaitingBodiesToBeIgnored , AwaitingHeadersToBeIgnored }
1613import io .iohk .ethereum .blockchain .sync .regular .BlockImporter .{ImportNewBlock , NotOnTop , OnTop }
1714import io .iohk .ethereum .blockchain .sync .regular .RegularSync .ProgressProtocol
1815import io .iohk .ethereum .crypto .kec256
@@ -44,7 +41,7 @@ class BlockFetcher(
4441 import BlockFetcher ._
4542
4643 implicit val ec : ExecutionContext = context.dispatcher
47- implicit val timeout : Timeout = syncConfig.peerResponseTimeout + 1 .second // some margin for actor communication
44+ implicit val timeout : Timeout = syncConfig.peerResponseTimeout + 2 .second // some margin for actor communication
4845
4946 override def receive : Receive = idle()
5047
@@ -130,7 +127,7 @@ class BlockFetcher(
130127
131128 fetchBlocks(newState)
132129 case RetryHeadersRequest if state.isFetchingHeaders =>
133- log.debug(" Time-out occurred while waiting for headers" )
130+ log.debug(" Something failed on a headers request, cancelling the request and re-fetching " )
134131
135132 val newState = state.withHeaderFetchReceived
136133 fetchBlocks(newState)
@@ -149,7 +146,7 @@ class BlockFetcher(
149146
150147 fetchBlocks(newState)
151148 case RetryBodiesRequest if state.isFetchingBodies =>
152- log.debug(" Time-out occurred while waiting for bodies" )
149+ log.debug(" Something failed on a bodies request, cancelling the request and re-fetching " )
153150
154151 val newState = state.withBodiesFetchReceived
155152 fetchBlocks(newState)
@@ -316,6 +313,10 @@ class BlockFetcher(
316313 (peersClient ? request)
317314 .tap(blacklistPeerOnFailedRequest)
318315 .flatMap(failureTo(responseFallback))
316+ .recover { case error =>
317+ log.error(error, " Unexpected error on a request" )
318+ responseFallback
319+ }
319320
320321 private def blacklistPeerOnFailedRequest (msg : Any ): Unit = msg match {
321322 case RequestFailed (peer, reason) => peersClient ! BlacklistPeer (peer.id, reason)
0 commit comments