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).
This commit is contained in:
Suhas Daftuar
2017-10-24 16:56:07 -04:00
parent db32a65897
commit ac7b37cd2b
5 changed files with 114 additions and 6 deletions

View File

@@ -1701,6 +1701,7 @@ bool CConnman::GetTryNewOutboundPeer()
void CConnman::SetTryNewOutboundPeer(bool flag)
{
m_try_another_outbound_peer = flag;
LogPrint(BCLog::NET, "net: setting try another outbound peer=%s\n", flag ? "true" : "false");
}
// Return the number of peers we have over our outbound connection limit