diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-02-16 16:37:46 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-01-07 18:07:07 +0200 |
commit | 28e2961fd6a2a9101fc08fb748430989291aaf7e (patch) | |
tree | c3fe71dbb68c12822cbf4a9a7fd3dab92756266c | |
parent | 02ccf69dd6b772423acb343d16ef2bdbb3e3da03 (diff) |
refactor: Replace magic number with named constant
-rw-r--r-- | src/mapport.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mapport.cpp b/src/mapport.cpp index a45d4d9060..1f24b75708 100644 --- a/src/mapport.cpp +++ b/src/mapport.cpp @@ -34,6 +34,10 @@ static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed" #ifdef USE_UPNP static CThreadInterrupt g_upnp_interrupt; static std::thread g_upnp_thread; + +using namespace std::chrono_literals; +static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD{20min}; + static void ThreadMapPort() { std::string port = strprintf("%u", GetListenPort()); @@ -84,7 +88,7 @@ static void ThreadMapPort() } else { LogPrintf("UPnP Port Mapping successful.\n"); } - } while (g_upnp_interrupt.sleep_for(std::chrono::minutes(20))); + } while (g_upnp_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD)); r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r); |