Track peers' available blocks #4407

pull sipa wants to merge 1 commits into bitcoin:master from sipa:headersfirst7 changing 3 files +48 −0
  1. sipa commented at 11:55 PM on June 24, 2014: member

    A small piece of logic that will be needed in headersfirst: knowing up to which point each peer is synchronized. As we no longer react on specific messages to trigger fetching blocks, but instead actively & asynchronously fetch what we're missing, we must know what we can ask from whom.

    This is not very useful now, except that it adds 'syncheight' to getpeerinfo (which is much more meaningful than startingheight, imho).

  2. laanwj commented at 5:15 AM on June 25, 2014: member

    'syncheight' looks like very useful information, will merge this into my testing nodes.

  3. jgarzik commented at 1:46 PM on June 26, 2014: contributor

    Looks OK to me... but it makes me nervous to add additional places in the code where a "valid hash equalling zero" may accidentally trigger undesired behavior.

    There was some discussion on IRC of separating uint256 and opaque_hash types. If such were the case, this code would not compile.

  4. gavinandresen commented at 3:11 PM on June 26, 2014: contributor

    ACK after code review and compiling/running/syncing a week's worth of blocks on OSX.

  5. in src/main.cpp:None in 04e4dfa40c outdated
    4498 | @@ -4453,6 +4499,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
    4499 |              pto->fDisconnect = true;
    4500 |          }
    4501 |  
    4502 | +        // Update knowledge of peer's block availability.
    


    laanwj commented at 8:16 AM on June 27, 2014:

    I have problems wrapping my head around this one. Why is the knowledge of block availability of the node set to 0 here at this point in SendMessage?


    sipa commented at 9:12 AM on June 27, 2014:

    There is no new information in this case, but hashLastUnknownBlock may after a while refer to a known one, so we want to update hashBestKnownBlock in that case. It's just done here because SendMessages is called periodically.

  6. sipa commented at 3:41 PM on June 29, 2014: member

    Rebased. @laanwj Any suggestion for a better method name, as the current name seems to confuse you? Maybe "ProcessBlockAvailability" ?

  7. laanwj commented at 4:02 PM on June 29, 2014: member

    @sipa Another option would be to split the function in two, an UpdateBlockAvailablity(node) for the first part and a ProcessBlockAvailability(node, hash) for the second part (or better names). That would remove the need for special-casing uint256(0) as well.

  8. sipa commented at 6:58 PM on June 29, 2014: member

    @laanwj Good idea, done.

  9. Track peers' available blocks aa81564700
  10. BitcoinPullTester commented at 8:06 PM on June 29, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4407_aa815647005bc8467f467c35a9e617794446cd64/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  11. gavinandresen merged this on Jun 30, 2014
  12. gavinandresen closed this on Jun 30, 2014

  13. MarcoFalke locked this on Sep 8, 2021

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-04-19 09:15 UTC

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