learn a new local address
| 274 | |
| 275 | // learn a new local address |
| 276 | bool AddLocal(const CService& addr, int nScore) |
| 277 | { |
| 278 | if (!addr.IsRoutable()) |
| 279 | return false; |
| 280 | |
| 281 | if (!fDiscover && nScore < LOCAL_MANUAL) |
| 282 | return false; |
| 283 | |
| 284 | if (IsLimited(addr)) |
| 285 | return false; |
| 286 | |
| 287 | LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore); |
| 288 | |
| 289 | { |
| 290 | LOCK(cs_mapLocalHost); |
| 291 | bool fAlready = mapLocalHost.count(addr) > 0; |
| 292 | LocalServiceInfo& info = mapLocalHost[addr]; |
| 293 | if (!fAlready || nScore >= info.nScore) { |
| 294 | info.nScore = nScore + (fAlready ? 1 : 0); |
| 295 | info.nPort = addr.GetPort(); |
| 296 | } |
| 297 | SetReachable(addr.GetNetwork()); |
| 298 | } |
| 299 | |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | bool AddLocal(const CNetAddr& addr, int nScore) |
| 304 | { |
no test coverage detected