Skip to content

Commit d769254

Browse files
author
Antoine Riard
committed
[doc] Clarify semantic of peer's m_protect w.r.t to outbound eviction logics
The field m_protect is used to protect from eviction both by bad/lagging chain and extra outbound peers logics. Outbound block-relay peers are always excluded from this protection.
1 parent ac71fe9 commit d769254

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/net_processing.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,17 @@ struct CNodeState {
321321
*/
322322
bool fSupportsDesiredCmpctVersion;
323323

324-
/** State used to enforce CHAIN_SYNC_TIMEOUT
325-
* Only in effect for outbound, non-manual, full-relay connections, with
326-
* m_protect == false
327-
* Algorithm: if a peer's best known block has less work than our tip,
324+
/** State used to enforce CHAIN_SYNC_TIMEOUT and EXTRA_PEER_CHECK_INTERVAL logic.
325+
*
326+
* Both are only in effect for outbound, non-manual, non-protected connections.
327+
* Any peer protected (m_protect = true) is not chosen for eviction. A peer is
328+
* marked as protected if all of these are true:
329+
* - its connection type is IsBlockOnlyConn() == false
330+
* - it gave us a valid connecting header
331+
* - we haven't reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT yet
332+
* - it has a better chain than we have
333+
*
334+
* CHAIN_SYNC_TIMEOUT: if a peer's best known block has less work than our tip,
328335
* set a timeout CHAIN_SYNC_TIMEOUT seconds in the future:
329336
* - If at timeout their best known block now has more work than our tip
330337
* when the timeout was set, then either reset the timeout or clear it
@@ -334,6 +341,9 @@ struct CNodeState {
334341
* and set a shorter timeout, HEADERS_RESPONSE_TIME seconds in future.
335342
* If their best known block is still behind when that new timeout is
336343
* reached, disconnect.
344+
*
345+
* EXTRA_PEER_CHECK_INTERVAL: after each interval, if we have too many outbound peers,
346+
* drop the outbound one that least recently announced us a new block.
337347
*/
338348
struct ChainSyncTimeoutState {
339349
//! A timeout used for checking whether our peer has sufficiently synced

0 commit comments

Comments
 (0)