Allow 2 simultaneous (compact-)block downloads #10984

pull TheBlueMatt wants to merge 6 commits into bitcoin:master from TheBlueMatt:2017-08-paralell-block-downloads changing 6 files +234 −94
  1. TheBlueMatt commented at 10:48 PM on August 3, 2017: contributor

    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).

  2. fanquake added the label P2P on Aug 5, 2017
  3. fanquake added the label Validation on Aug 5, 2017
  4. TheBlueMatt force-pushed on Aug 14, 2017
  5. TheBlueMatt force-pushed on Aug 14, 2017
  6. TheBlueMatt commented at 4:10 PM on August 14, 2017: contributor

    Rebased and added a simple test

  7. TheBlueMatt cross-referenced this on Aug 14, 2017 from issue Small step towards demangling cs_main from CNodeState by TheBlueMatt
  8. TheBlueMatt cross-referenced this on Sep 6, 2017 from issue Allow 2 simultaneous block downloads by morcos
  9. TheBlueMatt commented at 9:06 PM on September 27, 2017: contributor

    Rebased.

  10. TheBlueMatt force-pushed on Sep 27, 2017
  11. jonasschnelli commented at 3:40 AM on September 28, 2017: contributor

    Nice work! Obviously concept ACK (have not looked closely at the code yet).

  12. in src/net_processing.cpp:343 in 458feb36fc outdated
     291 | +    while (range.first != range.second) {
     292 | +        BlockDownloadMap::iterator itInFlight = range.first;
     293 | +        range.first++;
     294 | +        if (itInFlight->second.first == nodeid) {
     295 | +            if (clearState) ClearDownloadState(itInFlight);
     296 | +            mmapBlocksInFlight.erase(itInFlight);
    


    promag commented at 11:15 PM on October 10, 2017:

    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++;
        }
    }
    

    TheBlueMatt commented at 6:44 PM on January 11, 2018:

    Heh, thats more lines (and IMO less readable)...

  13. in src/net_processing.cpp:353 in 458feb36fc outdated
     322 | -    }
     323 | -    return false;
     324 | +    LOCK(cs_main);
     325 | +    bool found = false;
     326 | +    std::pair<BlockDownloadMap::iterator, BlockDownloadMap::iterator> range = mmapBlocksInFlight.equal_range(hash);
     327 | +    while (range.first != range.second) {
    


    promag commented at 11:20 PM on October 10, 2017:

    Loose found:

    if (range.first == range.second) return false;
    while (range.first != range.second) {
        ...
    }
    return true;
    

    TheBlueMatt commented at 6:52 PM on January 11, 2018:

    Done.

  14. in src/net_processing.cpp:372 in 458feb36fc outdated
     345 | -    if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
     346 | -        if (pit) {
     347 | -            *pit = &itInFlight->second.second;
     348 | +    std::pair<BlockDownloadMap::iterator, BlockDownloadMap::iterator> range = mmapBlocksInFlight.equal_range(hash);
     349 | +    while (range.first != range.second) {
     350 | +        BlockDownloadMap::iterator itInFlight = range.first;
    


    promag commented at 11:22 PM on October 10, 2017:

    Same as above.


    TheBlueMatt commented at 6:52 PM on January 11, 2018:

    Done.

  15. TheBlueMatt force-pushed on Nov 29, 2017
  16. TheBlueMatt commented at 5:19 PM on November 29, 2017: contributor

    Rebased.

  17. TheBlueMatt cross-referenced this on Nov 29, 2017 from issue Compact Blocks can sometimes take an excruciatingly long time to request transactions by 9124
  18. Turn mapBlocksInFlight into a multimap dc7e41bd6f
  19. Call NewPoWValidBlock callbacks for all new blocks, not just !IBD
    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.
    489b1a3926
  20. MarkBlockAsReceived on NewPoWValidBlock at receive.
    The received block could be malleated, so this is both simpler, and
    supports parallel downloads.
    c133cfeb9b
  21. Only request full blocks from the peer we thought had the block in-flight
    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)
    a634745469
  22. Allow up to 2 simultaneous downloads of the same block at once
    ...as long as the second one uses compact blocks with no more than
    10 missing transactions
    ee1e8a2507
  23. Add simple parallel compact block download test 8acd39abf6
  24. TheBlueMatt force-pushed on Jan 11, 2018
  25. ajtowns cross-referenced this on Jan 16, 2018 from issue [tests] Rename functional tests by ajtowns
  26. TheBlueMatt cross-referenced this on Feb 4, 2018 from issue Timeout downloading block by jhoenicke
  27. MarcoFalke added the label Needs rebase on Jun 6, 2018
  28. TheBlueMatt closed this on Jun 14, 2018

  29. TheBlueMatt cross-referenced this on Jun 8, 2019 from issue Notes on Block-In-Flight Handling by TheBlueMatt
  30. laanwj removed the label Needs rebase on Oct 24, 2019
  31. iemwill commented at 11:51 AM on February 24, 2021: none

    @TheBlueMatt

    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).

    The sentence above is controversial to itself.!

    EDIT: (not applicable)!

  32. ajtowns cross-referenced this on May 31, 2022 from issue Parallel compact block download by ajtowns
  33. bitcoin locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 11:55 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me