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

Function AddLocal

src/net.cpp:168–194  ·  view source on GitHub ↗

learn a new local address

Source from the content-addressed store, hash-verified

166
167// learn a new local address
168bool AddLocal(const CService& addr, int32_t nScore) {
169 if (!addr.IsRoutable())
170 return false;
171
172 if (!fDiscover && nScore < LOCAL_MANUAL)
173 return false;
174
175 if (IsLimited(addr))
176 return false;
177
178 LogPrint(BCLog::INFO, "AddLocal(%s,%i)\n", addr.ToString(), nScore);
179
180 {
181 LOCK(cs_mapLocalHost);
182 bool fAlready = mapLocalHost.count(addr) > 0;
183 LocalServiceInfo& info = mapLocalHost[addr];
184 if (!fAlready || nScore >= info.nScore) {
185 info.nScore = nScore + (fAlready ? 1 : 0);
186 info.nPort = addr.GetPort();
187 }
188 SetReachable(addr.GetNetwork());
189 }
190
191 AdvertizeLocal();
192
193 return true;
194}
195
196bool AddLocal(const CNetAddr& addr, int32_t nScore) { return AddLocal(CService(addr, GetListenPort()), nScore); }
197

Callers 5

AppInitFunction · 0.85
ThreadGetMyPublicIPFunction · 0.85
ThreadMapPortFunction · 0.85
net.cppFile · 0.85
DiscoverFunction · 0.85

Calls 10

IsLimitedFunction · 0.85
SetReachableFunction · 0.85
AdvertizeLocalFunction · 0.85
GetListenPortFunction · 0.85
IsRoutableMethod · 0.80
GetPortMethod · 0.80
GetNetworkMethod · 0.80
CServiceClass · 0.70
ToStringMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected