-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Allow 2 simultaneous (compact-)block downloads #10984
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
Allow 2 simultaneous (compact-)block downloads #10984
Conversation
6a66609
to
cad4b16
Compare
Rebased and added a simple test |
Rebased. |
cad4b16
to
458feb3
Compare
Nice work! |
458feb3
to
ea17977
Compare
Rebased. |
range.first++; | ||
if (itInFlight->second.first == nodeid) { | ||
if (clearState) ClearDownloadState(itInFlight); | ||
mmapBlocksInFlight.erase(itInFlight); |
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.
Loose itInFlight
:
while (range.first != range.second) {
if (range.first->second.first == nodeid) {
if (clearState) ClearDownloadState(range.first);
range.first = mmapBlocksInFlight.erase(range.first);
} else {
range.first++;
}
}
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.
Heh, thats more lines (and IMO less readable)...
src/net_processing.cpp
Outdated
LOCK(cs_main); | ||
bool found = false; | ||
std::pair<BlockDownloadMap::iterator, BlockDownloadMap::iterator> range = mmapBlocksInFlight.equal_range(hash); | ||
while (range.first != range.second) { |
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.
Loose found
:
if (range.first == range.second) return false;
while (range.first != range.second) {
...
}
return true;
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.
Done.
src/net_processing.cpp
Outdated
*pit = &itInFlight->second.second; | ||
std::pair<BlockDownloadMap::iterator, BlockDownloadMap::iterator> range = mmapBlocksInFlight.equal_range(hash); | ||
while (range.first != range.second) { | ||
BlockDownloadMap::iterator itInFlight = range.first; |
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.
Same as above.
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.
Done.
This pushes some "is this callback useful" logic down into net_processing, which is useful for later changes as it allows for more notifications to be used.
The received block could be malleated, so this is both simpler, and supports parallel downloads.
…ight This is a change in behavior so that if for some reason we request a block from a peer, we don't allow an unsolicited CMPCT_BLOCK announcement for that same block to cause a request for a full block from the uninvited peer (as some type of request is already outstanding from the original peer)
...as long as the second one uses compact blocks with no more than 10 missing transactions
ea17977
to
8acd39a
Compare
The sentence above is controversial to itself.! EDIT: (not applicable)! |
This is a (somewhat) simpler version of #9447 based on #10652.
It allows for up to 2 simultaneous downloads of the same block at once, as long as the second one is using compact blocks and only has up to 10 transactions to request in a getblocktxn (if applicable).