MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / AddLocal

Function AddLocal

src/net.cpp:278–306  ·  view source on GitHub ↗

learn a new local address

Source from the content-addressed store, hash-verified

276
277// learn a new local address
278bool AddLocal(const CService& addr_, int nScore)
279{
280 CService addr{MaybeFlipIPv6toCJDNS(addr_)};
281
282 if (!addr.IsRoutable())
283 return false;
284
285 if (!fDiscover && nScore < LOCAL_MANUAL)
286 return false;
287
288 if (!g_reachable_nets.Contains(addr))
289 return false;
290
291 if (fLogIPs) {
292 LogInfo("AddLocal(%s,%i)\n", addr.ToStringAddrPort(), nScore);
293 }
294
295 {
296 LOCK(g_maplocalhost_mutex);
297 const auto [it, is_newly_added] = mapLocalHost.emplace(addr, LocalServiceInfo());
298 LocalServiceInfo &info = it->second;
299 if (is_newly_added || nScore >= info.nScore) {
300 info.nScore = SaturatingAdd(nScore, is_newly_added ? 0 : 1);
301 info.nPort = addr.GetPort();
302 }
303 }
304
305 return true;
306}
307
308bool AddLocal(const CNetAddr &addr, int nScore)
309{

Callers 8

add_onion_cbMethod · 0.85
AppInitMainFunction · 0.85
ProcessPCPFunction · 0.85
DiscoverFunction · 0.85
BindMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
net.cppFile · 0.85

Calls 10

MaybeFlipIPv6toCJDNSFunction · 0.85
SaturatingAddFunction · 0.85
CServiceClass · 0.85
GetListenPortFunction · 0.85
IsRoutableMethod · 0.80
ToStringAddrPortMethod · 0.80
emplaceMethod · 0.80
GetPortMethod · 0.80
LocalServiceInfoClass · 0.70
ContainsMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68