learn a new local address
| 239 | |
| 240 | // learn a new local address |
| 241 | bool AddLocal(const CService& addr, int nScore) |
| 242 | { |
| 243 | if (!addr.IsRoutable()) |
| 244 | return false; |
| 245 | |
| 246 | if (!fDiscover && nScore < LOCAL_MANUAL) |
| 247 | return false; |
| 248 | |
| 249 | if (IsLimited(addr)) |
| 250 | return false; |
| 251 | |
| 252 | LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore); |
| 253 | |
| 254 | { |
| 255 | LOCK(cs_mapLocalHost); |
| 256 | bool fAlready = mapLocalHost.count(addr) > 0; |
| 257 | LocalServiceInfo &info = mapLocalHost[addr]; |
| 258 | if (!fAlready || nScore >= info.nScore) { |
| 259 | info.nScore = nScore + (fAlready ? 1 : 0); |
| 260 | info.nPort = addr.GetPort(); |
| 261 | } |
| 262 | SetReachable(addr.GetNetwork()); |
| 263 | } |
| 264 | |
| 265 | return true; |
| 266 | } |
| 267 | |
| 268 | bool AddLocal(const CNetAddr &addr, int nScore) |
| 269 | { |
no test coverage detected