fix: validation: cast now() to seconds for maxtipage comparison

Since faf44876db, the maxtipage comparison
in IsInitialBlockDownload() has been broken, since the NodeClock::now()
time_point is in the system's native denomination (micrcoseconds).

Without this patch, specifying the maximum allowable -maxtipage
(9223372036854775807) results in a SIGABRT crash.

Co-authored-by: MacroFake <falke.marco@gmail.com>
This commit is contained in:
James O'BeirneandMacroFake committed 2022-11-14 09:45:33 -05:00
1 parent 48174c0f28
commit a451e832b4
1 file changed
+1 -1
+1 -1
View File
@@ -1541,7 +1541,7 @@ bool Chainstate::IsInitialBlockDownload() const
if (m_chain.Tip()->nChainWork < m_chainman.MinimumChainWork()) {
return true;
}
if (m_chain.Tip()->Time() < NodeClock::now() - m_chainman.m_options.max_tip_age) {
if (m_chain.Tip()->Time() < Now<NodeSeconds>() - m_chainman.m_options.max_tip_age) {
return true;
}
LogPrintf("Leaving InitialBlockDownload (latching to false)\n");