aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp8
-rw-r--r--src/db.cpp20
-rw-r--r--src/db.h3
-rw-r--r--src/init.cpp22
-rw-r--r--src/leveldb.cpp10
-rw-r--r--src/leveldb.h2
-rw-r--r--src/main.cpp3
-rw-r--r--src/main.h1
-rw-r--r--src/qt/bitcoingui.cpp8
-rw-r--r--src/qt/bitcoinstrings.cpp2
-rw-r--r--src/qt/forms/optionsdialog.ui10
-rw-r--r--src/qt/forms/sendcoinsentry.ui26
-rw-r--r--src/qt/optionsdialog.cpp1
-rw-r--r--src/qt/optionsmodel.cpp10
-rw-r--r--src/qt/optionsmodel.h1
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/rpcwallet.cpp2
-rw-r--r--src/txdb.cpp4
-rw-r--r--src/txdb.h4
-rw-r--r--src/wallet.cpp8
20 files changed, 51 insertions, 96 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index ed51b7afb3..37f7859324 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -179,14 +179,12 @@ Value help(const Array& params, bool fHelp)
Value stop(const Array& params, bool fHelp)
{
+ // Accept the deprecated and ignored 'detach´ boolean argument
if (fHelp || params.size() > 1)
throw runtime_error(
- "stop <detach>\n"
- "<detach> is true or false to detach the database or not for this stop only\n"
- "Stop Bitcoin server (and possibly override the detachdb config value).");
+ "stop\n"
+ "Stop Bitcoin server.");
// Shutdown will take long enough that the response should get back
- if (params.size() > 0)
- bitdb.SetDetach(params[0].get_bool());
StartShutdown();
return "Bitcoin server stopping";
}
diff --git a/src/db.cpp b/src/db.cpp
index cf96fe6e38..fb405fc277 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -271,14 +271,6 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
}
}
-static bool IsChainFile(std::string strFile)
-{
- if (strFile == "coins.dat" || strFile == "blktree.dat")
- return true;
-
- return false;
-}
-
void CDB::Flush()
{
if (activeTxn)
@@ -288,10 +280,6 @@ void CDB::Flush()
unsigned int nMinutes = 0;
if (fReadOnly)
nMinutes = 1;
- if (IsChainFile(strFile))
- nMinutes = 2;
- if (IsChainFile(strFile) && IsInitialBlockDownload())
- nMinutes = 5;
bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0);
}
@@ -453,11 +441,9 @@ void CDBEnv::Flush(bool fShutdown)
CloseDb(strFile);
printf("%s checkpoint\n", strFile.c_str());
dbenv.txn_checkpoint(0, 0, 0);
- if (!IsChainFile(strFile) || fDetachDB) {
- printf("%s detach\n", strFile.c_str());
- if (!fMockDb)
- dbenv.lsn_reset(strFile.c_str(), 0);
- }
+ printf("%s detach\n", strFile.c_str());
+ if (!fMockDb)
+ dbenv.lsn_reset(strFile.c_str(), 0);
printf("%s closed\n", strFile.c_str());
mapFileUseCount.erase(mi++);
}
diff --git a/src/db.h b/src/db.h
index 9a5f1ca9e4..9cfbf4fd6f 100644
--- a/src/db.h
+++ b/src/db.h
@@ -31,7 +31,6 @@ bool BackupWallet(const CWallet& wallet, const std::string& strDest);
class CDBEnv
{
private:
- bool fDetachDB;
bool fDbEnvInit;
bool fMockDb;
boost::filesystem::path pathEnv;
@@ -71,8 +70,6 @@ public:
void Close();
void Flush(bool fShutdown);
void CheckpointLSN(std::string strFile);
- void SetDetach(bool fDetachDB_) { fDetachDB = fDetachDB_; }
- bool GetDetach() { return fDetachDB; }
void CloseDb(const std::string& strFile);
bool RemoveDb(const std::string& strFile);
diff --git a/src/init.cpp b/src/init.cpp
index 1724382bf5..8670ca9d39 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -236,7 +236,6 @@ std::string HelpMessage()
" -gen=0 " + _("Don't generate coins") + "\n" +
" -datadir=<dir> " + _("Specify data directory") + "\n" +
" -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n" +
- " -dblogsize=<n> " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
" -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
" -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" +
@@ -265,7 +264,6 @@ std::string HelpMessage()
" -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" +
#endif
#endif
- " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" +
" -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n" +
#ifdef QT_GUI
" -server " + _("Accept command line and JSON-RPC commands") + "\n" +
@@ -408,8 +406,6 @@ bool AppInit2()
else
fDebugNet = GetBoolArg("-debugnet");
- bitdb.SetDetach(GetBoolArg("-detachdb", false));
-
#if !defined(WIN32) && !defined(QT_GUI)
fDaemon = GetBoolArg("-daemon");
#else
@@ -461,7 +457,7 @@ bool AppInit2()
if (file) fclose(file);
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock())
- return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), strDataDir.c_str()));
+ return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), strDataDir.c_str()));
#if !defined(WIN32) && !defined(QT_GUI)
if (fDaemon)
@@ -651,11 +647,23 @@ bool AppInit2()
return InitError(msg);
}
+ // cache size calculations
+ size_t nTotalCache = GetArg("-dbcache", 25) << 20;
+ if (nTotalCache < (1 << 22))
+ nTotalCache = (1 << 22); // total cache cannot be less than 4 MiB
+ size_t nBlockTreeDBCache = nTotalCache / 8;
+ if (nBlockTreeDBCache > (1 << 21))
+ nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
+ nTotalCache -= nBlockTreeDBCache;
+ size_t nCoinDBCache = nTotalCache / 2; // use half of the remaining cache for coindb cache
+ nTotalCache -= nCoinDBCache;
+ nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
+
uiInterface.InitMessage(_("Loading block index..."));
printf("Loading block index...\n");
nStart = GetTimeMillis();
- pblocktree = new CBlockTreeDB();
- pcoinsdbview = new CCoinsViewDB();
+ pblocktree = new CBlockTreeDB(nBlockTreeDBCache);
+ pcoinsdbview = new CCoinsViewDB(nCoinDBCache);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
if (!LoadBlockIndex())
diff --git a/src/leveldb.cpp b/src/leveldb.cpp
index e8a0fbe874..58b75e5295 100644
--- a/src/leveldb.cpp
+++ b/src/leveldb.cpp
@@ -12,22 +12,22 @@
#include <boost/filesystem.hpp>
-static leveldb::Options GetOptions() {
+static leveldb::Options GetOptions(size_t nCacheSize) {
leveldb::Options options;
- int nCacheSizeMB = GetArg("-dbcache", 25);
- options.block_cache = leveldb::NewLRUCache(nCacheSizeMB * 1048576);
+ options.block_cache = leveldb::NewLRUCache(nCacheSize / 2);
+ options.write_buffer_size = nCacheSize / 4; // up to two write buffers may be held in memory simultaneously
options.filter_policy = leveldb::NewBloomFilterPolicy(10);
options.compression = leveldb::kNoCompression;
return options;
}
-CLevelDB::CLevelDB(const boost::filesystem::path &path, bool fMemory) {
+CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory) {
penv = NULL;
readoptions.verify_checksums = true;
iteroptions.verify_checksums = true;
iteroptions.fill_cache = false;
syncoptions.sync = true;
- options = GetOptions();
+ options = GetOptions(nCacheSize);
options.create_if_missing = true;
if (fMemory) {
penv = leveldb::NewMemEnv(leveldb::Env::Default());
diff --git a/src/leveldb.h b/src/leveldb.h
index ee9079c3c3..e5b2e1ef0b 100644
--- a/src/leveldb.h
+++ b/src/leveldb.h
@@ -69,7 +69,7 @@ private:
leveldb::DB *pdb;
public:
- CLevelDB(const boost::filesystem::path &path, bool fMemory = false);
+ CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory = false);
~CLevelDB();
template<typename K, typename V> bool Read(const K& key, V& value) {
diff --git a/src/main.cpp b/src/main.cpp
index 43bd5dd472..a08e393caa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,6 +41,7 @@ CBlockIndex* pindexBest = NULL;
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
int64 nTimeBestReceived = 0;
bool fImporting = false;
+unsigned int nCoinCacheSize = 5000;
CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
@@ -1735,7 +1736,7 @@ bool SetBestChain(CBlockIndex* pindexNew)
// Make sure it's successfully written to disk before changing memory structure
bool fIsInitialDownload = IsInitialBlockDownload();
- if (!fIsInitialDownload || view.GetCacheSize()>5000) {
+ if (!fIsInitialDownload || view.GetCacheSize() > nCoinCacheSize) {
FlushBlockFile();
pblocktree->Sync();
if (!view.Flush())
diff --git a/src/main.h b/src/main.h
index 744c0e4b51..899cabd85a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -88,6 +88,7 @@ extern CCriticalSection cs_setpwalletRegistered;
extern std::set<CWallet*> setpwalletRegistered;
extern unsigned char pchMessageStart[4];
extern bool fImporting;
+extern unsigned int nCoinCacheSize;
// Settings
extern int64 nTransactionFee;
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index c09e1ce447..988f4185b9 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -625,11 +625,9 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
{
- QString strMessage =
- tr("This transaction is over the size limit. You can still send it for a fee of %1, "
- "which goes to the nodes that process your transaction and helps to support the network. "
- "Do you want to pay the fee?").arg(
- BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
+ QString strMessage = tr("This transaction is over the size limit. You can still send it for a fee of %1, "
+ "which goes to the nodes that process your transaction and helps to support the network. "
+ "Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
QMessageBox::StandardButton retval = QMessageBox::question(
this, tr("Confirm transaction fee"), strMessage,
QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp
index b92a26c4a4..7e8e102ee7 100644
--- a/src/qt/bitcoinstrings.cpp
+++ b/src/qt/bitcoinstrings.cpp
@@ -27,8 +27,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", ""
"Cannot obtain a lock on data directory %s. Bitcoin is probably already "
"running."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
-"Detach block and address databases. Increases shutdown time (default: 0)"),
-QT_TRANSLATE_NOOP("bitcoin-core", ""
"Error: The transaction was rejected. This might happen if some of the coins "
"in your wallet were already spent, such as if you used a copy of wallet.dat "
"and coins were spent in the copy but not marked as spent here."),
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 1b81b0cdc8..6a13361974 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -87,16 +87,6 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="detachDatabases">
- <property name="toolTip">
- <string>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.</string>
- </property>
- <property name="text">
- <string>&amp;Detach databases at shutdown</string>
- </property>
- </widget>
- </item>
- <item>
<spacer name="verticalSpacer_Main">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui
index 22a3f8fdc6..28553c5508 100644
--- a/src/qt/forms/sendcoinsentry.ui
+++ b/src/qt/forms/sendcoinsentry.ui
@@ -52,23 +52,6 @@
<item row="5" column="1">
<widget class="BitcoinAmountField" name="payAmount"/>
</item>
- <item row="4" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="spacing">
- <number>0</number>
- </property>
- <item>
- <widget class="QValidatedLineEdit" name="addAsLabel">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Enter a label for this address to add it to your address book</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -90,7 +73,7 @@
<item>
<widget class="QValidatedLineEdit" name="payTo">
<property name="toolTip">
- <string>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string>
+ <string>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</string>
</property>
<property name="maxLength">
<number>34</number>
@@ -147,6 +130,13 @@
</item>
</layout>
</item>
+ <item row="4" column="1">
+ <widget class="QValidatedLineEdit" name="addAsLabel">
+ <property name="toolTip">
+ <string>Enter a label for this address to add it to your address book</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<customwidgets>
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 3fb30a9518..03dcb0b538 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -128,7 +128,6 @@ void OptionsDialog::setMapper()
/* Main */
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
- mapper->addMapping(ui->detachDatabases, OptionsModel::DetachDatabases);
/* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 1075ce1e6c..e3c9413f1b 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -56,8 +56,6 @@ void OptionsModel::Init()
SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString());
if (settings.contains("nSocksVersion") && settings.value("fUseProxy").toBool())
SoftSetArg("-socks", settings.value("nSocksVersion").toString().toStdString());
- if (settings.contains("detachDB"))
- SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool());
if (!language.isEmpty())
SoftSetArg("-lang", language.toStdString());
}
@@ -173,8 +171,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return QVariant(nDisplayUnit);
case DisplayAddresses:
return QVariant(bDisplayAddresses);
- case DetachDatabases:
- return QVariant(bitdb.GetDetach());
case Language:
return settings.value("language", "");
default:
@@ -256,12 +252,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
bDisplayAddresses = value.toBool();
settings.setValue("bDisplayAddresses", bDisplayAddresses);
break;
- case DetachDatabases: {
- bool fDetachDB = value.toBool();
- bitdb.SetDetach(fDetachDB);
- settings.setValue("detachDB", fDetachDB);
- }
- break;
case Language:
settings.setValue("language", value);
break;
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index 2d86a7a9ca..4f893bb44e 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -28,7 +28,6 @@ public:
Fee, // qint64
DisplayUnit, // BitcoinUnits::Unit
DisplayAddresses, // bool
- DetachDatabases, // bool
Language, // QString
OptionIDRowCount,
};
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index ca2c615333..0c1547bd8e 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -148,7 +148,7 @@ void SendCoinsDialog::on_sendButton_clicked()
break;
case WalletModel::TransactionCreationFailed:
QMessageBox::warning(this, tr("Send Coins"),
- tr("Error: Transaction creation failed."),
+ tr("Error: Transaction creation failed!"),
QMessageBox::Ok, QMessageBox::Ok);
break;
case WalletModel::TransactionCommitFailed:
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index cd91f650a8..29b3298b99 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1429,7 +1429,7 @@ Value encryptwallet(const Array& params, bool fHelp)
// slack space in .dat files; that is bad if the old data is
// unencrypted private keys. So:
StartShutdown();
- return "wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
+ return "wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.";
}
class DescribeAddressVisitor : public boost::static_visitor<Object>
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 6550f57876..d9972d5b06 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -19,7 +19,7 @@ void static BatchWriteHashBestChain(CLevelDBBatch &batch, const uint256 &hash) {
batch.Write('B', hash);
}
-CCoinsViewDB::CCoinsViewDB(bool fMemory) : db(GetDataDir() / "coins", fMemory) {
+CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory) : db(GetDataDir() / "coins", nCacheSize, fMemory) {
}
bool CCoinsViewDB::GetCoins(uint256 txid, CCoins &coins) {
@@ -64,7 +64,7 @@ bool CCoinsViewDB::BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockI
return db.WriteBatch(batch);
}
-CBlockTreeDB::CBlockTreeDB(bool fMemory) : CLevelDB(GetDataDir() / "blktree", fMemory) {
+CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory) : CLevelDB(GetDataDir() / "blktree", nCacheSize, fMemory) {
}
bool CBlockTreeDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
diff --git a/src/txdb.h b/src/txdb.h
index 123ec00d23..e13925c964 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -14,7 +14,7 @@ class CCoinsViewDB : public CCoinsView
protected:
CLevelDB db;
public:
- CCoinsViewDB(bool fMemory = false);
+ CCoinsViewDB(size_t nCacheSize, bool fMemory = false);
bool GetCoins(uint256 txid, CCoins &coins);
bool SetCoins(uint256 txid, const CCoins &coins);
@@ -29,7 +29,7 @@ public:
class CBlockTreeDB : public CLevelDB
{
public:
- CBlockTreeDB(bool fMemory = false);
+ CBlockTreeDB(size_t nCacheSize, bool fMemory = false);
private:
CBlockTreeDB(const CBlockTreeDB&);
void operator=(const CBlockTreeDB&);
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 67b4e8f095..ae9f695e9f 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1292,7 +1292,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew,
if (IsLocked())
{
- string strError = _("Error: Wallet locked, unable to create transaction ");
+ string strError = _("Error: Wallet locked, unable to create transaction!");
printf("SendMoney() : %s", strError.c_str());
return strError;
}
@@ -1300,9 +1300,9 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew,
{
string strError;
if (nValue + nFeeRequired > GetBalance())
- strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str());
+ strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!"), FormatMoney(nFeeRequired).c_str());
else
- strError = _("Error: Transaction creation failed ");
+ strError = _("Error: Transaction creation failed!");
printf("SendMoney() : %s", strError.c_str());
return strError;
}
@@ -1311,7 +1311,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew,
return "ABORTED";
if (!CommitTransaction(wtxNew, reservekey))
- return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
+ return _("Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
return "";
}