MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / GetLocalAddress

Function GetLocalAddress

src/net.cpp:224–231  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
224CService 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
233static int GetnScore(const CService &addr) {
234 LOCK(g_maplocalhost_mutex);

Callers 1

GetLocalAddrForPeerFunction · 0.85

Calls 3

GetListenPortFunction · 0.85
GetLocalFunction · 0.85
CNetAddrClass · 0.70

Tested by

no test coverage detected