• Daniel Kraft's avatar
    net: Avoid duplicate getheaders requests. · 38874de5
    Daniel Kraft authored
    The current logic for syncing headers may lead to lots of duplicate
    getheaders requests being sent:  If a new block arrives while the node
    is in headers sync, it will send getheaders in response to the block
    announcement.  When the headers arrive, the message will be of maximum
    size and so a follow-up request will be sent---all of that in addition
    to the existing headers syncing.  This will create a second "chain" of
    getheaders requests.  If more blocks arrive, this may even lead to
    arbitrarily many parallel chains of redundant requests.
    
    This patch changes the behaviour to only request more headers after a
    maximum-sized message when it contained at least one unknown header.
    This avoids sustaining parallel chains of redundant requests.
    
    Note that this patch avoids the issues raised in the discussion of
    https://github.com/bitcoin/bitcoin/pull/6821:  There is no risk of the
    node being permanently blocked.  At the latest when a new block arrives
    this will trigger a new getheaders request and restart syncing.
    38874de5
main.cpp 226 KB