MCPcopy Create free account
hub / github.com/ElementsProject/elements / AddLocal

Function AddLocal

src/net.cpp:287–313  ·  view source on GitHub ↗

learn a new local address

Source from the content-addressed store, hash-verified

285
286// learn a new local address
287bool AddLocal(const CService& addr_, int nScore)
288{
289 CService addr{MaybeFlipIPv6toCJDNS(addr_)};
290
291 if (!addr.IsRoutable())
292 return false;
293
294 if (!fDiscover && nScore < LOCAL_MANUAL)
295 return false;
296
297 if (!IsReachable(addr))
298 return false;
299
300 LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore);
301
302 {
303 LOCK(g_maplocalhost_mutex);
304 const auto [it, is_newly_added] = mapLocalHost.emplace(addr, LocalServiceInfo());
305 LocalServiceInfo &info = it->second;
306 if (is_newly_added || nScore >= info.nScore) {
307 info.nScore = nScore + (is_newly_added ? 0 : 1);
308 info.nPort = addr.GetPort();
309 }
310 }
311
312 return true;
313}
314
315bool AddLocal(const CNetAddr &addr, int nScore)
316{

Callers 8

add_onion_cbMethod · 0.85
AppInitMainFunction · 0.85
NatpmpMappingFunction · 0.85
ProcessUpnpFunction · 0.85
DiscoverFunction · 0.85
BindMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

MaybeFlipIPv6toCJDNSFunction · 0.85
IsReachableFunction · 0.85
LocalServiceInfoClass · 0.85
GetListenPortFunction · 0.85
IsRoutableMethod · 0.80
GetPortMethod · 0.80
CServiceClass · 0.70
ToStringMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68