diff options
author | John Newbery <john@johnnewbery.com> | 2021-01-06 11:12:51 +0000 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-01-19 10:50:36 +0000 |
commit | bf100f8170770544fb39ae6802175c564cde532f (patch) | |
tree | 2c006ffa5597e9ddeffcd5ca8667a4458b2407ca /src/net.h | |
parent | 06fa85cd50b718fecd69f0481740d2b8714a1397 (diff) |
[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.h | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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(); |