-
Notifications
You must be signed in to change notification settings - Fork 395
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
Fix downloader hangs in some case #4362
Conversation
@@ -475,7 +486,13 @@ protected async Task RequestReceipts(PeerInfo peer, CancellationToken cancellati | |||
for (int i = 0; i < result.Length; i++) | |||
{ | |||
TxReceipt[] txReceipts = result[i]; | |||
if (!context.TrySetReceipts(i + offset, txReceipts, out Block block)) | |||
Block block = context.GetBlockByRequestIdx(i + offset); | |||
if (block.Header.HasBody && block.Transactions.Length == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about unlces only blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good catch
@@ -172,6 +172,11 @@ bool HasMoreToSync() | |||
Block currentBlock = blocks[blockIndex]; | |||
if (_logger.IsTrace) _logger.Trace($"Received {currentBlock} from {bestPeer}"); | |||
|
|||
if (currentBlock.Header.HasBody && currentBlock.Body.IsEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now duplicated in 3 places, should we have some kind of method for this validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, I'm still good with this expression IMO, still understandable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to currentBlock.IsBodyMissing
4d65f7f
to
332ce66
Compare
Fix downloader hangs when peer response with no body.
Changes:
Types of changes
Testing
Requires testing
In case you checked yes, did you write tests??
Comments about testing , should you have some (optional)
Further comments (optional)
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...