refactor: Remove unused GetTimeMillis

The function is unused, not type-safe, and does not denote the
underlying clock type. So remove it.
This commit is contained in:
MarcoFalke 2023-05-08 12:37:57 +02:00
parent 322ec63b01
commit fae1d9cded
No known key found for this signature in database
4 changed files with 6 additions and 22 deletions

View File

@ -32,7 +32,7 @@ static void BenchTimeMillis(benchmark::Bench& bench)
static void BenchTimeMillisSys(benchmark::Bench& bench) static void BenchTimeMillisSys(benchmark::Bench& bench)
{ {
bench.run([&] { bench.run([&] {
(void)GetTimeMillis(); (void)TicksSinceEpoch<std::chrono::milliseconds>(SystemClock::now());
}); });
} }

View File

@ -512,15 +512,15 @@ static RPCHelpMan getaddednodeinfo()
static RPCHelpMan getnettotals() static RPCHelpMan getnettotals()
{ {
return RPCHelpMan{"getnettotals", return RPCHelpMan{"getnettotals",
"\nReturns information about network traffic, including bytes in, bytes out,\n" "Returns information about network traffic, including bytes in, bytes out,\n"
"and current time.\n", "and current system time.",
{}, {},
RPCResult{ RPCResult{
RPCResult::Type::OBJ, "", "", RPCResult::Type::OBJ, "", "",
{ {
{RPCResult::Type::NUM, "totalbytesrecv", "Total bytes received"}, {RPCResult::Type::NUM, "totalbytesrecv", "Total bytes received"},
{RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"}, {RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"},
{RPCResult::Type::NUM_TIME, "timemillis", "Current " + UNIX_EPOCH_TIME + " in milliseconds"}, {RPCResult::Type::NUM_TIME, "timemillis", "Current system " + UNIX_EPOCH_TIME + " in milliseconds"},
{RPCResult::Type::OBJ, "uploadtarget", "", {RPCResult::Type::OBJ, "uploadtarget", "",
{ {
{RPCResult::Type::NUM, "timeframe", "Length of the measuring timeframe in seconds"}, {RPCResult::Type::NUM, "timeframe", "Length of the measuring timeframe in seconds"},
@ -544,7 +544,7 @@ static RPCHelpMan getnettotals()
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.pushKV("totalbytesrecv", connman.GetTotalBytesRecv()); obj.pushKV("totalbytesrecv", connman.GetTotalBytesRecv());
obj.pushKV("totalbytessent", connman.GetTotalBytesSent()); obj.pushKV("totalbytessent", connman.GetTotalBytesSent());
obj.pushKV("timemillis", GetTimeMillis()); obj.pushKV("timemillis", TicksSinceEpoch<std::chrono::milliseconds>(SystemClock::now()));
UniValue outboundLimit(UniValue::VOBJ); UniValue outboundLimit(UniValue::VOBJ);
outboundLimit.pushKV("timeframe", count_seconds(connman.GetMaxOutboundTimeframe())); outboundLimit.pushKV("timeframe", count_seconds(connman.GetMaxOutboundTimeframe()));

View File

@ -78,14 +78,6 @@ NodeClock::time_point NodeClock::now() noexcept
return time_point{ret}; return time_point{ret};
}; };
template <typename T>
static T GetSystemTime()
{
const auto now = std::chrono::duration_cast<T>(std::chrono::system_clock::now().time_since_epoch());
assert(now.count() > 0);
return now;
}
void SetMockTime(int64_t nMockTimeIn) void SetMockTime(int64_t nMockTimeIn)
{ {
Assert(nMockTimeIn >= 0); Assert(nMockTimeIn >= 0);
@ -102,11 +94,6 @@ std::chrono::seconds GetMockTime()
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed)); return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));
} }
int64_t GetTimeMillis()
{
return int64_t{GetSystemTime<std::chrono::milliseconds>().count()};
}
int64_t GetTime() { return GetTime<std::chrono::seconds>().count(); } int64_t GetTime() { return GetTime<std::chrono::seconds>().count(); }
std::string FormatISO8601DateTime(int64_t nTime) { std::string FormatISO8601DateTime(int64_t nTime) {

View File

@ -71,9 +71,6 @@ using MillisecondsDouble = std::chrono::duration<double, std::chrono::millisecon
*/ */
int64_t GetTime(); int64_t GetTime();
/** Returns the system time (not mockable) */
int64_t GetTimeMillis();
/** /**
* DEPRECATED * DEPRECATED
* Use SetMockTime with chrono type * Use SetMockTime with chrono type