LearnBitcoin

Bitcoin Dev Archive 2015

Initial getheaders request

1 message, 13 Oct 2015. Started by Daniel Kraft.

Daniel Kraft

Permalink Original thread on gnusha.org

Daniel Kraft permalink original

Hi!

I've stumbled upon the code that does the initial "getheaders" request, i. e., around line 4960 of src/main.cpp [1].

  [1] https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L4960

For some reason, it uses not pindexBestHeader but the *preceding* block pindexBestHeader->pprev as the "from argument". In contrast, the request on line 4132 [2] (which is done in response to a newly announced block) *does* use pindexBestHeader.

  [2] https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L4132

I see no apparent reason for using the preceding call; but if I change it to pindexBestHeader on line 4960 as well, the wallet.py test seems to get stuck. I've not been able to figure out from the logs and the code why this is the case; can anyone help me? I think this is something that should really be explained in a comment around line 4960. If someone can make me understand, I can write a pull request for that -- I guess this will save others some time wondering like I do at the moment.

Yours, Daniel