Skip to content

Commit

Permalink
Force reindex when dex live does not present
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Fieroni <[email protected]>
  • Loading branch information
bvbfan committed Apr 27, 2022
1 parent 46ef729 commit 3cce1a4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <key_io.h>
#include <masternodes/accountshistory.h>
#include <masternodes/anchors.h>
#include <masternodes/govvariables/attributes.h>
#include <masternodes/masternodes.h>
#include <masternodes/vaulthistory.h>
#include <miner.h>
Expand Down Expand Up @@ -1618,9 +1619,23 @@ bool AppInitMain(InitInterfaces& interfaces)
pcustomcsview.reset();
pcustomcsview = MakeUnique<CCustomCSView>(*pcustomcsDB.get());
if (!fReset && !fReindexChainState) {
if (!pcustomcsDB->IsEmpty() && pcustomcsview->GetDbVersion() != CCustomCSView::DbVersion) {
strLoadError = _("Account database is unsuitable").translated;
break;
if (!pcustomcsDB->IsEmpty()) {
if (pcustomcsview->GetDbVersion() != CCustomCSView::DbVersion) {
strLoadError = _("Account database is unsuitable").translated;
break;
}
// force reindex iif there is at least one pool swap
PoolHeightKey anyPoolSwap{DCT_ID{}, ~0u};
auto it = pcustomcsview->LowerBound<CPoolPairView::ByPoolSwap>(anyPoolSwap);
auto shouldReindex = it.Valid();
if (auto attributes = pcustomcsview->GetAttributes()) {
CDataStructureV0 dexKey{AttributeTypes::Live, ParamIDs::Economy, EconomyKeys::DexTokens};
shouldReindex &= !attributes->CheckKey(dexKey);
}
if (shouldReindex) {
strLoadError = _("Live dex needs reindex").translated;
break;
}
}
}

Expand Down

0 comments on commit 3cce1a4

Please sign in to comment.