From be95952dda2d442857de28170cb7801d95d50f64 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 23 Jul 2020 16:51:40 +0900 Subject: [PATCH 1/2] Don't throw exception when connecting to all neighbors fails --- CHANGES.md | 3 +++ Libplanet/Net/Protocols/KademliaProtocol.cs | 29 --------------------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e7deb430e93..601e32b38fb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -98,6 +98,8 @@ To be released. [[#459], [#919]] - `Swarm` became to promote the most difficult chain as a canonical chain instead of the longest chain. [[#459], [#919]] + - Changed to not throw an exception in `Swarm.BootstrapAsync()` when + connecting to all neighbors fails. [[#933]] ### Bug fixes @@ -151,6 +153,7 @@ To be released. [#927]: https://github.com/planetarium/libplanet/pull/927 [#930]: https://github.com/planetarium/libplanet/pull/930 [#932]: https://github.com/planetarium/libplanet/pull/932 +[#933]: https://github.com/planetarium/libplanet/pull/933 [sleep mode]: https://en.wikipedia.org/wiki/Sleep_mode diff --git a/Libplanet/Net/Protocols/KademliaProtocol.cs b/Libplanet/Net/Protocols/KademliaProtocol.cs index 5d75343db2a..06b976d6a89 100644 --- a/Libplanet/Net/Protocols/KademliaProtocol.cs +++ b/Libplanet/Net/Protocols/KademliaProtocol.cs @@ -127,15 +127,6 @@ public async Task BootstrapAsync( } catch (Exception e) { - if (findPeerTasks.All(task => - task.IsFaulted && - !(task.Exception is null) && - task.Exception.InnerExceptions.All(ex => ex is TimeoutException))) - { - throw new TimeoutException( - $"Timeout exception occurred during {nameof(BootstrapAsync)}()."); - } - var msg = $"An unexpected exception occurred during {nameof(BootstrapAsync)}()." + " {Exception}"; _logger.Error(e, msg, e); @@ -640,16 +631,6 @@ private async Task ProcessFoundAsync( } catch (Exception e) { - if (awaitables.All(task => - task.IsFaulted && - !(task.Exception is null) && - task.Exception.InnerExceptions.All(ex => ex is TimeoutException))) - { - throw new TimeoutException( - $"All neighbors found do not respond in {_requestTimeout}." - ); - } - _logger.Error( e, "Some responses from neighbors found unexpectedly terminated: {Exception}", @@ -695,16 +676,6 @@ private async Task ProcessFoundAsync( } catch (Exception e) { - if (findPeerTasks.All(task => - task.IsFaulted && - !(task.Exception is null) && - task.Exception.InnerExceptions.All(ex => ex is TimeoutException))) - { - throw new TimeoutException( - "All FindPeer tasks caused timeout during " + - $"{nameof(ProcessFoundAsync)}()."); - } - _logger.Error( e, "Some FindPeer tasks were unexpectedly terminated: {Exception}", From 2495685a496415a433752a39f386bfa4e0da91c5 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 23 Jul 2020 17:16:05 +0900 Subject: [PATCH 2/2] Update CHANGES.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hong Minhee (洪 民憙) --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 601e32b38fb..3cd939e8741 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -98,8 +98,8 @@ To be released. [[#459], [#919]] - `Swarm` became to promote the most difficult chain as a canonical chain instead of the longest chain. [[#459], [#919]] - - Changed to not throw an exception in `Swarm.BootstrapAsync()` when - connecting to all neighbors fails. [[#933]] + - `Swarm.BootstrapAsync()` method became not to throw `TimeoutException` when + it fails to connect to all neighbors. [[#933]] ### Bug fixes