Few fixes for lite mode (#2014)
* Allow disabling txindex in lite mode * Do not load/store Dash-specific cache in lite mode * Do not create/show masternode tab in lite mode * Do not connect PS actions in lite mode * Fix sync/ignore block updates in Dash submodules in lite mode
This commit is contained in:
parent
2f1661678c
commit
72a225b9bf
@ -43,6 +43,9 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
|
||||
if (fInitialDownload)
|
||||
return;
|
||||
|
||||
if (fLiteMode)
|
||||
return;
|
||||
|
||||
mnodeman.UpdatedBlockTip(pindexNew);
|
||||
CPrivateSend::UpdatedBlockTip(pindexNew);
|
||||
#ifdef ENABLE_WALLET
|
||||
|
101
src/init.cpp
101
src/init.cpp
@ -242,14 +242,16 @@ void PrepareShutdown()
|
||||
g_connman.reset();
|
||||
|
||||
// STORE DATA CACHES INTO SERIALIZED DAT FILES
|
||||
CFlatDB<CMasternodeMan> flatdb1("mncache.dat", "magicMasternodeCache");
|
||||
flatdb1.Dump(mnodeman);
|
||||
CFlatDB<CMasternodePayments> flatdb2("mnpayments.dat", "magicMasternodePaymentsCache");
|
||||
flatdb2.Dump(mnpayments);
|
||||
CFlatDB<CGovernanceManager> flatdb3("governance.dat", "magicGovernanceCache");
|
||||
flatdb3.Dump(governance);
|
||||
CFlatDB<CNetFulfilledRequestManager> flatdb4("netfulfilled.dat", "magicFulfilledCache");
|
||||
flatdb4.Dump(netfulfilledman);
|
||||
if (!fLiteMode) {
|
||||
CFlatDB<CMasternodeMan> flatdb1("mncache.dat", "magicMasternodeCache");
|
||||
flatdb1.Dump(mnodeman);
|
||||
CFlatDB<CMasternodePayments> flatdb2("mnpayments.dat", "magicMasternodePaymentsCache");
|
||||
flatdb2.Dump(mnpayments);
|
||||
CFlatDB<CGovernanceManager> flatdb3("governance.dat", "magicGovernanceCache");
|
||||
flatdb3.Dump(governance);
|
||||
CFlatDB<CNetFulfilledRequestManager> flatdb4("netfulfilled.dat", "magicFulfilledCache");
|
||||
flatdb4.Dump(netfulfilledman);
|
||||
}
|
||||
|
||||
UnregisterNodeSignals(GetNodeSignals());
|
||||
if (fDumpMempoolLater)
|
||||
@ -1793,10 +1795,20 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
fMasternodeMode = GetBoolArg("-masternode", false);
|
||||
// TODO: masternode should have no wallet
|
||||
|
||||
if((fMasternodeMode || masternodeConfig.getCount() > -1) && fTxIndex == false
|
||||
//lite mode disables all Dash-specific functionality
|
||||
fLiteMode = GetBoolArg("-litemode", false);
|
||||
|
||||
if(fLiteMode) {
|
||||
InitWarning(_("You are starting in lite mode, all Dash-specific functionality is disabled."));
|
||||
}
|
||||
|
||||
if((!fLiteMode && fTxIndex == false)
|
||||
&& chainparams.NetworkIDString() != CBaseChainParams::REGTEST) { // TODO remove this when pruning is fixed. See https://github.com/dashpay/dash/pull/1817 and https://github.com/dashpay/dash/pull/1743
|
||||
return InitError("Enabling Masternode support requires turning on transaction indexing."
|
||||
"Please add txindex=1 to your configuration and start with -reindex");
|
||||
return InitError(_("Transaction index can't be disabled in full mode. Either start with -litemode command line switch or enable transaction index."));
|
||||
}
|
||||
|
||||
if(fLiteMode && fMasternodeMode) {
|
||||
return InitError(_("You can not start a masternode in lite mode."));
|
||||
}
|
||||
|
||||
if(fMasternodeMode) {
|
||||
@ -1853,12 +1865,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
nInstantSendDepth = GetArg("-instantsenddepth", DEFAULT_INSTANTSEND_DEPTH);
|
||||
nInstantSendDepth = std::min(std::max(nInstantSendDepth, MIN_INSTANTSEND_DEPTH), MAX_INSTANTSEND_DEPTH);
|
||||
|
||||
//lite mode disables all Dash-specific functionality
|
||||
fLiteMode = GetBoolArg("-litemode", false);
|
||||
if(fMasternodeMode && fLiteMode){
|
||||
return InitError("You can not start a masternode in litemode");
|
||||
}
|
||||
|
||||
LogPrintf("fLiteMode %d\n", fLiteMode);
|
||||
LogPrintf("nInstantSendDepth %d\n", nInstantSendDepth);
|
||||
#ifdef ENABLE_WALLET
|
||||
@ -1873,41 +1879,44 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
// LOAD SERIALIZED DAT FILES INTO DATA CACHES FOR INTERNAL USE
|
||||
|
||||
boost::filesystem::path pathDB = GetDataDir();
|
||||
std::string strDBName;
|
||||
if (!fLiteMode) {
|
||||
boost::filesystem::path pathDB = GetDataDir();
|
||||
std::string strDBName;
|
||||
|
||||
strDBName = "mncache.dat";
|
||||
uiInterface.InitMessage(_("Loading masternode cache..."));
|
||||
CFlatDB<CMasternodeMan> flatdb1(strDBName, "magicMasternodeCache");
|
||||
if(!flatdb1.Load(mnodeman)) {
|
||||
return InitError(_("Failed to load masternode cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
|
||||
if(mnodeman.size()) {
|
||||
strDBName = "mnpayments.dat";
|
||||
uiInterface.InitMessage(_("Loading masternode payment cache..."));
|
||||
CFlatDB<CMasternodePayments> flatdb2(strDBName, "magicMasternodePaymentsCache");
|
||||
if(!flatdb2.Load(mnpayments)) {
|
||||
return InitError(_("Failed to load masternode payments cache from") + "\n" + (pathDB / strDBName).string());
|
||||
strDBName = "mncache.dat";
|
||||
uiInterface.InitMessage(_("Loading masternode cache..."));
|
||||
CFlatDB<CMasternodeMan> flatdb1(strDBName, "magicMasternodeCache");
|
||||
if(!flatdb1.Load(mnodeman)) {
|
||||
return InitError(_("Failed to load masternode cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
|
||||
strDBName = "governance.dat";
|
||||
uiInterface.InitMessage(_("Loading governance cache..."));
|
||||
CFlatDB<CGovernanceManager> flatdb3(strDBName, "magicGovernanceCache");
|
||||
if(!flatdb3.Load(governance)) {
|
||||
return InitError(_("Failed to load governance cache from") + "\n" + (pathDB / strDBName).string());
|
||||
if(mnodeman.size()) {
|
||||
strDBName = "mnpayments.dat";
|
||||
uiInterface.InitMessage(_("Loading masternode payment cache..."));
|
||||
CFlatDB<CMasternodePayments> flatdb2(strDBName, "magicMasternodePaymentsCache");
|
||||
if(!flatdb2.Load(mnpayments)) {
|
||||
return InitError(_("Failed to load masternode payments cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
|
||||
strDBName = "governance.dat";
|
||||
uiInterface.InitMessage(_("Loading governance cache..."));
|
||||
CFlatDB<CGovernanceManager> flatdb3(strDBName, "magicGovernanceCache");
|
||||
if(!flatdb3.Load(governance)) {
|
||||
return InitError(_("Failed to load governance cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
governance.InitOnLoad();
|
||||
} else {
|
||||
uiInterface.InitMessage(_("Masternode cache is empty, skipping payments and governance cache..."));
|
||||
}
|
||||
|
||||
strDBName = "netfulfilled.dat";
|
||||
uiInterface.InitMessage(_("Loading fulfilled requests cache..."));
|
||||
CFlatDB<CNetFulfilledRequestManager> flatdb4(strDBName, "magicFulfilledCache");
|
||||
if(!flatdb4.Load(netfulfilledman)) {
|
||||
return InitError(_("Failed to load fulfilled requests cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
governance.InitOnLoad();
|
||||
} else {
|
||||
uiInterface.InitMessage(_("Masternode cache is empty, skipping payments and governance cache..."));
|
||||
}
|
||||
|
||||
strDBName = "netfulfilled.dat";
|
||||
uiInterface.InitMessage(_("Loading fulfilled requests cache..."));
|
||||
CFlatDB<CNetFulfilledRequestManager> flatdb4(strDBName, "magicFulfilledCache");
|
||||
if(!flatdb4.Load(netfulfilledman)) {
|
||||
return InitError(_("Failed to load fulfilled requests cache from") + "\n" + (pathDB / strDBName).string());
|
||||
}
|
||||
|
||||
// ********************************************************* Step 11c: update block tip in Dash modules
|
||||
|
||||
|
@ -482,6 +482,11 @@ void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitia
|
||||
pindexNew->nHeight, pindexBestHeader->nHeight, fInitialDownload, fReachedBestHeader);
|
||||
|
||||
if (!IsBlockchainSynced() && fReachedBestHeader) {
|
||||
if (fLiteMode) {
|
||||
// nothing to do in lite mode, just finish the process immediately
|
||||
nRequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
|
||||
return;
|
||||
}
|
||||
// Reached best header while being in initial mode.
|
||||
// We must be at the tip already, let's move to the next asset.
|
||||
SwitchToNextAsset(connman);
|
||||
|
@ -343,7 +343,7 @@ void BitcoinGUI::createActions()
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) {
|
||||
masternodeAction = new QAction(QIcon(":/icons/" + theme + "/masternodes"), tr("&Masternodes"), this);
|
||||
masternodeAction->setStatusTip(tr("Browse masternodes"));
|
||||
masternodeAction->setToolTip(masternodeAction->statusTip());
|
||||
@ -565,7 +565,7 @@ void BitcoinGUI::createToolBars()
|
||||
toolbar->addAction(receiveCoinsAction);
|
||||
toolbar->addAction(historyAction);
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool())
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction)
|
||||
{
|
||||
toolbar->addAction(masternodeAction);
|
||||
}
|
||||
@ -714,7 +714,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
|
||||
receiveCoinsMenuAction->setEnabled(enabled);
|
||||
historyAction->setEnabled(enabled);
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
|
||||
masternodeAction->setEnabled(enabled);
|
||||
}
|
||||
encryptWalletAction->setEnabled(enabled);
|
||||
@ -886,7 +886,7 @@ void BitcoinGUI::gotoHistoryPage()
|
||||
void BitcoinGUI::gotoMasternodePage()
|
||||
{
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
|
||||
masternodeAction->setChecked(true);
|
||||
if (walletFrame) walletFrame->gotoMasternodePage();
|
||||
}
|
||||
@ -1059,6 +1059,8 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
|
||||
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
|
||||
tooltip += QString("<br>");
|
||||
tooltip += tr("Transactions after this will not yet be visible.");
|
||||
} else if (fLiteMode) {
|
||||
setAdditionalDataSyncProgress(1);
|
||||
}
|
||||
|
||||
// Don't word-wrap this (fixed-width) tooltip
|
||||
@ -1089,6 +1091,11 @@ void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
|
||||
QString strSyncStatus;
|
||||
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if(walletFrame)
|
||||
walletFrame->showOutOfSyncWarning(false);
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
if(masternodeSync.IsSynced()) {
|
||||
progressBarLabel->setVisible(false);
|
||||
progressBar->setVisible(false);
|
||||
@ -1100,11 +1107,6 @@ void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
|
||||
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
||||
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if(walletFrame)
|
||||
walletFrame->showOutOfSyncWarning(false);
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
progressBar->setFormat(tr("Synchronizing additional data: %p%"));
|
||||
progressBar->setMaximum(1000000000);
|
||||
progressBar->setValue(nSyncProgress * 1000000000.0 + 0.5);
|
||||
|
@ -284,18 +284,22 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
|
||||
|
||||
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
updateWatchOnlyLabels(model->haveWatchOnly());
|
||||
connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
|
||||
|
||||
// explicitly update PS frame and transaction list to reflect actual settings
|
||||
updateAdvancedPSUI(model->getOptionsModel()->getShowAdvancedPSUI());
|
||||
|
||||
// that's it for litemode
|
||||
if(fLiteMode) return;
|
||||
connect(model->getOptionsModel(), SIGNAL(privateSendRoundsChanged()), this, SLOT(updatePrivateSendProgress()));
|
||||
connect(model->getOptionsModel(), SIGNAL(privateSentAmountChanged()), this, SLOT(updatePrivateSendProgress()));
|
||||
connect(model->getOptionsModel(), SIGNAL(advancedPSUIChanged(bool)), this, SLOT(updateAdvancedPSUI(bool)));
|
||||
// explicitly update PS frame and transaction list to reflect actual settings
|
||||
updateAdvancedPSUI(model->getOptionsModel()->getShowAdvancedPSUI());
|
||||
|
||||
connect(ui->privateSendAuto, SIGNAL(clicked()), this, SLOT(privateSendAuto()));
|
||||
connect(ui->privateSendReset, SIGNAL(clicked()), this, SLOT(privateSendReset()));
|
||||
connect(ui->privateSendInfo, SIGNAL(clicked()), this, SLOT(privateSendInfo()));
|
||||
connect(ui->togglePrivateSend, SIGNAL(clicked()), this, SLOT(togglePrivateSend()));
|
||||
updateWatchOnlyLabels(model->haveWatchOnly());
|
||||
connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent):
|
||||
addWidget(sendCoinsPage);
|
||||
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) {
|
||||
masternodeListPage = new MasternodeList(platformStyle);
|
||||
addWidget(masternodeListPage);
|
||||
}
|
||||
@ -139,7 +139,7 @@ void WalletView::setClientModel(ClientModel *_clientModel)
|
||||
overviewPage->setClientModel(_clientModel);
|
||||
sendCoinsPage->setClientModel(_clientModel);
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) {
|
||||
masternodeListPage->setClientModel(_clientModel);
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
|
||||
transactionView->setModel(_walletModel);
|
||||
overviewPage->setWalletModel(_walletModel);
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) {
|
||||
masternodeListPage->setWalletModel(_walletModel);
|
||||
}
|
||||
receiveCoinsPage->setModel(_walletModel);
|
||||
@ -217,7 +217,7 @@ void WalletView::gotoHistoryPage()
|
||||
void WalletView::gotoMasternodePage()
|
||||
{
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) {
|
||||
setCurrentWidget(masternodeListPage);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user