src/net.cpp
bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
{
    if (!fListen)
        return false;

    int nBestScore = -1;
    int nBestReachability = -1;
    {
        LOCK(cs_mapLocalHost);
        for (const auto& entry : mapLocalHost)
        {
            int nScore = entry.second.nScore;
            int nReachability = entry.first.GetReachabilityFrom(paddrPeer);
            if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
            {
                addr = CService(entry.first, entry.second.nPort);
                nBestReachability = nReachability;
                nBestScore = nScore;
            }
        }
    }
    return nBestScore >= 0;
}
// find 'best' local address for a particular peer
find 'best' local address for a particular peer
find ' best ' local address for a particular peer
bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
{
    if (!fListen)
        return false;
    int nBestScore = -1;
    int nBestReachability = -1;
    {
        LOCK(cs_mapLocalHost);
        for (const auto& entry : mapLocalHost)
        {
            int nScore = entry.second.nScore;
            int nReachability = entry.first.GetReachabilityFrom(paddrPeer);
            if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
            {
                addr = CService(entry.first, entry.second.nPort);
                nBestReachability = nReachability;
                nBestScore = nScore;
            }
        }
    }
    return nBestScore >= 0;
}
bool GetLocal ( CService & addr , const CNetAddr * paddrPeer ) { if ( ! fListen ) return false ; int nBestScore = -1 ; int nBestReachability = -1 ; { LOCK ( cs_mapLocalHost ) ; for ( const auto & entry : mapLocalHost ) { int nScore = entry . second . nScore ; int nReachability = entry . first . GetReachabilityFrom ( paddrPeer ) ; if ( nReachability > nBestReachability || ( nReachability == nBestReachability && nScore > nBestScore ) ) { addr = CService ( entry . first , entry . second . nPort ) ; nBestReachability = nReachability ; nBestScore = nScore ; } } } return nBestScore >= 0 ; }
find 'best' local address for a particular peer
find ' best ' local address for a particular peer