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

Fail-fast when block sync #1350

Merged
merged 1 commit into from
Jul 6, 2021
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay without PerceivedTime?

Copy link
Member Author

@longfin longfin Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗

)
)
{
Expand Down