Skip to content

Commit

Permalink
Merge pull request #1350 from longfin/feature/tune-swarm-blocksync
Browse files Browse the repository at this point in the history
Fail-fast when block sync
  • Loading branch information
longfin authored Jul 6, 2021
2 parents b8eb4c8 + 61f989b commit a14e7c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ To be released.
- (Libplanet.RocksDBStore) Fixed a bug where `RocksDBStore.GetBlock<T>()`
and `RocksDBStore.GetTransaction<T>()` handn't returned expected values
in multithreading environment. [[#1339], [#1342]]
- Fixed a bug where chain synchronization had been incorrectly updated with
an improper chain. [[#1349], [#1350]]
- Fixed a bug where `Swarm<T>` hadn't respond immediately under load.
[[#1360]]

Expand Down Expand Up @@ -321,6 +323,8 @@ To be released.
[#1342]: https://github.com/planetarium/libplanet/pull/1342
[#1343]: https://github.com/planetarium/libplanet/pull/1343
[#1348]: https://github.com/planetarium/libplanet/pull/1348
[#1349]: https://github.com/planetarium/libplanet/issues/1349
[#1350]: https://github.com/planetarium/libplanet/pull/1350
[#1351]: https://github.com/planetarium/libplanet/pull/1351
[#1360]: https://github.com/planetarium/libplanet/pull/1360

Expand Down
11 changes: 3 additions & 8 deletions Libplanet/Net/Swarm.BlockSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,9 @@ CancellationToken cancellationToken
var canonComparer = BlockChain.Policy.CanonicalChainComparer;
if (synced is { } syncedB
&& !syncedB.Id.Equals(blockChain?.Id)
&& (!(blockChain.Tip is { } tip && syncedB.Tip is { } syncedTip)
|| canonComparer.Compare(
blockChain.PerceiveBlock(tip),
blockChain.PerceiveBlock(
syncedTip,
syncedB.PerceiveBlock(syncedTip).PerceivedTime
)
) < 0
&& (canonComparer.Compare(
blockChain.PerceiveBlock(blockChain.Tip),
blockChain.PerceiveBlock(syncedB.Tip)) < 0
)
)
{
Expand Down

0 comments on commit a14e7c8

Please sign in to comment.