Get best local address for a particular peer as a CService. Otherwise, return the unroutable 0.0.0.0 but filled in with the normal parameters, since the IP may be changed to a useful one by discovery.
| 222 | // the unroutable 0.0.0.0 but filled in with the normal parameters, since the IP |
| 223 | // may be changed to a useful one by discovery. |
| 224 | CService GetLocalAddress(const CNetAddr &addrPeer) { |
| 225 | CService ret{CNetAddr(), GetListenPort()}; |
| 226 | CService addr; |
| 227 | if (GetLocal(addr, &addrPeer)) { |
| 228 | ret = CService{addr}; |
| 229 | } |
| 230 | return ret; |
| 231 | } |
| 232 | |
| 233 | static int GetnScore(const CService &addr) { |
| 234 | LOCK(g_maplocalhost_mutex); |
no test coverage detected