mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 19:50:43 +02:00
refactor: Replace GetTimeMicros by SystemClock
This commit is contained in:
parent
8d12127a9c
commit
faf3f12424
@ -349,11 +349,12 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
|
|||||||
return str;
|
return str;
|
||||||
|
|
||||||
if (m_started_new_line) {
|
if (m_started_new_line) {
|
||||||
int64_t nTimeMicros = GetTimeMicros();
|
const auto now{SystemClock::now()};
|
||||||
strStamped = FormatISO8601DateTime(nTimeMicros/1000000);
|
const auto now_seconds{std::chrono::time_point_cast<std::chrono::seconds>(now)};
|
||||||
|
strStamped = FormatISO8601DateTime(TicksSinceEpoch<std::chrono::seconds>(now_seconds));
|
||||||
if (m_log_time_micros) {
|
if (m_log_time_micros) {
|
||||||
strStamped.pop_back();
|
strStamped.pop_back();
|
||||||
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
strStamped += strprintf(".%06dZ", Ticks<std::chrono::microseconds>(now - now_seconds));
|
||||||
}
|
}
|
||||||
std::chrono::seconds mocktime = GetMockTime();
|
std::chrono::seconds mocktime = GetMockTime();
|
||||||
if (mocktime > 0s) {
|
if (mocktime > 0s) {
|
||||||
|
@ -107,11 +107,6 @@ int64_t GetTimeMillis()
|
|||||||
return int64_t{GetSystemTime<std::chrono::milliseconds>().count()};
|
return int64_t{GetSystemTime<std::chrono::milliseconds>().count()};
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetTimeMicros()
|
|
||||||
{
|
|
||||||
return int64_t{GetSystemTime<std::chrono::microseconds>().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) {
|
||||||
|
@ -29,6 +29,8 @@ using SteadySeconds = std::chrono::time_point<std::chrono::steady_clock, std::ch
|
|||||||
using SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds>;
|
using SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds>;
|
||||||
using SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>;
|
using SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>;
|
||||||
|
|
||||||
|
using SystemClock = std::chrono::system_clock;
|
||||||
|
|
||||||
void UninterruptibleSleep(const std::chrono::microseconds& n);
|
void UninterruptibleSleep(const std::chrono::microseconds& n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,16 +65,14 @@ using MillisecondsDouble = std::chrono::duration<double, std::chrono::millisecon
|
|||||||
* DEPRECATED
|
* DEPRECATED
|
||||||
* Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
|
* Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
|
||||||
* ClockType is
|
* ClockType is
|
||||||
* - std::chrono::steady_clock for steady time
|
* - SteadyClock/std::chrono::steady_clock for steady time
|
||||||
* - std::chrono::system_clock for system time
|
* - SystemClock/std::chrono::system_clock for system time
|
||||||
* - NodeClock for mockable system time
|
* - NodeClock for mockable system time
|
||||||
*/
|
*/
|
||||||
int64_t GetTime();
|
int64_t GetTime();
|
||||||
|
|
||||||
/** Returns the system time (not mockable) */
|
/** Returns the system time (not mockable) */
|
||||||
int64_t GetTimeMillis();
|
int64_t GetTimeMillis();
|
||||||
/** Returns the system time (not mockable) */
|
|
||||||
int64_t GetTimeMicros();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DEPRECATED
|
* DEPRECATED
|
||||||
|
Loading…
Reference in New Issue
Block a user