diff --git a/src/init.cpp b/src/init.cpp index 55e01e090b59d4..adc2ff558c81bd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1827,7 +1827,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) if (node.peerman) node.peerman->SetBestBlock(chain_active_height, std::chrono::seconds{best_block_time}); // Map ports with NAT-PMP - StartMapPort(args.GetBoolArg("-natpmp", DEFAULT_NATPMP)); + if (args.GetBoolArg("-natpmp", DEFAULT_NATPMP)) StartMapPort(); CConnman::Options connOptions; connOptions.m_local_services = g_local_services; diff --git a/src/interfaces/node.h b/src/interfaces/node.h index aebb4386511b80..b6a78737465b6e 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -121,7 +121,7 @@ class Node virtual void resetSettings() = 0; //! Map port. - virtual void mapPort(bool use_pcp) = 0; + virtual void mapPort() = 0; //! Get proxy. virtual bool getProxy(Network net, Proxy& proxy_info) = 0; diff --git a/src/mapport.cpp b/src/mapport.cpp index 96aa1020dde4f3..e1138a9a57beae 100644 --- a/src/mapport.cpp +++ b/src/mapport.cpp @@ -161,14 +161,9 @@ static void DispatchMapPort() } } -static void MapPortProtoSetEnabled(bool enabled) +void StartMapPort() { - g_mapport_enabled = enabled; -} - -void StartMapPort(bool use_pcp) -{ - MapPortProtoSetEnabled(use_pcp); + g_mapport_enabled = true; DispatchMapPort(); } diff --git a/src/mapport.h b/src/mapport.h index aaf15051e712d7..8c00d997876b17 100644 --- a/src/mapport.h +++ b/src/mapport.h @@ -7,7 +7,7 @@ static constexpr bool DEFAULT_NATPMP = false; -void StartMapPort(bool use_pcp); +void StartMapPort(); void InterruptMapPort(); void StopMapPort(); diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index e4ae9400e37aa6..b7e2034b188a5c 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -187,7 +187,7 @@ class NodeImpl : public Node }); args().WriteSettingsFile(); } - void mapPort(bool use_pcp) override { StartMapPort(use_pcp); } + void mapPort() override { StartMapPort(); } bool getProxy(Network net, Proxy& proxy_info) override { return GetProxy(net, proxy_info); } size_t getNodeCount(ConnectionDirection flags) override { diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index a1dbc6248c0765..8bc7c550dce1b2 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -526,7 +526,7 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std:: case MapPortNatpmp: // core option - can be changed on-the-fly if (changed()) { update(value.toBool()); - node().mapPort(value.toBool()); + if (value.toBool()) node().mapPort(); } break; case MinimizeOnClose: