diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index b1631e410b..92334ba28b 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -426,7 +426,7 @@ private: "See this help\n" "> dash-cli -netinfo help\n"}; } - const int64_t m_time_now{GetSystemTimeInSeconds()}; + const int64_t m_time_now{GetTimeSeconds()}; public: static constexpr int ID_PEERINFO = 0; diff --git a/src/masternode/utils.cpp b/src/masternode/utils.cpp index 651264d3f8..2946913955 100644 --- a/src/masternode/utils.cpp +++ b/src/masternode/utils.cpp @@ -48,7 +48,7 @@ void CMasternodeUtils::DoMaintenance(CConnman& connman, const CMasternodeSync& m connman.ForEachNode(CConnman::AllNodes, [&](CNode* pnode) { if (pnode->m_masternode_probe_connection) { // we're not disconnecting masternode probes for at least PROBE_WAIT_INTERVAL seconds - if (GetSystemTimeInSeconds() - pnode->nTimeConnected < PROBE_WAIT_INTERVAL) return; + if (GetTimeSeconds() - pnode->nTimeConnected < PROBE_WAIT_INTERVAL) return; } else { // we're only disconnecting m_masternode_connection connections if (!pnode->m_masternode_connection) return; @@ -65,7 +65,7 @@ void CMasternodeUtils::DoMaintenance(CConnman& connman, const CMasternodeSync& m if (pnode->IsInboundConn()) { return; } - } else if (GetSystemTimeInSeconds() - pnode->nTimeConnected < 5) { + } else if (GetTimeSeconds() - pnode->nTimeConnected < 5) { // non-verified, give it some time to verify itself return; } else if (pnode->qwatch) { diff --git a/src/net.cpp b/src/net.cpp index b114a4b1ae..49324f1412 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -878,7 +878,7 @@ size_t CConnman::SocketSendData(CNode& node) nBytes = send(node.hSocket, reinterpret_cast(data.data()) + node.nSendOffset, data.size() - node.nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT); } if (nBytes > 0) { - node.nLastSend = GetSystemTimeInSeconds(); + node.nLastSend = GetTimeSeconds(); node.nSendBytes += nBytes; node.nSendOffset += nBytes; nSentSize += nBytes; @@ -1072,7 +1072,7 @@ bool CConnman::AttemptToEvictConnection() // was accepted. This short time is meant for the VERSION/VERACK exchange and the possible MNAUTH that might // 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 = GetSystemTimeInSeconds() - node->nTimeConnected < INBOUND_EVICTION_PROTECTION_TIME; + bool isProtected = GetTimeSeconds() - node->nTimeConnected < INBOUND_EVICTION_PROTECTION_TIME; if (node->nTimeFirstMessageReceived != 0 && !node->fFirstMessageIsMNAUTH) { isProtected = false; } @@ -1490,7 +1490,7 @@ void CConnman::CalculateNumConnectionsChangedStats() bool CConnman::ShouldRunInactivityChecks(const CNode& node, std::optional now_in) const { - const int64_t now = now_in ? now_in.value() : GetSystemTimeInSeconds(); + const int64_t now = now_in ? now_in.value() : GetTimeSeconds(); return node.nTimeConnected + m_peer_connect_timeout < now; } @@ -1498,7 +1498,7 @@ bool CConnman::InactivityCheck(const CNode& node) const { // Use non-mockable system time (otherwise these timers will pop when we // use setmocktime in the tests). - int64_t now = GetSystemTimeInSeconds(); + int64_t now = GetTimeSeconds(); if (!ShouldRunInactivityChecks(node, now)) return false; @@ -2718,7 +2718,7 @@ void CConnman::ThreadOpenMasternodeConnections() // 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 && GetSystemTimeInSeconds() - pnode->nTimeFirstMessageReceived > 5) { + if (pnode->nTimeFirstMessageReceived != 0 && GetTimeSeconds() - pnode->nTimeFirstMessageReceived > 5) { // 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.ToString(false)); @@ -4033,7 +4033,7 @@ ServiceFlags CConnman::GetLocalServices() const unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; } CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion) - : nTimeConnected(GetSystemTimeInSeconds()), + : nTimeConnected(GetTimeSeconds()), addr(addrIn), addrBind(addrBindIn), nKeyedNetGroup(nKeyedNetGroupIn), diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 47ba9c613d..23cd76cc7e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3342,7 +3342,7 @@ void PeerManagerImpl::ProcessMessage( if (pfrom.nTimeFirstMessageReceived == 0) { // First message after VERSION/VERACK - pfrom.nTimeFirstMessageReceived = GetSystemTimeInSeconds(); + pfrom.nTimeFirstMessageReceived = GetTimeSeconds(); pfrom.fFirstMessageIsMNAUTH = msg_type == NetMsgType::MNAUTH; // Note: do not break the flow here diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 30f393ba60..9a05ddb62b 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1244,7 +1244,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats) ui->peerHeading->setText(peerAddrDetails); ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices)); ui->peerRelayTxes->setText(stats->nodeStats.fRelayTxes ? "Yes" : "No"); - const int64_t time_now{GetSystemTimeInSeconds()}; + const int64_t time_now{GetTimeSeconds()}; ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected)); ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime)); ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime)); diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index a0f743a6e7..d5eafe2824 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(util_FormatParseISO8601DateTime) BOOST_CHECK_EQUAL(ParseISO8601DateTime("1960-01-01T00:00:00Z"), 0); BOOST_CHECK_EQUAL(ParseISO8601DateTime("2011-09-30T23:36:17Z"), 1317425777); - auto time = GetSystemTimeInSeconds(); + auto time = GetTimeSeconds(); BOOST_CHECK_EQUAL(ParseISO8601DateTime(FormatISO8601DateTime(time)), time); } diff --git a/src/util/time.cpp b/src/util/time.cpp index d8f37f5843..14183d540d 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -115,7 +115,7 @@ int64_t GetTimeMicros() return int64_t{GetSystemTime().count()}; } -int64_t GetSystemTimeInSeconds() +int64_t GetTimeSeconds() { return int64_t{GetSystemTime().count()}; } diff --git a/src/util/time.h b/src/util/time.h index 3eefa353ae..36300b29fd 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -44,7 +44,7 @@ inline double CountSecondsDouble(SecondsDouble t) { return t.count(); } /** * DEPRECATED - * Use either GetSystemTimeInSeconds (not mockable) or GetTime (mockable) + * Use either GetTimeSeconds (not mockable) or GetTime (mockable) */ int64_t GetTime(); @@ -53,7 +53,7 @@ int64_t GetTimeMillis(); /** Returns the system time (not mockable) */ int64_t GetTimeMicros(); /** Returns the system time (not mockable) */ -int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable +int64_t GetTimeSeconds(); // Like GetTime(), but not mockable /** * DEPRECATED