Skip to content

Commit

Permalink
Qt/Options: Expose peercfilters in GUI using rwconf
Browse files Browse the repository at this point in the history
For now, enables basic block filters permanently (can only be disabled via enabling prune)
  • Loading branch information
luke-jr committed Jan 14, 2020
1 parent 663a538 commit 3f5fdf0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
8 changes: 8 additions & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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(); });
Expand Down Expand Up @@ -275,6 +282,7 @@ void OptionsDialog::setMapper()
}

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

/* Window */
#ifndef Q_OS_MAC
Expand Down
24 changes: 24 additions & 0 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class OptionsModel : public QAbstractListModel
Listen, // bool
maxuploadtarget,
peerbloomfilters, // bool
peercfilters, // bool
OptionIDRowCount,
};

Expand Down

0 comments on commit 3f5fdf0

Please sign in to comment.