aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-01-06 11:12:51 +0000
committerJohn Newbery <john@johnnewbery.com>2021-01-19 10:50:36 +0000
commitbf100f8170770544fb39ae6802175c564cde532f (patch)
tree2c006ffa5597e9ddeffcd5ca8667a4458b2407ca /src/net.h
parent06fa85cd50b718fecd69f0481740d2b8714a1397 (diff)
downloadbitcoin-bf100f8170770544fb39ae6802175c564cde532f.tar.xz
[net] Cleanup InactivityChecks() and add commenting about time
Also clean up and better comment the function. InactivityChecks() uses a mixture of (non-mockable) system time and mockable time. Make sure that's well documented. Despite being marked as const in CConnman before this commit, the function did mutate the state of the passed in CNode, which is contained in vNodes, which is a member of CConnman. To make the function truly const in CConnman and all its data, instead make InactivityChecks() a pure function, return whether the peer should be disconnected, and let the calling function (SocketHandler()) update the CNode object. Also make the CNode& argument const.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/net.h b/src/net.h
index 6bc19f7148..3a1b55d054 100644
--- a/src/net.h
+++ b/src/net.h
@@ -1044,7 +1044,8 @@ private:
void AcceptConnection(const ListenSocket& hListenSocket);
void DisconnectNodes();
void NotifyNumConnectionsChanged();
- void InactivityCheck(CNode& node) const;
+ /** Return true if the peer is inactive and should be disconnected. */
+ bool InactivityCheck(const CNode& node) const;
bool GenerateSelectSet(std::set<SOCKET> &recv_set, std::set<SOCKET> &send_set, std::set<SOCKET> &error_set);
void SocketEvents(std::set<SOCKET> &recv_set, std::set<SOCKET> &send_set, std::set<SOCKET> &error_set);
void SocketHandler();