Skip to content

Commit

Permalink
Skip tip check before swap chain (to fail fast)
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed Jun 23, 2021
1 parent 2eaab5a commit a5f2174
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 @@ -256,6 +256,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]]

### CLI tools

Expand Down Expand Up @@ -306,6 +308,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


Version 0.11.1
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 a5f2174

Please sign in to comment.