From f2d831396cfad772006cf88d2b17f85cfca5d65f Mon Sep 17 00:00:00 2001 From: Amirul Ashraf Date: Tue, 28 Jun 2022 16:23:28 +0800 Subject: [PATCH] Reduce sync timeout level to debug --- .../FastBlocks/BodiesSyncDispatcher.cs | 13 +++++++++++-- .../FastBlocks/HeadersSyncDispatcher.cs | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Nethermind/Nethermind.Synchronization/FastBlocks/BodiesSyncDispatcher.cs b/src/Nethermind/Nethermind.Synchronization/FastBlocks/BodiesSyncDispatcher.cs index 0bfb414a711..8a9c78727be 100644 --- a/src/Nethermind/Nethermind.Synchronization/FastBlocks/BodiesSyncDispatcher.cs +++ b/src/Nethermind/Nethermind.Synchronization/FastBlocks/BodiesSyncDispatcher.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the Nethermind. If not, see . +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -49,8 +50,16 @@ protected override async Task Dispatch(PeerInfo peerInfo, BodiesSyncBatch batch, if (Logger.IsDebug) Logger.Debug($"{batch} - attempted send a request with no hash."); return; } - - batch.Response = await peer.GetBlockBodies(hashes, cancellationToken); + + try + { + batch.Response = await peer.GetBlockBodies(hashes, cancellationToken); + } + catch (TimeoutException) + { + if (Logger.IsDebug) Logger.Debug($"{batch} - Get block bodies timeout {batch.RequestTime:F2}"); + return; + } if (batch.RequestTime > 1000) { if (Logger.IsDebug) Logger.Debug($"{batch} - peer is slow {batch.RequestTime:F2}"); diff --git a/src/Nethermind/Nethermind.Synchronization/FastBlocks/HeadersSyncDispatcher.cs b/src/Nethermind/Nethermind.Synchronization/FastBlocks/HeadersSyncDispatcher.cs index 7d05f90baca..8d612cdadea 100644 --- a/src/Nethermind/Nethermind.Synchronization/FastBlocks/HeadersSyncDispatcher.cs +++ b/src/Nethermind/Nethermind.Synchronization/FastBlocks/HeadersSyncDispatcher.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the Nethermind. If not, see . +using System; using System.Threading; using System.Threading.Tasks; using Nethermind.Blockchain.Synchronization; @@ -43,8 +44,16 @@ protected override async Task Dispatch( ISyncPeer peer = peerInfo.SyncPeer; batch.ResponseSourcePeer = peerInfo; batch.MarkSent(); - - batch.Response = await peer.GetBlockHeaders(batch.StartNumber, batch.RequestSize, 0, cancellationToken); + + try + { + batch.Response = await peer.GetBlockHeaders(batch.StartNumber, batch.RequestSize, 0, cancellationToken); + } + catch (TimeoutException) + { + if (Logger.IsDebug) Logger.Debug($"{batch} - request block header timeout {batch.RequestTime:F2}"); + return; + } if (batch.RequestTime > 1000) { if (Logger.IsDebug) Logger.Debug($"{batch} - peer is slow {batch.RequestTime:F2}");