Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polishing Swarm<T> #996

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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