mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
UpgradeDBIfNeeded failure should require reindexing (#3516)
This commit is contained in:
parent
1163fc70a2
commit
acff9998e1
@ -1077,7 +1077,7 @@ void CDeterministicMNManager::CleanupCache(int nHeight)
|
||||
}
|
||||
}
|
||||
|
||||
bool CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pindexNext, const CDeterministicMNList& curMNList, CDeterministicMNList& newMNList)
|
||||
void CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pindexNext, const CDeterministicMNList& curMNList, CDeterministicMNList& newMNList)
|
||||
{
|
||||
CDataStream oldDiffData(SER_DISK, CLIENT_VERSION);
|
||||
if (!evoDb.GetRawDB().ReadDataStream(std::make_pair(DB_LIST_DIFF, pindexNext->GetBlockHash()), oldDiffData)) {
|
||||
@ -1085,7 +1085,7 @@ bool CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pi
|
||||
newMNList = curMNList;
|
||||
newMNList.SetBlockHash(pindexNext->GetBlockHash());
|
||||
newMNList.SetHeight(pindexNext->nHeight);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
CDeterministicMNListDiff_OldFormat oldDiff;
|
||||
@ -1125,27 +1125,27 @@ bool CDeterministicMNManager::UpgradeDiff(CDBBatch& batch, const CBlockIndex* pi
|
||||
|
||||
batch.Write(std::make_pair(DB_LIST_DIFF, pindexNext->GetBlockHash()), newDiff);
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO this can be completely removed in a future version
|
||||
void CDeterministicMNManager::UpgradeDBIfNeeded()
|
||||
bool CDeterministicMNManager::UpgradeDBIfNeeded()
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
if (chainActive.Tip() == nullptr) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (evoDb.GetRawDB().Exists(EVODB_BEST_BLOCK)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Removing the old EVODB_BEST_BLOCK value early results in older version to crash immediately, even if the upgrade
|
||||
// process is cancelled in-between. But if the new version sees that the old EVODB_BEST_BLOCK is already removed,
|
||||
// then we must assume that the upgrade process was already running before but was interrupted.
|
||||
if (chainActive.Height() > 1 && !evoDb.GetRawDB().Exists(std::string("b_b"))) {
|
||||
LogPrintf("CDeterministicMNManager::%s -- ERROR, upgrade process was interrupted and can't be continued. You need to reindex now.\n", __func__);
|
||||
return false;
|
||||
}
|
||||
evoDb.GetRawDB().Erase(std::string("b_b"));
|
||||
|
||||
@ -1154,7 +1154,7 @@ void CDeterministicMNManager::UpgradeDBIfNeeded()
|
||||
auto dbTx = evoDb.BeginTransaction();
|
||||
evoDb.WriteBestBlock(chainActive.Tip()->GetBlockHash());
|
||||
dbTx->Commit();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
LogPrintf("CDeterministicMNManager::%s -- upgrading DB to use compact diffs\n", __func__);
|
||||
@ -1190,4 +1190,6 @@ void CDeterministicMNManager::UpgradeDBIfNeeded()
|
||||
dbTx->Commit();
|
||||
|
||||
evoDb.GetRawDB().CompactFull();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -673,8 +673,8 @@ public:
|
||||
|
||||
public:
|
||||
// TODO these can all be removed in a future version
|
||||
bool UpgradeDiff(CDBBatch& batch, const CBlockIndex* pindexNext, const CDeterministicMNList& curMNList, CDeterministicMNList& newMNList);
|
||||
void UpgradeDBIfNeeded();
|
||||
void UpgradeDiff(CDBBatch& batch, const CBlockIndex* pindexNext, const CDeterministicMNList& curMNList, CDeterministicMNList& newMNList);
|
||||
bool UpgradeDBIfNeeded();
|
||||
|
||||
private:
|
||||
void CleanupCache(int nHeight);
|
||||
|
@ -1944,7 +1944,10 @@ bool AppInitMain()
|
||||
assert(chainActive.Tip() != NULL);
|
||||
}
|
||||
|
||||
deterministicMNManager->UpgradeDBIfNeeded();
|
||||
if (!deterministicMNManager->UpgradeDBIfNeeded()) {
|
||||
strLoadError = _("Error upgrading evo database");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_coinsview_empty) {
|
||||
uiInterface.InitMessage(_("Verifying blocks..."));
|
||||
|
Loading…
Reference in New Issue
Block a user