Merge pull request #1119 from sipa/fastshutdown
Make lsn_reset ("detach databases") optional and off by default.
This commit is contained in:
commit
e1ea3ce7aa
6 changed files with 27 additions and 3 deletions
|
@ -28,6 +28,7 @@ unsigned int nWalletDBUpdated;
|
||||||
|
|
||||||
CCriticalSection cs_db;
|
CCriticalSection cs_db;
|
||||||
static bool fDbEnvInit = false;
|
static bool fDbEnvInit = false;
|
||||||
|
bool fDetachDB = false;
|
||||||
DbEnv dbenv(0);
|
DbEnv dbenv(0);
|
||||||
map<string, int> mapFileUseCount;
|
map<string, int> mapFileUseCount;
|
||||||
static map<string, Db*> mapDb;
|
static map<string, Db*> mapDb;
|
||||||
|
@ -307,9 +308,13 @@ void DBFlush(bool fShutdown)
|
||||||
{
|
{
|
||||||
// Move log data to the dat file
|
// Move log data to the dat file
|
||||||
CloseDb(strFile);
|
CloseDb(strFile);
|
||||||
|
printf("%s checkpoint\n", strFile.c_str());
|
||||||
dbenv.txn_checkpoint(0, 0, 0);
|
dbenv.txn_checkpoint(0, 0, 0);
|
||||||
printf("%s flush\n", strFile.c_str());
|
if ((strFile != "blkindex.dat" && strFile != "addr.dat") || fDetachDB) {
|
||||||
|
printf("%s detach\n", strFile.c_str());
|
||||||
dbenv.lsn_reset(strFile.c_str(), 0);
|
dbenv.lsn_reset(strFile.c_str(), 0);
|
||||||
|
}
|
||||||
|
printf("%s closed\n", strFile.c_str());
|
||||||
mapFileUseCount.erase(mi++);
|
mapFileUseCount.erase(mi++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
1
src/db.h
1
src/db.h
|
@ -25,6 +25,7 @@ class CWallet;
|
||||||
class CWalletTx;
|
class CWalletTx;
|
||||||
|
|
||||||
extern unsigned int nWalletDBUpdated;
|
extern unsigned int nWalletDBUpdated;
|
||||||
|
extern bool fDetachDB;
|
||||||
extern DbEnv dbenv;
|
extern DbEnv dbenv;
|
||||||
|
|
||||||
extern void DBFlush(bool fShutdown);
|
extern void DBFlush(bool fShutdown);
|
||||||
|
|
|
@ -200,6 +200,7 @@ bool AppInit2(int argc, char* argv[])
|
||||||
#else
|
#else
|
||||||
" -upnp \t " + _("Use Universal Plug and Play to map the listening port (default: 0)") + "\n" +
|
" -upnp \t " + _("Use Universal Plug and Play to map the listening port (default: 0)") + "\n" +
|
||||||
#endif
|
#endif
|
||||||
|
" -detachdb \t " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" +
|
||||||
#endif
|
#endif
|
||||||
" -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send") + "\n" +
|
" -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send") + "\n" +
|
||||||
#ifdef QT_GUI
|
#ifdef QT_GUI
|
||||||
|
@ -255,6 +256,7 @@ bool AppInit2(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
fDebug = GetBoolArg("-debug");
|
fDebug = GetBoolArg("-debug");
|
||||||
|
fDetachDB = GetBoolArg("-detachdb", false);
|
||||||
|
|
||||||
#if !defined(WIN32) && !defined(QT_GUI)
|
#if !defined(WIN32) && !defined(QT_GUI)
|
||||||
fDaemon = GetBoolArg("-daemon");
|
fDaemon = GetBoolArg("-daemon");
|
||||||
|
|
|
@ -38,6 +38,7 @@ private:
|
||||||
QCheckBox *minimize_on_close;
|
QCheckBox *minimize_on_close;
|
||||||
#endif
|
#endif
|
||||||
QCheckBox *connect_socks4;
|
QCheckBox *connect_socks4;
|
||||||
|
QCheckBox *detach_database;
|
||||||
QLineEdit *proxy_ip;
|
QLineEdit *proxy_ip;
|
||||||
QLineEdit *proxy_port;
|
QLineEdit *proxy_port;
|
||||||
BitcoinAmountField *fee_edit;
|
BitcoinAmountField *fee_edit;
|
||||||
|
@ -229,6 +230,10 @@ MainOptionsPage::MainOptionsPage(QWidget *parent):
|
||||||
|
|
||||||
layout->addLayout(fee_hbox);
|
layout->addLayout(fee_hbox);
|
||||||
|
|
||||||
|
detach_database = new QCheckBox(tr("Detach databases at shutdown"));
|
||||||
|
detach_database->setToolTip(tr("Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached."));
|
||||||
|
layout->addWidget(detach_database);
|
||||||
|
|
||||||
layout->addStretch(1); // Extra space at bottom
|
layout->addStretch(1); // Extra space at bottom
|
||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
@ -256,6 +261,7 @@ void MainOptionsPage::setMapper(MonitoredDataMapper *mapper)
|
||||||
mapper->addMapping(proxy_ip, OptionsModel::ProxyIP);
|
mapper->addMapping(proxy_ip, OptionsModel::ProxyIP);
|
||||||
mapper->addMapping(proxy_port, OptionsModel::ProxyPort);
|
mapper->addMapping(proxy_port, OptionsModel::ProxyPort);
|
||||||
mapper->addMapping(fee_edit, OptionsModel::Fee);
|
mapper->addMapping(fee_edit, OptionsModel::Fee);
|
||||||
|
mapper->addMapping(detach_database, OptionsModel::DetachDatabases);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayOptionsPage::DisplayOptionsPage(QWidget *parent):
|
DisplayOptionsPage::DisplayOptionsPage(QWidget *parent):
|
||||||
|
|
|
@ -28,6 +28,8 @@ void OptionsModel::Init()
|
||||||
SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool());
|
SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool());
|
||||||
if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool())
|
if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool())
|
||||||
SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString());
|
SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString());
|
||||||
|
if (settings.contains("detachDB"))
|
||||||
|
SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OptionsModel::Upgrade()
|
bool OptionsModel::Upgrade()
|
||||||
|
@ -121,6 +123,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||||
return QVariant(nDisplayUnit);
|
return QVariant(nDisplayUnit);
|
||||||
case DisplayAddresses:
|
case DisplayAddresses:
|
||||||
return QVariant(bDisplayAddresses);
|
return QVariant(bDisplayAddresses);
|
||||||
|
case DetachDatabases:
|
||||||
|
return QVariant(fDetachDB);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -204,6 +208,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||||
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DetachDatabases: {
|
||||||
|
fDetachDB = value.toBool();
|
||||||
|
settings.setValue("detachDB", fDetachDB);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ public:
|
||||||
Fee, // qint64
|
Fee, // qint64
|
||||||
DisplayUnit, // BitcoinUnits::Unit
|
DisplayUnit, // BitcoinUnits::Unit
|
||||||
DisplayAddresses, // bool
|
DisplayAddresses, // bool
|
||||||
OptionIDRowCount
|
DetachDatabases, // bool
|
||||||
|
OptionIDRowCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
Loading…
Reference in a new issue