Skip to content

Commit df6a5fc

Browse files
committed
[util] Change GetMockTime to return chrono type instead of int
1 parent a2d908e commit df6a5fc

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/logging.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
203203
strStamped.pop_back();
204204
strStamped += strprintf(".%06dZ", nTimeMicros%1000000);
205205
}
206-
int64_t mocktime = GetMockTime();
207-
if (mocktime) {
208-
strStamped += " (mocktime: " + FormatISO8601DateTime(mocktime) + ")";
206+
std::chrono::seconds mocktime = GetMockTime();
207+
if (mocktime > 0s) {
208+
strStamped += " (mocktime: " + FormatISO8601DateTime(count_seconds(mocktime)) + ")";
209209
}
210210
strStamped += ' ' + str;
211211
} else

src/util/time.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ void SetMockTime(int64_t nMockTimeIn)
5353
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
5454
}
5555

56-
int64_t GetMockTime()
56+
std::chrono::seconds GetMockTime()
5757
{
58-
return nMockTime.load(std::memory_order_relaxed);
58+
return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed));
5959
}
6060

6161
int64_t GetTimeMillis()

src/util/time.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable
4545

4646
/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
4747
void SetMockTime(int64_t nMockTimeIn);
48+
4849
/** For testing */
49-
int64_t GetMockTime();
50+
std::chrono::seconds GetMockTime();
5051

5152
/** Return system time (or mocked time, if set) */
5253
template <typename T>

0 commit comments

Comments
 (0)