learn a new local address
| 205 | |
| 206 | // learn a new local address |
| 207 | bool AddLocal(const CService& addr, int nScore) |
| 208 | { |
| 209 | if (!addr.IsRoutable()) |
| 210 | return false; |
| 211 | |
| 212 | if (!fDiscover && nScore < LOCAL_MANUAL) |
| 213 | return false; |
| 214 | |
| 215 | if (IsLimited(addr)) |
| 216 | return false; |
| 217 | |
| 218 | LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore); |
| 219 | |
| 220 | { |
| 221 | LOCK(cs_mapLocalHost); |
| 222 | bool fAlready = mapLocalHost.count(addr) > 0; |
| 223 | LocalServiceInfo &info = mapLocalHost[addr]; |
| 224 | if (!fAlready || nScore >= info.nScore) { |
| 225 | info.nScore = nScore + (fAlready ? 1 : 0); |
| 226 | info.nPort = addr.GetPort(); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | return true; |
| 231 | } |
| 232 | |
| 233 | bool AddLocal(const CNetAddr &addr, int nScore) |
| 234 | { |
no test coverage detected