Skip to content

Commit 3b82608

Browse files
vasildjonatack
andcommitted
options: add a comment for -listenonion and dedup a long expression
A followup to #568 Co-authored-by: Jon Atack <[email protected]>
1 parent 0a14a16 commit 3b82608

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/qt/optionsmodel.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,26 @@ void OptionsModel::Init(bool resetSettings)
151151

152152
if (!settings.contains("fListen"))
153153
settings.setValue("fListen", DEFAULT_LISTEN);
154-
if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool())) {
154+
const bool listen{settings.value("fListen").toBool()};
155+
if (!gArgs.SoftSetBoolArg("-listen", listen)) {
155156
addOverriddenOption("-listen");
156-
} else if (!settings.value("fListen").toBool()) {
157+
} else if (!listen) {
158+
// We successfully set -listen=0, thus mimic the logic from InitParameterInteraction():
159+
// "parameter interaction: -listen=0 -> setting -listenonion=0".
160+
//
161+
// Both -listen and -listenonion default to true.
162+
//
163+
// The call order is:
164+
//
165+
// InitParameterInteraction()
166+
// would set -listenonion=0 if it sees -listen=0, but for bitcoin-qt with
167+
// fListen=false -listen is 1 at this point
168+
//
169+
// OptionsModel::Init()
170+
// (this method) can flip -listen from 1 to 0 if fListen=false
171+
//
172+
// AppInitParameterInteraction()
173+
// raises an error if -listen=0 and -listenonion=1
157174
gArgs.SoftSetBoolArg("-listenonion", false);
158175
}
159176

0 commit comments

Comments
 (0)