Qt/Options: Configure maxmempool using rwconf

This commit is contained in:
Luke Dashjr 2016-02-15 08:49:26 +00:00
parent a46bb3410f
commit 04ac0eb698
4 changed files with 32 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <outputtype.h>
#include <txdb.h> // for -dbcache defaults
#include <util/system.h>
#include <txmempool.h> // for maxmempoolMinimum
#include <chrono>
@ -203,6 +204,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);
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);
@ -448,6 +455,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

@ -15,6 +15,7 @@
#include <chainparams.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>
@ -611,6 +612,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_max_size_bytes);
default:
return QVariant();
}
@ -943,6 +946,25 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
}
break;
}
case maxmempool:
{
if (changed()) {
long long nOldValue = node().mempool().m_max_size_bytes;
long long nNv = value.toLongLong();
std::string strNv = value.toString().toStdString();
node().mempool().m_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,
};