use buid-in time functionality

This commit is contained in:
Pol Espinasa 2025-02-03 23:32:12 +01:00
parent ef15351b76
commit 317ddca8e6
No known key found for this signature in database
GPG Key ID: 28470907B40BF26D

View File

@ -5625,10 +5625,9 @@ double ChainstateManager::GuessVerificationProgress(const CBlockIndex* pindex) c
return 0.0;
}
int64_t end_of_chain_timestamp = pindex->GetBlockTime();
int64_t end_of_chain_timestamp = TicksSinceEpoch<std::chrono::seconds>(NodeClock::time_point{std::chrono::seconds{pindex->GetBlockTime()}});
if (m_best_header && m_best_header->nChainWork > pindex->nChainWork) {
int64_t header_age = time(nullptr) - m_best_header->GetBlockTime();
int64_t header_age = TicksSinceEpoch<std::chrono::seconds>(Now<NodeSeconds>()) - m_best_header->GetBlockTime();
if (header_age < 24 * 60 * 60) {
end_of_chain_timestamp = std::max(end_of_chain_timestamp, m_best_header->GetBlockTime());
}