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 026ec04
Showing 1 changed file with 3 additions and 8 deletions.
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 026ec04

Please sign in to comment.