Skip to content

Commit 62d9ff9

Browse files
committed
Merge bitcoin/bitcoin#22107: scripted-diff: rename GetSystemTimeInSeconds to GetTimeSeconds
feb72e5 scripted-diff: rename GetSystemTimeInSeconds to GetTimeSeconds (fanquake) Pull request description: This PR simply renames `GetSystemTimeInSeconds` to `GetTimeSeconds`, for uniformity amongst our time handling functions (`GetTimeMillis`, `GetTimeMicros`). I have a branch that does a chunk of `GetTime()` -> `GetSystemTimeInSeconds` (`GetTimeSeconds`) / `GetTime<T>` migration, so we can eventually remove the (2 year) deprecated `GetTime()`. However, splitting this off and doing the renaming first while the number of `GetSystemTimeInSeconds` instances is small seems worthwhile. ACKs for top commit: practicalswift: cr ACK feb72e5: patch looks correct promag: Code review ACK feb72e5. Tree-SHA512: e2ac30be9cbcd77b70c9f74bef820b558945d0fcc6f3dc59fde68a18d08a7d36f42088b804ffe7c03478c8db048615b4c4aa65a3d8d9f5d717d59b58c99f1c54
2 parents 684e687 + feb72e5 commit 62d9ff9

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
418418
if (conn_type == "addr-fetch") return "addr";
419419
return "";
420420
}
421-
const int64_t m_time_now{GetSystemTimeInSeconds()};
421+
const int64_t m_time_now{GetTimeSeconds()};
422422

423423
public:
424424
static constexpr int ID_PEERINFO = 0;

src/net.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ size_t CConnman::SocketSendData(CNode& node) const
796796
nBytes = send(node.hSocket, reinterpret_cast<const char*>(data.data()) + node.nSendOffset, data.size() - node.nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT);
797797
}
798798
if (nBytes > 0) {
799-
node.nLastSend = GetSystemTimeInSeconds();
799+
node.nLastSend = GetTimeSeconds();
800800
node.nSendBytes += nBytes;
801801
node.nSendOffset += nBytes;
802802
nSentSize += nBytes;
@@ -1251,15 +1251,15 @@ void CConnman::NotifyNumConnectionsChanged()
12511251

12521252
bool CConnman::ShouldRunInactivityChecks(const CNode& node, std::optional<int64_t> now_in) const
12531253
{
1254-
const int64_t now = now_in ? now_in.value() : GetSystemTimeInSeconds();
1254+
const int64_t now = now_in ? now_in.value() : GetTimeSeconds();
12551255
return node.nTimeConnected + m_peer_connect_timeout < now;
12561256
}
12571257

12581258
bool CConnman::InactivityCheck(const CNode& node) const
12591259
{
12601260
// Use non-mockable system time (otherwise these timers will pop when we
12611261
// use setmocktime in the tests).
1262-
int64_t now = GetSystemTimeInSeconds();
1262+
int64_t now = GetTimeSeconds();
12631263

12641264
if (!ShouldRunInactivityChecks(node, now)) return false;
12651265

@@ -2912,7 +2912,7 @@ ServiceFlags CConnman::GetLocalServices() const
29122912
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
29132913

29142914
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)
2915-
: nTimeConnected(GetSystemTimeInSeconds()),
2915+
: nTimeConnected(GetTimeSeconds()),
29162916
addr(addrIn),
29172917
addrBind(addrBindIn),
29182918
m_inbound_onion(inbound_onion),

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ void RPCConsole::updateDetailWidget()
11051105
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ? ts.from : QLatin1Char('/') + ts.from);
11061106
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = ts.no;
11071107
ui->peerHighBandwidth->setText(bip152_hb_settings);
1108-
const int64_t time_now{GetSystemTimeInSeconds()};
1108+
const int64_t time_now{GetTimeSeconds()};
11091109
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
11101110
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
11111111
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime));

src/test/util_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(util_FormatParseISO8601DateTime)
182182
BOOST_CHECK_EQUAL(ParseISO8601DateTime("1960-01-01T00:00:00Z"), 0);
183183
BOOST_CHECK_EQUAL(ParseISO8601DateTime("2011-09-30T23:36:17Z"), 1317425777);
184184

185-
auto time = GetSystemTimeInSeconds();
185+
auto time = GetTimeSeconds();
186186
BOOST_CHECK_EQUAL(ParseISO8601DateTime(FormatISO8601DateTime(time)), time);
187187
}
188188

src/util/time.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int64_t GetTimeMicros()
124124
return int64_t{GetSystemTime<std::chrono::microseconds>().count()};
125125
}
126126

127-
int64_t GetSystemTimeInSeconds()
127+
int64_t GetTimeSeconds()
128128
{
129129
return int64_t{GetSystemTime<std::chrono::seconds>().count()};
130130
}

src/util/time.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline double CountSecondsDouble(SecondsDouble t) { return t.count(); }
3939

4040
/**
4141
* DEPRECATED
42-
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
42+
* Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
4343
*/
4444
int64_t GetTime();
4545

@@ -48,7 +48,7 @@ int64_t GetTimeMillis();
4848
/** Returns the system time (not mockable) */
4949
int64_t GetTimeMicros();
5050
/** Returns the system time (not mockable) */
51-
int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
51+
int64_t GetTimeSeconds(); // Like GetTime(), but not mockable
5252

5353
/**
5454
* DEPRECATED

0 commit comments

Comments
 (0)