diff options
author | John Newbery <john@johnnewbery.com> | 2021-01-06 11:07:01 +0000 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-01-13 16:18:12 +0000 |
commit | 06fa85cd50b718fecd69f0481740d2b8714a1397 (patch) | |
tree | 6c751032e8d77d1abce9f170b330cb9a00548f11 | |
parent | e7eb37128c3155f074af5f38974934ce6941b0fb (diff) | |
download | bitcoin-06fa85cd50b718fecd69f0481740d2b8714a1397.tar.xz |
[net] InactivityCheck() takes a CNode reference
-rw-r--r-- | src/net.cpp | 36 | ||||
-rw-r--r-- | src/net.h | 2 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/net.cpp b/src/net.cpp index 4f74bbede4..2e52afa1cc 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1216,35 +1216,35 @@ void CConnman::NotifyNumConnectionsChanged() } } -void CConnman::InactivityCheck(CNode *pnode) const +void CConnman::InactivityCheck(CNode& node) const { int64_t nTime = GetSystemTimeInSeconds(); - if (nTime - pnode->nTimeConnected > m_peer_connect_timeout) + if (nTime - node.nTimeConnected > m_peer_connect_timeout) { - if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) + if (node.nLastRecv == 0 || node.nLastSend == 0) { - LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d from %d\n", m_peer_connect_timeout, pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->GetId()); - pnode->fDisconnect = true; + LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d from %d\n", m_peer_connect_timeout, node.nLastRecv != 0, node.nLastSend != 0, node.GetId()); + node.fDisconnect = true; } - else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL) + else if (nTime - node.nLastSend > TIMEOUT_INTERVAL) { - LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend); - pnode->fDisconnect = true; + LogPrintf("socket sending timeout: %is\n", nTime - node.nLastSend); + node.fDisconnect = true; } - else if (nTime - pnode->nLastRecv > TIMEOUT_INTERVAL) + else if (nTime - node.nLastRecv > TIMEOUT_INTERVAL) { - LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv); - pnode->fDisconnect = true; + LogPrintf("socket receive timeout: %is\n", nTime - node.nLastRecv); + node.fDisconnect = true; } - else if (pnode->nPingNonceSent && pnode->m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} < GetTime<std::chrono::microseconds>()) + else if (node.nPingNonceSent && node.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL} < GetTime<std::chrono::microseconds>()) { - LogPrintf("ping timeout: %fs\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - pnode->m_ping_start.load())); - pnode->fDisconnect = true; + LogPrintf("ping timeout: %fs\n", 0.000001 * count_microseconds(GetTime<std::chrono::microseconds>() - node.m_ping_start.load())); + node.fDisconnect = true; } - else if (!pnode->fSuccessfullyConnected) + else if (!node.fSuccessfullyConnected) { - LogPrint(BCLog::NET, "version handshake timeout from %d\n", pnode->GetId()); - pnode->fDisconnect = true; + LogPrint(BCLog::NET, "version handshake timeout from %d\n", node.GetId()); + node.fDisconnect = true; } } } @@ -1522,7 +1522,7 @@ void CConnman::SocketHandler() if (bytes_sent) RecordBytesSent(bytes_sent); } - InactivityCheck(pnode); + InactivityCheck(*pnode); } { LOCK(cs_vNodes); @@ -1044,7 +1044,7 @@ private: void AcceptConnection(const ListenSocket& hListenSocket); void DisconnectNodes(); void NotifyNumConnectionsChanged(); - void InactivityCheck(CNode *pnode) const; + void InactivityCheck(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(); |