MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetLocal

Function GetLocal

src/net.cpp:103–125  ·  view source on GitHub ↗

find 'best' local address for a particular peer

Source from the content-addressed store, hash-verified

101
102// find 'best' local address for a particular peer
103bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
104{
105 if (!fListen)
106 return false;
107
108 int nBestScore = -1;
109 int nBestReachability = -1;
110 {
111 LOCK(cs_mapLocalHost);
112 for (const auto& entry : mapLocalHost)
113 {
114 int nScore = entry.second.nScore;
115 int nReachability = entry.first.GetReachabilityFrom(paddrPeer);
116 if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
117 {
118 addr = CService(entry.first, entry.second.nPort);
119 nBestReachability = nReachability;
120 nBestScore = nScore;
121 }
122 }
123 }
124 return nBestScore >= 0;
125}
126
127//! Convert the pnSeed6 array into usable address objects.
128static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn)

Callers 1

GetLocalAddressFunction · 0.85

Calls 2

GetReachabilityFromMethod · 0.80
CServiceClass · 0.70

Tested by

no test coverage detected