@ -393,21 +393,15 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
NodeId id = GetNewNodeId ( ) ;
NodeId id = GetNewNodeId ( ) ;
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
CNode * pnode = new CNode ( id , nLocalServices , GetBestHeight ( ) , hSocket , addrConnect , CalculateKeyedNetGroup ( addrConnect ) , nonce , pszDest ? pszDest : " " , false ) ;
CNode * pnode = new CNode ( id , nLocalServices , GetBestHeight ( ) , hSocket , addrConnect , CalculateKeyedNetGroup ( addrConnect ) , nonce , pszDest ? pszDest : " " , false ) ;
pnode - > nServicesExpected = ServiceFlags ( addrConnect . nServices & nRelevantServices ) ;
pnode - > nTimeConnected = GetTime ( ) ;
PushVersion ( pnode , GetTime ( ) ) ;
GetNodeSignals ( ) . InitializeNode ( pnode - > GetId ( ) , pnode ) ;
pnode - > AddRef ( ) ;
pnode - > AddRef ( ) ;
GetNodeSignals ( ) . InitializeNode ( pnode , * this ) ;
{
{
LOCK ( cs_vNodes ) ;
LOCK ( cs_vNodes ) ;
vNodes . push_back ( pnode ) ;
vNodes . push_back ( pnode ) ;
}
}
pnode - > nServicesExpected = ServiceFlags ( addrConnect . nServices & nRelevantServices ) ;
pnode - > nTimeConnected = GetTime ( ) ;
return pnode ;
return pnode ;
} else if ( ! proxyConnectionFailed ) {
} else if ( ! proxyConnectionFailed ) {
// If connecting to the node failed, and failure is not caused by a problem connecting to
// If connecting to the node failed, and failure is not caused by a problem connecting to
@ -418,24 +412,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
return NULL ;
return NULL ;
}
}
void CConnman : : PushVersion ( CNode * pnode , int64_t nTime )
{
ServiceFlags nLocalNodeServices = pnode - > GetLocalServices ( ) ;
CAddress addrYou = ( pnode - > addr . IsRoutable ( ) & & ! IsProxy ( pnode - > addr ) ? pnode - > addr : CAddress ( CService ( ) , pnode - > addr . nServices ) ) ;
CAddress addrMe = CAddress ( CService ( ) , nLocalNodeServices ) ;
uint64_t nonce = pnode - > GetLocalNonce ( ) ;
int nNodeStartingHeight = pnode - > nMyStartingHeight ;
NodeId id = pnode - > GetId ( ) ;
PushMessageWithVersion ( pnode , INIT_PROTO_VERSION , NetMsgType : : VERSION , PROTOCOL_VERSION , ( uint64_t ) nLocalNodeServices , nTime , addrYou , addrMe ,
nonce , strSubVersion , nNodeStartingHeight , : : fRelayTxes ) ;
if ( fLogIPs )
LogPrint ( " net " , " send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d \n " , PROTOCOL_VERSION , nNodeStartingHeight , addrMe . ToString ( ) , addrYou . ToString ( ) , id ) ;
else
LogPrint ( " net " , " send version message: version %d, blocks=%d, us=%s, peer=%d \n " , PROTOCOL_VERSION , nNodeStartingHeight , addrMe . ToString ( ) , id ) ;
}
void CConnman : : DumpBanlist ( )
void CConnman : : DumpBanlist ( )
{
{
SweepBanned ( ) ; // clean unused entries (if bantime has expired)
SweepBanned ( ) ; // clean unused entries (if bantime has expired)
@ -1036,9 +1012,9 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
CNode * pnode = new CNode ( id , nLocalServices , GetBestHeight ( ) , hSocket , addr , CalculateKeyedNetGroup ( addr ) , nonce , " " , true ) ;
CNode * pnode = new CNode ( id , nLocalServices , GetBestHeight ( ) , hSocket , addr , CalculateKeyedNetGroup ( addr ) , nonce , " " , true ) ;
GetNodeSignals ( ) . InitializeNode ( pnode - > GetId ( ) , pnode ) ;
pnode - > AddRef ( ) ;
pnode - > AddRef ( ) ;
pnode - > fWhitelisted = whitelisted ;
pnode - > fWhitelisted = whitelisted ;
GetNodeSignals ( ) . InitializeNode ( pnode , * this ) ;
LogPrint ( " net " , " connection from %s accepted \n " , addr . ToString ( ) ) ;
LogPrint ( " net " , " connection from %s accepted \n " , addr . ToString ( ) ) ;
@ -2130,7 +2106,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
uint64_t nonce = GetDeterministicRandomizer ( RANDOMIZER_ID_LOCALHOSTNONCE ) . Write ( id ) . Finalize ( ) ;
pnodeLocalHost = new CNode ( id , nLocalServices , GetBestHeight ( ) , INVALID_SOCKET , CAddress ( CService ( local , 0 ) , nLocalServices ) , 0 , nonce ) ;
pnodeLocalHost = new CNode ( id , nLocalServices , GetBestHeight ( ) , INVALID_SOCKET , CAddress ( CService ( local , 0 ) , nLocalServices ) , 0 , nonce ) ;
GetNodeSignals ( ) . InitializeNode ( pnodeLocalHost - > GetId ( ) , pnodeLocalHost ) ;
GetNodeSignals ( ) . InitializeNode ( pnodeLocalHost , * this ) ;
}
}
//
//