upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index e4cfa69..112426e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -127,6 +127,25 @@ static const int64 DISCONNECT_DRAIN_SECS = 60;
127// 3966-4085 -- 120 blocks, 5890.50 BTF -- were mined in exactly this state. 127// 3966-4085 -- 120 blocks, 5890.50 BTF -- were mined in exactly this state.
128static const int64 BTF_NO_PEER_HEIGHT_MAX_SECS = 20 * 60; 128static const int64 BTF_NO_PEER_HEIGHT_MAX_SECS = 20 * 60;
129 129
130// How long a peer may leave this node waiting for the rest of a message it
131// announced in a header.
132//
133// ProcessMessages rewinds the header and breaks when the body has not all
134// arrived, which is correct for a message still in flight and unbounded for
135// one that never completes: the same header is re-read, the loop breaks
136// again, and that peer is never parsed again for the life of the process.
137// Satoshi left the note -- "need a mechanism to give up waiting for overlong
138// message size error" -- and this is it.
139//
140// It never self-corrects, because any byte that arrives refreshes nLastRecv,
141// so the inactivity timeout that would otherwise drop the peer never fires.
142// The socket stays healthy, select() keeps reporting it, and the node goes
143// silently deaf one peer at a time.
144//
145// A header may legitimately outrun its body by a round trip or two; two
146// minutes is far beyond that, and well inside BTF_RECV_TIMEOUT_SECS.
147static const int64 BTF_MSG_WAIT_MAX_SECS = 2 * 60;
148
130// Send a ping after this long with nothing to say, so a peer running the 149// Send a ping after this long with nothing to say, so a peer running the
131// inactivity check above does not mistake a quiet node for a dead one. Must 150// inactivity check above does not mistake a quiet node for a dead one. Must
132// stay well under BTF_RECV_TIMEOUT_SECS. 151// stay well under BTF_RECV_TIMEOUT_SECS.
@@ -651,6 +670,10 @@ public:
651 string strBtfAddr; 670 string strBtfAddr;
652 string strBtfMeeting; 671 string strBtfMeeting;
653 672
673 // When this peer's message loop first rewound a header to wait for the
674 // rest of a message, or 0 when it is not waiting. See ProcessMessages.
675 int64 nMsgWaitSince;
676
654 // Height this peer announced in its version message, or -1 if it sent a 677 // Height this peer announced in its version message, or -1 if it sent a
655 // version message that predates the field. Knowing how far along everyone 678 // version message that predates the field. Knowing how far along everyone
656 // else is, is the only way a node can tell "in sync" from "not hearing". 679 // else is, is the only way a node can tell "in sync" from "not hearing".