mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
net: clarify if we ever sent or received from peer
This commit is contained in:
parent
1d01ad4d73
commit
06443b8f28
2 changed files with 11 additions and 6 deletions
13
src/net.cpp
13
src/net.cpp
|
@ -1982,12 +1982,17 @@ bool CConnman::InactivityCheck(const CNode& node) const
|
||||||
|
|
||||||
if (!ShouldRunInactivityChecks(node, now)) return false;
|
if (!ShouldRunInactivityChecks(node, now)) return false;
|
||||||
|
|
||||||
if (last_recv.count() == 0 || last_send.count() == 0) {
|
bool has_received{last_recv.count() != 0};
|
||||||
|
bool has_sent{last_send.count() != 0};
|
||||||
|
|
||||||
|
if (!has_received || !has_sent) {
|
||||||
|
std::string has_never;
|
||||||
|
if (!has_received) has_never += ", never received from peer";
|
||||||
|
if (!has_sent) has_never += ", never sent to peer";
|
||||||
LogDebug(BCLog::NET,
|
LogDebug(BCLog::NET,
|
||||||
"socket no message in first %i seconds, %d %d, %s\n",
|
"socket no message in first %i seconds%s, %s\n",
|
||||||
count_seconds(m_peer_connect_timeout),
|
count_seconds(m_peer_connect_timeout),
|
||||||
last_recv.count() != 0,
|
has_never,
|
||||||
last_send.count() != 0,
|
|
||||||
node.DisconnectMsg(fLogIPs)
|
node.DisconnectMsg(fLogIPs)
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -91,8 +91,8 @@ class TimeoutsTest(BitcoinTestFramework):
|
||||||
else:
|
else:
|
||||||
expected_timeout_logs = [
|
expected_timeout_logs = [
|
||||||
"version handshake timeout, disconnecting peer=0",
|
"version handshake timeout, disconnecting peer=0",
|
||||||
"socket no message in first 3 seconds, 1 0, disconnecting peer=1",
|
"socket no message in first 3 seconds, never sent to peer, disconnecting peer=1",
|
||||||
"socket no message in first 3 seconds, 0 0, disconnecting peer=2",
|
"socket no message in first 3 seconds, never received from peer, never sent to peer, disconnecting peer=2",
|
||||||
]
|
]
|
||||||
|
|
||||||
with self.nodes[0].assert_debug_log(expected_msgs=expected_timeout_logs):
|
with self.nodes[0].assert_debug_log(expected_msgs=expected_timeout_logs):
|
||||||
|
|
Loading…
Reference in a new issue