Page MenuHomePhabricator

Connect to a new outbound peer if our tip is stale
ClosedPublic

Authored by deadalnix on Sep 12 2018, 18:16.

Details

Summary
  • net: Allow connecting to extra outbound peers
  • Track tip update time and last new block announcement from each peer
  • Add CConnmanTest to mutate g_connman in tests
  • Connect to an extra outbound peer if our tip is stale

If our tip hasn't updated in a while, that may be because our peers are
not relaying blocks to us that we would consider valid. Allow connection
to an additional outbound peer in that circumstance.

Also, periodically check to see if we are exceeding our target number of
outbound peers, and disconnect the one which has least recently
announced a new block to us (choosing the newest such peer in the case
of tie).

  • Add scheduler to the testing setup
  • Add unit test for stale tip checking

This is a backport of core PR11560

Depends on D1778 and D1776

Test Plan
make check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

schancel added a subscriber: schancel.
schancel added inline comments.
src/net_processing.cpp
3455 ↗(On Diff #4905)
if (extra_peers <= 0) {
   return;
}
3488 ↗(On Diff #4905)
if(worst_peer == -1) {
   return;
}
3536 ↗(On Diff #4905)
if (time_in_seconds < m_stale_tip_check_time) {
    // Tip not stale, no need to try new outbound peers
    return;
}
This revision is now accepted and ready to land.Sep 18 2018, 02:28
This revision was automatically updated to reflect the committed changes.