Skip to content

Commit fae1d9c

Browse files
author
MarcoFalke
committed
refactor: Remove unused GetTimeMillis
The function is unused, not type-safe, and does not denote the underlying clock type. So remove it.
1 parent 322ec63 commit fae1d9c

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

src/bench/util_time.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void BenchTimeMillis(benchmark::Bench& bench)
3232
static void BenchTimeMillisSys(benchmark::Bench& bench)
3333
{
3434
bench.run([&] {
35-
(void)GetTimeMillis();
35+
(void)TicksSinceEpoch<std::chrono::milliseconds>(SystemClock::now());
3636
});
3737
}
3838

src/rpc/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,15 @@ static RPCHelpMan getaddednodeinfo()
512512
static RPCHelpMan getnettotals()
513513
{
514514
return RPCHelpMan{"getnettotals",
515-
"\nReturns information about network traffic, including bytes in, bytes out,\n"
516-
"and current time.\n",
517-
{},
515+
"Returns information about network traffic, including bytes in, bytes out,\n"
516+
"and current system time.",
517+
{},
518518
RPCResult{
519519
RPCResult::Type::OBJ, "", "",
520520
{
521521
{RPCResult::Type::NUM, "totalbytesrecv", "Total bytes received"},
522522
{RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"},
523-
{RPCResult::Type::NUM_TIME, "timemillis", "Current " + UNIX_EPOCH_TIME + " in milliseconds"},
523+
{RPCResult::Type::NUM_TIME, "timemillis", "Current system " + UNIX_EPOCH_TIME + " in milliseconds"},
524524
{RPCResult::Type::OBJ, "uploadtarget", "",
525525
{
526526
{RPCResult::Type::NUM, "timeframe", "Length of the measuring timeframe in seconds"},
@@ -544,7 +544,7 @@ static RPCHelpMan getnettotals()
544544
UniValue obj(UniValue::VOBJ);
545545
obj.pushKV("totalbytesrecv", connman.GetTotalBytesRecv());
546546
obj.pushKV("totalbytessent", connman.GetTotalBytesSent());
547-
obj.pushKV("timemillis", GetTimeMillis());
547+
obj.pushKV("timemillis", TicksSinceEpoch<std::chrono::milliseconds>(SystemClock::now()));
548548

549549
UniValue outboundLimit(UniValue::VOBJ);
550550
outboundLimit.pushKV("timeframe", count_seconds(connman.GetMaxOutboundTimeframe()));

src/util/time.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ NodeClock::time_point NodeClock::now() noexcept
7878
return time_point{ret};
7979
};
8080

81-
template <typename T>
82-
static T GetSystemTime()
83-
{
84-
const auto now = std::chrono::duration_cast<T>(std::chrono::system_clock::now().time_since_epoch());
85-
assert(now.count() > 0);
86-
return now;
87-
}
88-
8981
void SetMockTime(int64_t nMockTimeIn)
9082
{
9183
Assert(nMockTimeIn >= 0);
@@ -102,11 +94,6 @@ std::chrono::seconds GetMockTime()
10294
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));
10395
}
10496

105-
int64_t GetTimeMillis()
106-
{
107-
return int64_t{GetSystemTime<std::chrono::milliseconds>().count()};
108-
}
109-
11097
int64_t GetTime() { return GetTime<std::chrono::seconds>().count(); }
11198

11299
std::string FormatISO8601DateTime(int64_t nTime) {

src/util/time.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ using MillisecondsDouble = std::chrono::duration<double, std::chrono::millisecon
7171
*/
7272
int64_t GetTime();
7373

74-
/** Returns the system time (not mockable) */
75-
int64_t GetTimeMillis();
76-
7774
/**
7875
* DEPRECATED
7976
* Use SetMockTime with chrono type

0 commit comments

Comments
 (0)