MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetLocal

Function GetLocal

src/net.cpp:135–155  ·  view source on GitHub ↗

find 'best' local address for a particular peer

Source from the content-addressed store, hash-verified

133
134// find 'best' local address for a particular peer
135bool GetLocal(CService& addr, const CNetAddr* paddrPeer)
136{
137 if (!fListen)
138 return false;
139
140 int nBestScore = -1;
141 int nBestReachability = -1;
142 {
143 LOCK(cs_mapLocalHost);
144 for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++) {
145 int nScore = (*it).second.nScore;
146 int nReachability = (*it).first.GetReachabilityFrom(paddrPeer);
147 if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) {
148 addr = CService((*it).first, (*it).second.nPort);
149 nBestReachability = nReachability;
150 nBestScore = nScore;
151 }
152 }
153 }
154 return nBestScore >= 0;
155}
156
157//! Convert the pnSeed6 array into usable address objects.
158static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn)

Callers 2

ManageStatusMethod · 0.85
GetLocalAddressFunction · 0.85

Calls 4

GetReachabilityFromMethod · 0.80
CServiceClass · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected