From 2aba33f224e96ef5d65b1e4ecb23c70df2a18eaf Mon Sep 17 00:00:00 2001 From: Swen Mun Date: Thu, 10 Sep 2020 17:36:58 +0900 Subject: [PATCH 1/3] Release _demandHash after fetching blocks --- CHANGES.md | 3 +++ Libplanet/Net/Swarm.cs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 9de95b4d15..ce33869381 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -249,6 +249,8 @@ To be released. was once called. [[#965]] - Fixed a bug that `TurnClient` had thrown `InvalidOperationException` when reconnecting. [[#957], [#972]] + - Fixed a bug that `Swarm` had not received block headers after failing + to recevie previous blocks. [[#996]] ### CLI tools @@ -312,6 +314,7 @@ To be released. [#980]: https://github.com/planetarium/libplanet/pull/980 [#981]: https://github.com/planetarium/libplanet/pull/981 [#991]: https://github.com/planetarium/libplanet/pull/991 +[#996]: https://github.com/planetarium/libplanet/pull/996 [sleep mode]: https://en.wikipedia.org/wiki/Sleep_mode diff --git a/Libplanet/Net/Swarm.cs b/Libplanet/Net/Swarm.cs index 893ed75a5a..f39279e06b 100644 --- a/Libplanet/Net/Swarm.cs +++ b/Libplanet/Net/Swarm.cs @@ -1968,6 +1968,13 @@ await SyncPreviousBlocksAsync( $" {nameof(ProcessFillBlocks)}: {{e}}"; _logger.Error(e, msg, e); } + finally + { + using (await _blockSyncMutex.LockAsync(cancellationToken)) + { + _demandBlockHash = null; + } + } } } From 0815f28d0bf8cf6add2b8b1d8cfc063f6ff121dd Mon Sep 17 00:00:00 2001 From: Swen Mun Date: Thu, 10 Sep 2020 17:45:49 +0900 Subject: [PATCH 2/3] Fix for nested reorg situation --- CHANGES.md | 2 ++ Libplanet/Net/Swarm.cs | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ce33869381..6f4984be45 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -251,6 +251,8 @@ To be released. reconnecting. [[#957], [#972]] - Fixed a bug that `Swarm` had not received block headers after failing to recevie previous blocks. [[#996]] + - Fixed a bug that `Swarm` had thrown `InvalidGenesisBlockException` + when reorganizing repeatedly. [[#996]] ### CLI tools diff --git a/Libplanet/Net/Swarm.cs b/Libplanet/Net/Swarm.cs index f39279e06b..e65ba9efd3 100644 --- a/Libplanet/Net/Swarm.cs +++ b/Libplanet/Net/Swarm.cs @@ -1810,10 +1810,7 @@ out HashDigest branchPoint { _logger.Debug("It doesn't need to fork."); } - - // We can omit this clause if assume every chain shares - // same genesis block... - else if (!BlockChain.ContainsBlock(branchPoint)) + else if (!workspace.ContainsBlock(branchPoint)) { // FIXME: This behavior can unexpectedly terminate the swarm (and the game // app) if it encounters a peer having a different blockchain, and therefore From df56f00ac84d1fdf8c8188c01b999165be80c7fa Mon Sep 17 00:00:00 2001 From: Swen Mun Date: Thu, 10 Sep 2020 17:55:40 +0900 Subject: [PATCH 3/3] typo --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6f4984be45..7543f1c1c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -250,9 +250,9 @@ To be released. - Fixed a bug that `TurnClient` had thrown `InvalidOperationException` when reconnecting. [[#957], [#972]] - Fixed a bug that `Swarm` had not received block headers after failing - to recevie previous blocks. [[#996]] + to receive previous blocks. [[#996]] - Fixed a bug that `Swarm` had thrown `InvalidGenesisBlockException` - when reorganizing repeatedly. [[#996]] + when reorg its chain repeatedly. [[#996]] ### CLI tools