diff --git a/src/net.cpp b/src/net.cpp index 45ebdafbf9..f3e0455390 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1901,7 +1901,7 @@ bool CConnman::AttemptToEvictConnection() // follow when the incoming connection is from another masternode. When a message other than MNAUTH // is received after VERSION/VERACK, the protection is lifted immediately. bool isProtected = GetTime() - node->m_connected < INBOUND_EVICTION_PROTECTION_TIME; - if (node->nTimeFirstMessageReceived != 0 && !node->fFirstMessageIsMNAUTH) { + if (node->nTimeFirstMessageReceived.load() != 0s && !node->fFirstMessageIsMNAUTH) { isProtected = false; } // if MNAUTH was valid, the node is always protected (and at the same time not accounted when @@ -3754,7 +3754,7 @@ void CConnman::ThreadOpenMasternodeConnections(CDeterministicMNManager& dmnman, // we probably connected to it before it became a masternode // or maybe we are still waiting for mnauth (void)ForNode(addr2, [&](CNode* pnode) { - if (pnode->nTimeFirstMessageReceived != 0 && GetTimeSeconds() - pnode->nTimeFirstMessageReceived > 5) { + if (pnode->nTimeFirstMessageReceived.load() != 0s && GetTime() - pnode->nTimeFirstMessageReceived.load() > 5s) { // clearly not expecting mnauth to take that long even if it wasn't the first message // we received (as it should normally), disconnect LogPrint(BCLog::NET_NETCONN, "CConnman::%s -- dropping non-mnauth connection to %s, service=%s\n", _func_, proRegTxHash.ToString(), addr2.ToStringAddrPort()); diff --git a/src/net.h b/src/net.h index c0a2b82cde..ae4336bdf9 100644 --- a/src/net.h +++ b/src/net.h @@ -766,7 +766,7 @@ public: const std::chrono::seconds m_connected; std::atomic nTimeOffset{0}; std::atomic nLastWarningTime{0}; - std::atomic nTimeFirstMessageReceived{0}; + std::atomic nTimeFirstMessageReceived{0s}; std::atomic fFirstMessageIsMNAUTH{false}; // Address of this peer const CAddress addr; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 61c3df9d11..88b37aa8e7 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3936,9 +3936,9 @@ void PeerManagerImpl::ProcessMessage( return; } - if (pfrom.nTimeFirstMessageReceived == 0) { + if (pfrom.nTimeFirstMessageReceived.load() == 0s) { // First message after VERSION/VERACK - pfrom.nTimeFirstMessageReceived = GetTimeSeconds(); + pfrom.nTimeFirstMessageReceived = GetTime(); pfrom.fFirstMessageIsMNAUTH = msg_type == NetMsgType::MNAUTH; // Note: do not break the flow here