aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_bitcoin_main.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2017-10-12 13:55:43 -0400
committerMarcoFalke <falke.marco@gmail.com>2017-11-02 13:18:34 -0400
commit9961abf9e469da17a3142697007fb810ca88c145 (patch)
treebd174ea3414f569aa76fbb993d9d144918413acd /src/test/test_bitcoin_main.cpp
parentbf191a71836f357d7949459f666db506dffd123b (diff)
downloadbitcoin-9961abf9e469da17a3142697007fb810ca88c145.tar.xz
Permit disconnection of outbound peers on bad/slow chains
Currently we have no rotation of outbound peers. If an outbound peer stops serving us blocks, or is on a consensus-incompatible chain with less work than our tip (but otherwise valid headers), then we will never disconnect that peer, even though that peer is using one of our 8 outbound connection slots. Because we rely on our outbound peers to find an honest node in order to reach consensus, allowing an incompatible peer to occupy one of those slots is undesirable, particularly if it is possible for all such slots to be occupied by such peers. Protect against this by always checking to see if a peer's best known block has less work than our tip, and if so, set a 20 minute timeout -- if the peer is still not known to have caught up to a chain with as much work as ours after 20 minutes, then send a single getheaders message, wait 2 more minutes, and if a better header hasn't been received by then, disconnect that peer. Note: - we do not require that our peer sync to the same tip as ours, just an equal or greater work tip. (Doing otherwise would risk partitioning the network in the event of a chain split, and is also unnecessary.) - we pick 4 of our outbound peers and do not subject them to this logic, to be more conservative. We don't wish to permit temporary network issues (or an attacker) to excessively disrupt network topology. Github-Pull: #11490 Rebased-From: 5a6d00c6defc587e22c93e63029fdd538ce8858d
Diffstat (limited to 'src/test/test_bitcoin_main.cpp')
0 files changed, 0 insertions, 0 deletions