From 3765ac81ea4321d42c4128603f46a10f34f5ccdc Mon Sep 17 00:00:00 2001 From: Swen Mun Date: Fri, 30 Oct 2020 16:01:31 +0900 Subject: [PATCH] Removed retrying logic when block downloading [skip changelog] --- Libplanet/Net/Swarm.cs | 62 ++++++++++++------------------------------ 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/Libplanet/Net/Swarm.cs b/Libplanet/Net/Swarm.cs index af2125256e..bde2761870 100644 --- a/Libplanet/Net/Swarm.cs +++ b/Libplanet/Net/Swarm.cs @@ -1683,56 +1683,30 @@ private async Task SyncPreviousBlocksAsync( CancellationToken cancellationToken ) { - int retry = 3; long previousTipIndex = blockChain.Tip?.Index ?? -1; BlockChain synced = null; try { - while (true) - { - cancellationToken.ThrowIfCancellationRequested(); + long currentTipIndex = blockChain.Tip?.Index ?? -1; + long receivedBlockCount = currentTipIndex - previousTipIndex; - try - { - long currentTipIndex = blockChain.Tip?.Index ?? -1; - long receivedBlockCount = currentTipIndex - previousTipIndex; - - FillBlocksAsyncStarted.Set(); - synced = await FillBlocksAsync( - peer, - blockChain, - stop, - progress, - totalBlockCount, - receivedBlockCount, - true, - cancellationToken - ); - break; - } - catch (TimeoutException e) - { - if (retry > 0) - { - _logger.Error( - e, - $"{nameof(FillBlocksAsync)}() failed; retrying...: {e}" - ); - retry--; - } - else - { - FillBlocksAsyncFailed.Set(); - throw; - } - } - catch (Exception) - { - FillBlocksAsyncFailed.Set(); - throw; - } - } + FillBlocksAsyncStarted.Set(); + synced = await FillBlocksAsync( + peer, + blockChain, + stop, + progress, + totalBlockCount, + receivedBlockCount, + true, + cancellationToken + ); + } + catch (Exception) + { + FillBlocksAsyncFailed.Set(); + throw; } finally {