merge bitcoin#22107: rename GetSystemTimeInSeconds to GetTimeSeconds

This commit is contained in:
Kittywhiskers Van Gogh 2024-03-26 17:22:54 +00:00
parent 2e55327f55
commit e89c555b0f
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
8 changed files with 15 additions and 15 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -878,7 +878,7 @@ size_t CConnman::SocketSendData(CNode& node)
nBytes = send(node.hSocket, reinterpret_cast<const char*>(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<int64_t> 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),

View File

@ -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

View File

@ -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));

View File

@ -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);
}

View File

@ -115,7 +115,7 @@ int64_t GetTimeMicros()
return int64_t{GetSystemTime<std::chrono::microseconds>().count()};
}
int64_t GetSystemTimeInSeconds()
int64_t GetTimeSeconds()
{
return int64_t{GetSystemTime<std::chrono::seconds>().count()};
}

View File

@ -44,7 +44,7 @@ inline double CountSecondsDouble(SecondsDouble t) { return t.count(); }
/**
* DEPRECATED
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
* Use either GetTimeSeconds (not mockable) or GetTime<T> (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