fix: make sure we flush our committed best block in no-upgrade cases

This was spotted when working on `feature_txindex_compatibility.py`,
attempting to load old databases would fail because `MigrateDBIfNeeded()`
would delete `DB_OLD_BEST_BLOCK`, write `EVODB_BEST_BLOCK`, commit it
but never flush it.

So when `MigrateDBIfNeeded2()` would read it again, it would note the lack
of `DB_OLD_BEST_BLOCK` and conclude it was a failed run and exit. This
is solved by actually flushing our new best block, which would prevent
`MigrateDBIfNeeded2` from raising an objection.
This commit is contained in:
Kittywhiskers Van Gogh 2024-10-13 15:43:07 +00:00
parent 3f0c2ff324
commit ebae59eedf
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -1238,6 +1238,10 @@ bool CDeterministicMNManager::MigrateDBIfNeeded()
auto dbTx = m_evoDb.BeginTransaction();
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
dbTx->Commit();
if (!m_evoDb.CommitRootTransaction()) {
LogPrintf("CDeterministicMNManager::%s -- failed to commit to evoDB\n", __func__);
return false;
}
return true;
}
@ -1349,6 +1353,10 @@ bool CDeterministicMNManager::MigrateDBIfNeeded2()
auto dbTx = m_evoDb.BeginTransaction();
m_evoDb.WriteBestBlock(m_chainstate.m_chain.Tip()->GetBlockHash());
dbTx->Commit();
if (!m_evoDb.CommitRootTransaction()) {
LogPrintf("CDeterministicMNManager::%s -- failed to commit to evoDB\n", __func__);
return false;
}
return true;
}