GUI/Options: Configure mempooltruc using settings

This commit is contained in:
Luke Dashjr 2024-06-06 13:17:55 +00:00
parent fdfc57bd1a
commit b399472de8
4 changed files with 45 additions and 0 deletions

View File

@ -237,6 +237,13 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
mempoolreplacement->addItem(QString("with a higher mining fee (no opt-out)"), QVariant("fee,-optin"));
CreateOptionUI(verticalLayout_Mempool, mempoolreplacement, tr("Transaction &replacement: %s"));
mempooltruc = new QValueComboBox(tabMempool);
mempooltruc->addItem(QString("do not relay or mine at all"), QVariant("reject"));
mempooltruc->addItem(QString("handle the same as other transactions"), QVariant("accept"));
mempooltruc->addItem(QString("impose stricter limits requested (DRAFT)"), QVariant("enforce"));
mempooltruc->setToolTip(tr("Some transactions signal a request to limit both themselves and other related transactions to more restrictive expectations. Specifically, this would disallow more than 1 unconfirmed predecessor or spending transaction, as well as smaller size limits (see BIP 431 for details), regardless of what policy you have configured."));
CreateOptionUI(verticalLayout_Mempool, mempooltruc, tr("Transactions requesting more restrictive policy limits (TRUC): %s"));
maxorphantx = new QSpinBox(tabMempool);
maxorphantx->setMinimum(0);
maxorphantx->setMaximum(std::numeric_limits<int>::max());
@ -707,6 +714,14 @@ void OptionsDialog::setMapper()
}
mempoolreplacement->setCurrentIndex(current_mempoolreplacement_index);
QVariant current_mempooltruc = model->data(model->index(OptionsModel::mempooltruc, 0), Qt::EditRole);
int current_mempooltruc_index = mempooltruc->findData(current_mempooltruc);
if (current_mempooltruc_index == -1) {
mempooltruc->addItem(current_mempooltruc.toString(), current_mempooltruc);
current_mempooltruc_index = mempooltruc->count() - 1;
}
mempooltruc->setCurrentIndex(current_mempooltruc_index);
mapper->addMapping(maxorphantx, OptionsModel::maxorphantx);
mapper->addMapping(maxmempool, OptionsModel::maxmempool);
mapper->addMapping(incrementalrelayfee, OptionsModel::incrementalrelayfee);
@ -920,6 +935,7 @@ void OptionsDialog::on_okButton_clicked()
}
model->setData(model->index(OptionsModel::mempoolreplacement, 0), mempoolreplacement->itemData(mempoolreplacement->currentIndex()));
model->setData(model->index(OptionsModel::mempooltruc, 0), mempooltruc->itemData(mempooltruc->currentIndex()));
if (dustdynamic_enable->isChecked()) {
if (dustdynamic_target->isChecked()) {

View File

@ -103,6 +103,7 @@ private:
QSpinBox *blockreconstructionextratxn;
QValueComboBox *mempoolreplacement;
QValueComboBox *mempooltruc;
QSpinBox *maxorphantx;
BitcoinAmountField *incrementalrelayfee;
QSpinBox *maxmempool;

View File

@ -223,6 +223,16 @@ static QString CanonicalMempoolReplacement(const OptionsModel& model)
assert(0);
}
static QString CanonicalMempoolTRUC(const OptionsModel& model)
{
switch (model.node().mempool().m_opts.truc_policy) {
case TRUCPolicy::Reject: return "reject";
case TRUCPolicy::Accept: return "accept";
case TRUCPolicy::Enforce: return "enforce";
}
assert(0);
}
OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent) :
QAbstractListModel(parent), m_node{node}
{
@ -650,6 +660,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS);
case mempoolreplacement:
return CanonicalMempoolReplacement(*this);
case mempooltruc:
return CanonicalMempoolTRUC(*this);
case maxorphantx:
return qlonglong(gArgs.GetIntArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
case maxmempool:
@ -1049,6 +1061,21 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
}
break;
}
case mempooltruc:
{
if (changed()) {
QString nv = value.toString();
if (nv == "reject") {
node().mempool().m_opts.truc_policy = TRUCPolicy::Reject;
} else if (nv == "accept") {
node().mempool().m_opts.truc_policy = TRUCPolicy::Accept;
} else if (nv == "enforce") {
node().mempool().m_opts.truc_policy = TRUCPolicy::Enforce;
}
node().updateRwSetting("mempooltruc", nv.toStdString());
}
break;
}
case maxorphantx:
{
if (changed()) {

View File

@ -82,6 +82,7 @@ public:
peerbloomfilters, // bool
peerblockfilters, // bool
mempoolreplacement,
mempooltruc,
maxorphantx,
maxmempool,
incrementalrelayfee,