Skip to content

Commit 7532090

Browse files
hebastoFuzzbawls
authored andcommitted
refactor: Replace magic number with named constant
1 parent c481f62 commit 7532090

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mapport.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed"
3535
#ifdef USE_UPNP
3636
static CThreadInterrupt g_upnp_interrupt;
3737
static std::thread g_upnp_thread;
38+
39+
static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD = std::chrono::minutes(20);
40+
3841
void ThreadMapPort()
3942
{
4043
std::string port = strprintf("%u", GetListenPort());
@@ -84,7 +87,7 @@ void ThreadMapPort()
8487
} else {
8588
LogPrintf("UPnP Port Mapping successful.\n");
8689
}
87-
} while(g_upnp_interrupt.sleep_for(std::chrono::minutes(20)));
90+
} while(g_upnp_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD));
8891

8992
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
9093
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);

0 commit comments

Comments
 (0)