Skip to content

Commit

Permalink
Merge pull request #996 from longfin/bugfix/swarm-polish
Browse files Browse the repository at this point in the history
Polishing Swarm<T>
  • Loading branch information
longfin authored Sep 10, 2020
2 parents 5eecf71 + df56f00 commit 915b94e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ To be released.
was once called. [[#965]]
- Fixed a bug that `TurnClient` had thrown `InvalidOperationException` when
reconnecting. [[#957], [#972]]
- Fixed a bug that `Swarm<T>` had not received block headers after failing
to receive previous blocks. [[#996]]
- Fixed a bug that `Swarm<T>` had thrown `InvalidGenesisBlockException`
when reorg its chain repeatedly. [[#996]]

### CLI tools

Expand Down Expand Up @@ -312,6 +316,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


Expand Down
12 changes: 8 additions & 4 deletions Libplanet/Net/Swarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,10 +1810,7 @@ out HashDigest<SHA256> 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
Expand Down Expand Up @@ -1968,6 +1965,13 @@ await SyncPreviousBlocksAsync(
$" {nameof(ProcessFillBlocks)}: {{e}}";
_logger.Error(e, msg, e);
}
finally
{
using (await _blockSyncMutex.LockAsync(cancellationToken))
{
_demandBlockHash = null;
}
}
}
}

Expand Down

0 comments on commit 915b94e

Please sign in to comment.