Qt/Options: Configure maxmempool using rwconf

This commit is contained in:
Luke Dashjr 2016-02-15 08:49:26 +00:00
parent 4dff308dc7
commit d6f4eb55f9
4 changed files with 33 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#include <qt/guiutil.h>
#include <qt/optionsmodel.h>
#include <common/args.h>
#include <common/system.h>
#include <index/blockfilterindex.h>
#include <interfaces/node.h>
@ -20,8 +21,8 @@
#include <netbase.h>
#include <outputtype.h>
#include <txdb.h>
#include <txmempool.h> // for maxmempoolMinimum
#include <util/strencodings.h>
#include <chrono>
#include <QApplication>
@ -207,6 +208,12 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
maxorphantx->setMaximum(std::numeric_limits<int>::max());
CreateOptionUI(verticalLayout_Mempool, maxorphantx, tr("Keep at most %s unconnected transactions in memory"));
maxmempool = new QSpinBox(tabMempool);
const int64_t nMempoolSizeMinMB = maxmempoolMinimumBytes(gArgs.GetIntArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT_KVB) * 1'000) / 1'000'000;
maxmempool->setMinimum(nMempoolSizeMinMB);
maxmempool->setMaximum(std::numeric_limits<int>::max());
CreateOptionUI(verticalLayout_Mempool, maxmempool, tr("Keep the transaction memory pool below %s MB"));
QGroupBox * const groupBox_Spamfiltering = new QGroupBox(tabMempool);
groupBox_Spamfiltering->setTitle(tr("Spam filtering"));
QVBoxLayout * const verticalLayout_Spamfiltering = new QVBoxLayout(groupBox_Spamfiltering);
@ -460,6 +467,7 @@ void OptionsDialog::setMapper()
mempoolreplacement->setCurrentIndex(current_mempoolreplacement_index);
mapper->addMapping(maxorphantx, OptionsModel::maxorphantx);
mapper->addMapping(maxmempool, OptionsModel::maxmempool);
/* Window */
#ifndef Q_OS_MACOS

View File

@ -90,6 +90,7 @@ private:
QValueComboBox *mempoolreplacement;
QSpinBox *maxorphantx;
QSpinBox *maxmempool;
};
#endif // BITCOIN_QT_OPTIONSDIALOG_H

View File

@ -14,6 +14,7 @@
#include <common/args.h>
#include <index/blockfilterindex.h>
#include <interfaces/node.h>
#include <kernel/mempool_options.h> // for DEFAULT_MAX_MEMPOOL_SIZE_MB
#include <mapport.h>
#include <net.h>
#include <net_processing.h>
@ -637,6 +638,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return CanonicalMempoolReplacement(*this);
case maxorphantx:
return qlonglong(gArgs.GetIntArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
case maxmempool:
return qlonglong(node().mempool().m_opts.max_size_bytes / 1'000'000);
default:
return QVariant();
}
@ -970,6 +973,25 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
}
break;
}
case maxmempool:
{
if (changed()) {
long long nOldValue = node().mempool().m_opts.max_size_bytes;
long long nNv = value.toLongLong();
std::string strNv = value.toString().toStdString();
node().mempool().m_opts.max_size_bytes = nNv * 1'000'000;
gArgs.ForceSetArg("-maxmempool", strNv);
gArgs.ModifyRWConfigFile("maxmempool", strNv);
if (nNv < nOldValue) {
LOCK(cs_main);
auto node_ctx = node().context();
assert(node_ctx && node_ctx->mempool && node_ctx->chainman);
auto& active_chainstate = node_ctx->chainman->ActiveChainstate();
LimitMempoolSize(*node_ctx->mempool, active_chainstate.CoinsTip());
}
}
break;
}
default:
break;
}

View File

@ -82,6 +82,7 @@ public:
peerblockfilters, // bool
mempoolreplacement,
maxorphantx,
maxmempool,
OptionIDRowCount,
};