Skip to content
Permalink
Browse files

Qt/Options: Expose peercfilters in GUI using rwconf

For now, enables basic block filters permanently (can only be disabled via enabling prune)
  • Loading branch information
luke-jr committed Jan 13, 2020
1 parent 663a538 commit 3f5fdf052c6f749686b063f3a3932a0211e1a789
Showing with 43 additions and 0 deletions.
  1. +10 −0 src/qt/forms/optionsdialog.ui
  2. +8 −0 src/qt/optionsdialog.cpp
  3. +24 −0 src/qt/optionsmodel.cpp
  4. +1 −0 src/qt/optionsmodel.h
@@ -697,6 +697,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="peercfilters">
<property name="toolTip">
<string>Generate compact block filters and allow peers to download them</string>
</property>
<property name="text">
<string>Provide compact block filters for light clients</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_Network">
<property name="orientation">
@@ -45,6 +45,12 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :

ui->pruneSize->setEnabled(false);
connect(ui->prune, &QPushButton::toggled, ui->pruneSize, &QWidget::setEnabled);
connect(ui->prune, &QPushButton::toggled, [this](bool nv) {
ui->peercfilters->setEnabled(!nv);
});
connect(ui->peercfilters, &QPushButton::toggled, [this](bool nv) {
ui->prune->setEnabled(!nv);
});

ui->networkPort->setValidator(new QIntValidator(1024, 65535, this));
connect(ui->networkPort, SIGNAL(textChanged(const QString&)), this, SLOT(checkLineEdit()));
@@ -194,6 +200,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->peerbloomfilters, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->peercfilters, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
/* Display */
connect(ui->lang, static_cast<void (QValueComboBox::*)()>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
@@ -275,6 +282,7 @@ void OptionsDialog::setMapper()
}

mapper->addMapping(ui->peerbloomfilters, OptionsModel::peerbloomfilters);
mapper->addMapping(ui->peercfilters, OptionsModel::peercfilters);

/* Window */
#ifndef Q_OS_MAC
@@ -12,6 +12,7 @@
#include <qt/guiconstants.h>
#include <qt/guiutil.h>

#include <index/blockfilterindex.h>
#include <interfaces/node.h>
#include <chainparams.h>
#include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS
@@ -363,6 +364,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return qlonglong(g_connman->GetMaxOutboundTarget() / 1024 / 1024);
case peerbloomfilters:
return f_peerbloomfilters;
case peercfilters:
return gArgs.GetBoolArg("-peercfilters", DEFAULT_PEERCFILTERS);
default:
return QVariant();
}
@@ -519,6 +522,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
if (llvalue > 1) {
settings.setValue("nPruneSize", ((llvalue * 1024 * 1024) + GB_BYTES - 1) / GB_BYTES);
}
if (llvalue != 0 && gArgs.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX) != "0") {
// Can't start with pruning if the index is enabled
// This won't delete it, but will allow starting
gArgs.ModifyRWConfigFile("blockfilterindex", "0");
}
setRestartRequired(true);
}
break;
@@ -557,6 +565,22 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true);
}
break;
case peercfilters:
{
bool nv = value.toBool();
if (gArgs.GetBoolArg("-peercfilters", DEFAULT_PEERCFILTERS) != nv) {
gArgs.ModifyRWConfigFile("peercfilters", strprintf("%d", nv));
gArgs.ForceSetArg("peercfilters", nv);
if (nv && !GetBlockFilterIndex(BlockFilterType::BASIC)) {
// TODO: When other options are possible, we need to append a list!
// TODO: Some way to unset/delete this...
gArgs.ModifyRWConfigFile("blockfilterindex", "basic");
gArgs.ForceSetArg("blockfilterindex", "basic");
}
setRestartRequired(true);
}
break;
}
default:
break;
}
@@ -58,6 +58,7 @@ class OptionsModel : public QAbstractListModel
Listen, // bool
maxuploadtarget,
peerbloomfilters, // bool
peercfilters, // bool
OptionIDRowCount,
};

0 comments on commit 3f5fdf0

Please sign in to comment.
You can’t perform that action at this time.