learn a new local address
| 166 | |
| 167 | // learn a new local address |
| 168 | bool 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 | |
| 196 | bool AddLocal(const CNetAddr& addr, int32_t nScore) { return AddLocal(CService(addr, GetListenPort()), nScore); } |
| 197 |
no test coverage detected