Skip to content

Commit fa1b4e5

Browse files
committed
Use steady clock in FlushStateToDisk
1 parent 1111e2f commit fa1b4e5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,12 +2478,12 @@ bool Chainstate::FlushStateToDisk(
24782478
}
24792479
}
24802480
}
2481-
const auto nNow = GetTime<std::chrono::microseconds>();
2481+
const auto nNow{SteadyClock::now()};
24822482
// Avoid writing/flushing immediately after startup.
2483-
if (m_last_write.count() == 0) {
2483+
if (m_last_write == decltype(m_last_write){}) {
24842484
m_last_write = nNow;
24852485
}
2486-
if (m_last_flush.count() == 0) {
2486+
if (m_last_flush == decltype(m_last_flush){}) {
24872487
m_last_flush = nNow;
24882488
}
24892489
// The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
@@ -2544,7 +2544,7 @@ bool Chainstate::FlushStateToDisk(
25442544
m_last_flush = nNow;
25452545
full_flush_completed = true;
25462546
TRACE5(utxocache, flush,
2547-
(int64_t)(GetTimeMicros() - nNow.count()), // in microseconds (µs)
2547+
int64_t{Ticks<std::chrono::microseconds>(SteadyClock::now() - nNow)},
25482548
(uint32_t)mode,
25492549
(uint64_t)coins_count,
25502550
(uint64_t)coins_mem_usage,

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,8 @@ class Chainstate
785785
void UpdateTip(const CBlockIndex* pindexNew)
786786
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
787787

788-
std::chrono::microseconds m_last_write{0};
789-
std::chrono::microseconds m_last_flush{0};
788+
SteadyClock::time_point m_last_write{};
789+
SteadyClock::time_point m_last_flush{};
790790

791791
friend ChainstateManager;
792792
};

0 commit comments

Comments
 (0)