Skip to content

Commit 967654d

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25079: index: Change sync variables to use std::chrono::steady_clock
92b35ab index, refactor: Change sync variables to use `std::chrono::steady_clock` (w0xlt) Pull request description: This PR refactors the sync variables to use `std::chrono::steady_clock` as it is best suitable for measuring intervals. ACKs for top commit: jonatack: utACK 92b35ab ajtowns: ACK 92b35ab - code review only Tree-SHA512: cd4bafde47b30beb88c0aac247e41b4dced2ff2845c67a7043619da058dcff4f84374a7c704a698f3055c888d076d25503c2f38ace8fbc5456f624e0efe1e188
2 parents b9219b2 + 92b35ab commit 967654d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index/base.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ using node::ReadBlockFromDisk;
1818

1919
constexpr uint8_t DB_BEST_BLOCK{'B'};
2020

21-
constexpr int64_t SYNC_LOG_INTERVAL = 30; // seconds
22-
constexpr int64_t SYNC_LOCATOR_WRITE_INTERVAL = 30; // seconds
21+
constexpr auto SYNC_LOG_INTERVAL{30s};
22+
constexpr auto SYNC_LOCATOR_WRITE_INTERVAL{30s};
2323

2424
template <typename... Args>
2525
static void FatalError(const char* fmt, const Args&... args)
@@ -130,8 +130,8 @@ void BaseIndex::ThreadSync()
130130
if (!m_synced) {
131131
auto& consensus_params = Params().GetConsensus();
132132

133-
int64_t last_log_time = 0;
134-
int64_t last_locator_write_time = 0;
133+
std::chrono::steady_clock::time_point last_log_time{0s};
134+
std::chrono::steady_clock::time_point last_locator_write_time{0s};
135135
while (true) {
136136
if (m_interrupt) {
137137
SetBestBlockIndex(pindex);
@@ -160,7 +160,7 @@ void BaseIndex::ThreadSync()
160160
pindex = pindex_next;
161161
}
162162

163-
int64_t current_time = GetTime();
163+
auto current_time{std::chrono::steady_clock::now()};
164164
if (last_log_time + SYNC_LOG_INTERVAL < current_time) {
165165
LogPrintf("Syncing %s with block chain from height %d\n",
166166
GetName(), pindex->nHeight);

0 commit comments

Comments
 (0)