mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
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:
parent
322ec63b01
commit
fae1d9cded
@ -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());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()));
|
||||||
|
@ -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) {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user