@ -179,7 +179,7 @@ unsigned short GetListenPort()
}
// find 'best' local address for a particular peer
bool GetLocal ( CService & addr , const CNetAddr * paddrP eer )
bool GetLocal ( CService & addr , const CNode & p eer )
{
if ( ! fListen )
return false ;
@ -191,7 +191,7 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
for ( map < CNetAddr , LocalServiceInfo > : : iterator it = mapLocalHost . begin ( ) ; it ! = mapLocalHost . end ( ) ; it + + )
{
int nScore = ( * it ) . second . nScore ;
int nReachability = ( * it ) . first . GetReachabilityFrom ( paddrPee r ) ;
int nReachability = ( * it ) . first . GetReachabilityFrom ( peer . addr ) ;
if ( nReachability > nBestReachability | | ( nReachability = = nBestReachability & & nScore > nBestScore ) )
{
addr = CService ( ( * it ) . first , ( * it ) . second . nPort ) ;
@ -228,12 +228,11 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
// 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.
CAddress GetLocalAddress ( const CNetAddr * paddrP eer )
CService GetLocalAddress ( const CNode & p eer )
{
CAddress ret ( CService ( CNetAddr ( ) , GetListenPort ( ) ) , 0 ) ;
CService addr ;
if ( GetLocal ( addr , paddrPeer ) )
{
if ( GetLocal ( addr , peer ) ) {
ret = CAddress ( addr ) ;
}
ret . nServices = nLocalServices ;
@ -261,7 +260,7 @@ void AdvertizeLocal(CNode *pnode)
{
if ( fListen & & pnode - > fSuccessfullyConnected )
{
CAddress addrLocal = GetLocalAddress ( & pnode - > addr ) ;
CAddress addrLocal { GetLocalAddress ( * pnode ) } ;
// If discovery is enabled, sometimes give our peer the address it
// tells us that it sees us as in case it has a better idea of our
// address than we do.
@ -576,14 +575,15 @@ extern int32_t HUSH_NSPV;
# define HUSH_NSPV_SUPERLITE (HUSH_NSPV > 0)
# endif // !HUSH_NSPV_SUPERLITE
void CNode : : PushVersion ( )
{
int nBestHeight = g_signals . GetHeight ( ) . get_value_or ( 0 ) ;
int64_t nTime = ( fInbound ? GetTime ( ) : GetTime ( ) ) ;
CAddress addrYou = ( addr . IsRoutable ( ) & & ! IsProxy ( addr ) ? addr : CAddress ( CService ( ) , addr . nServices ) ) ;
CAddress addrMe = GetLocalAddress ( & addr ) ;
CNode * addr = this ;
CService service = GetLocalAddress ( * addr ) ;
CAddress addrMe ( service ) ;
GetRandBytes ( ( unsigned char * ) & nLocalHostNonce , sizeof ( nLocalHostNonce ) ) ;
if ( fLogIPs )
LogPrint ( " net " , " send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d \n " , PROTOCOL_VERSION , nBestHeight , addrMe . ToString ( ) , addrYou . ToString ( ) , id ) ;