Skip to content

Commit

Permalink
Reduce sync timeout level to debug (#4215)
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap authored Jun 29, 2022
1 parent 6ec56f2 commit 1a31fbc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -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}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Threading;
using System.Threading.Tasks;
using Nethermind.Blockchain.Synchronization;
Expand Down Expand Up @@ -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}");
Expand Down

0 comments on commit 1a31fbc

Please sign in to comment.