Browse Source

add constants for shared (GUI/core) -dbcache settings

- adds nDefaultDbCache, nMaxDbCache and nMinDbCache in txdb.h
0.10
Philip Kaufmann 11 years ago
parent
commit
82e96006ae
  1. 10
      src/init.cpp
  2. 12
      src/qt/forms/optionsdialog.ui
  3. 6
      src/qt/optionsdialog.cpp
  4. 3
      src/qt/optionsmodel.cpp
  5. 7
      src/txdb.h

10
src/init.cpp

@ -196,7 +196,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -testnet " + _("Use the test network") + "\n"; strUsage += " -testnet " + _("Use the test network") + "\n";
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n"; strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
strUsage += " -gen " + _("Generate coins (default: 0)") + "\n"; strUsage += " -gen " + _("Generate coins (default: 0)") + "\n";
strUsage += " -dbcache=<n> " + _("Set database cache size in megabytes (default: 100)") + "\n"; strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n"; strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n";
strUsage += " -proxy=<ip:port> " + _("Connect through SOCKS proxy") + "\n"; strUsage += " -proxy=<ip:port> " + _("Connect through SOCKS proxy") + "\n";
strUsage += " -socks=<n> " + _("Select SOCKS version for -proxy (4 or 5, default: 5)") + "\n"; strUsage += " -socks=<n> " + _("Select SOCKS version for -proxy (4 or 5, default: 5)") + "\n";
@ -776,9 +776,11 @@ bool AppInit2(boost::thread_group& threadGroup)
} }
// cache size calculations // cache size calculations
size_t nTotalCache = GetArg("-dbcache", 100) << 20; size_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20);
if (nTotalCache < (1 << 22)) if (nTotalCache < (nMinDbCache << 20))
nTotalCache = (1 << 22); // total cache cannot be less than 4 MiB nTotalCache = (nMinDbCache << 20); // total cache cannot be less than nMinDbCache
else if (nTotalCache > (nMaxDbCache << 20))
nTotalCache = (nMaxDbCache << 20); // total cache cannot be greater than nMaxDbCache
size_t nBlockTreeDBCache = nTotalCache / 8; size_t nBlockTreeDBCache = nTotalCache / 8;
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false))
nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB

12
src/qt/forms/optionsdialog.ui

@ -53,17 +53,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="databaseCache"> <widget class="QSpinBox" name="databaseCache"/>
<property name="toolTip">
<string>Set database cache size in megabytes (default: 25)</string>
</property>
<property name="maximum">
<number>1024</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="databaseCacheUnitLabel"> <widget class="QLabel" name="databaseCacheUnitLabel">

6
src/qt/optionsdialog.cpp

@ -14,8 +14,9 @@
#include "monitoreddatamapper.h" #include "monitoreddatamapper.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "main.h" // for CTransaction::nMinTxFee
#include "netbase.h" #include "netbase.h"
#include "main.h" #include "txdb.h" // for -dbcache defaults
#include <QDir> #include <QDir>
#include <QIntValidator> #include <QIntValidator>
@ -34,7 +35,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this); GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this);
/* Main elements init */ /* Main elements init */
ui->databaseCache->setMaximum(sizeof(void*) > 4 ? 4096 : 1024); ui->databaseCache->setMinimum(nMinDbCache);
ui->databaseCache->setMaximum(nMaxDbCache);
/* Network elements init */ /* Network elements init */
#ifndef USE_UPNP #ifndef USE_UPNP

3
src/qt/optionsmodel.cpp

@ -14,6 +14,7 @@
#include "init.h" #include "init.h"
#include "main.h" #include "main.h"
#include "net.h" #include "net.h"
#include "txdb.h" // for -dbcache defaults
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
#include "wallet.h" #include "wallet.h"
#include "walletdb.h" #include "walletdb.h"
@ -84,7 +85,7 @@ void OptionsModel::Init()
#endif #endif
if (!settings.contains("nDatabaseCache")) if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", 100); settings.setValue("nDatabaseCache", nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString())) if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
strOverriddenByCommandLine += "-dbcache "; strOverriddenByCommandLine += "-dbcache ";

7
src/txdb.h

@ -18,6 +18,13 @@ class CBigNum;
class CCoins; class CCoins;
class uint256; class uint256;
// -dbcache default (MiB)
static const int nDefaultDbCache = 100;
// max. -dbcache in (MiB)
static const int nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024;
// min. -dbcache in (MiB)
static const int nMinDbCache = 4;
/** CCoinsView backed by the LevelDB coin database (chainstate/) */ /** CCoinsView backed by the LevelDB coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView class CCoinsViewDB : public CCoinsView
{ {

Loading…
Cancel
Save