mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
[util] Change GetMockTime to return chrono type instead of int
This commit is contained in:
parent
a2d908e1da
commit
df6a5fc1df
3 changed files with 7 additions and 6 deletions
|
@ -203,9 +203,9 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
|
||||||
strStamped.pop_back();
|
strStamped.pop_back();
|
||||||
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
|
||||||
}
|
}
|
||||||
int64_t mocktime = GetMockTime();
|
std::chrono::seconds mocktime = GetMockTime();
|
||||||
if (mocktime) {
|
if (mocktime > 0s) {
|
||||||
strStamped += " (mocktime: " + FormatISO8601DateTime(mocktime) + ")";
|
strStamped += " (mocktime: " + FormatISO8601DateTime(count_seconds(mocktime)) + ")";
|
||||||
}
|
}
|
||||||
strStamped += ' ' + str;
|
strStamped += ' ' + str;
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -53,9 +53,9 @@ void SetMockTime(int64_t nMockTimeIn)
|
||||||
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
|
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetMockTime()
|
std::chrono::seconds GetMockTime()
|
||||||
{
|
{
|
||||||
return nMockTime.load(std::memory_order_relaxed);
|
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetTimeMillis()
|
int64_t GetTimeMillis()
|
||||||
|
|
|
@ -45,8 +45,9 @@ int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
|
||||||
|
|
||||||
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
|
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
|
||||||
void SetMockTime(int64_t nMockTimeIn);
|
void SetMockTime(int64_t nMockTimeIn);
|
||||||
|
|
||||||
/** For testing */
|
/** For testing */
|
||||||
int64_t GetMockTime();
|
std::chrono::seconds GetMockTime();
|
||||||
|
|
||||||
/** Return system time (or mocked time, if set) */
|
/** Return system time (or mocked time, if set) */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Add table
Reference in a new issue