@@ -71,6 +71,7 @@ constexpr const CConnman::CFullyConnectedOnly CConnman::FullyConnectedOnly;
7171constexpr const CConnman::CAllNodes CConnman::AllNodes;
7272
7373static const uint64_t RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL ; // SHA256("netgroup")[0:8]
74+ static const uint64_t RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL ; // SHA256("localhostnonce")[0:8]
7475//
7576// Global state variables
7677//
@@ -413,7 +414,9 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
413414 addrman.Attempt (addrConnect, fCountFailure );
414415
415416 // Add node
416- CNode* pnode = new CNode (GetNewNodeId (), nLocalServices, GetBestHeight (), hSocket, addrConnect, CalculateKeyedNetGroup (addrConnect), pszDest ? pszDest : " " , false , true );
417+ NodeId id = GetNewNodeId ();
418+ uint64_t nonce = GetDeterministicRandomizer (RANDOMIZER_ID_LOCALHOSTNONCE).Write (id).Finalize ();
419+ CNode* pnode = new CNode (id, nLocalServices, GetBestHeight (), hSocket, addrConnect, CalculateKeyedNetGroup (addrConnect), nonce, pszDest ? pszDest : " " , false , true );
417420
418421 pnode->nServicesExpected = ServiceFlags (addrConnect.nServices & nRelevantServices);
419422 pnode->nTimeConnected = GetSystemTimeInSeconds ();
@@ -1079,7 +1082,10 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
10791082 return ;
10801083 }
10811084
1082- CNode* pnode = new CNode (GetNewNodeId (), nLocalServices, GetBestHeight (), hSocket, addr, CalculateKeyedNetGroup (addr), " " , true );
1085+ NodeId id = GetNewNodeId ();
1086+ uint64_t nonce = GetDeterministicRandomizer (RANDOMIZER_ID_LOCALHOSTNONCE).Write (id).Finalize ();
1087+
1088+ CNode* pnode = new CNode (id, nLocalServices, GetBestHeight (), hSocket, addr, CalculateKeyedNetGroup (addr), nonce, " " , true );
10831089 pnode->fWhitelisted = whitelisted;
10841090 GetNodeSignals ().InitializeNode (pnode, *this );
10851091
@@ -2223,7 +2229,11 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
22232229 if (pnodeLocalHost == NULL ) {
22242230 CNetAddr local;
22252231 LookupHost (" 127.0.0.1" , local, false );
2226- pnodeLocalHost = new CNode (GetNewNodeId (), nLocalServices, GetBestHeight (), INVALID_SOCKET, CAddress (CService (local, 0 ), nLocalServices), 0 );
2232+
2233+ NodeId id = GetNewNodeId ();
2234+ uint64_t nonce = GetDeterministicRandomizer (RANDOMIZER_ID_LOCALHOSTNONCE).Write (id).Finalize ();
2235+
2236+ pnodeLocalHost = new CNode (id, nLocalServices, GetBestHeight (), INVALID_SOCKET, CAddress (CService (local, 0 ), nLocalServices), 0 , nonce);
22272237 GetNodeSignals ().InitializeNode (pnodeLocalHost, *this );
22282238 }
22292239
@@ -2622,11 +2632,16 @@ int CConnman::GetBestHeight() const
26222632unsigned int CConnman::GetReceiveFloodSize () const { return nReceiveFloodSize; }
26232633unsigned int CConnman::GetSendBufferSize () const { return nSendBufferMaxSize; }
26242634
2625- CNode::CNode (NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, const std::string& addrNameIn, bool fInboundIn , bool fNetworkNodeIn ) :
2635+ CNode::CNode (NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const std::string& addrNameIn, bool fInboundIn , bool fNetworkNodeIn ) :
26262636 addr (addrIn),
2637+ fInbound (fInboundIn ),
2638+ id (idIn),
26272639 nKeyedNetGroup (nKeyedNetGroupIn),
26282640 addrKnown (5000 , 0.001 ),
26292641 filterInventoryKnown (50000 , 0.000001 ),
2642+ nLocalHostNonce (nLocalHostNonceIn),
2643+ nLocalServices (nLocalServicesIn),
2644+ nMyStartingHeight (nMyStartingHeightIn),
26302645 nSendVersion (0 )
26312646{
26322647 nServices = NODE_NONE;
@@ -2648,7 +2663,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
26482663 fOneShot = false ;
26492664 fClient = false ; // set by version message
26502665 fFeeler = false ;
2651- fInbound = fInboundIn ;
26522666 fNetworkNode = fNetworkNodeIn ;
26532667 fSuccessfullyConnected = false ;
26542668 fDisconnect = false ;
@@ -2678,15 +2692,10 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
26782692 minFeeFilter = 0 ;
26792693 lastSentFeeFilter = 0 ;
26802694 nextSendTimeFeeFilter = 0 ;
2681- id = idIn;
2682- nLocalServices = nLocalServicesIn;
26832695 fPauseRecv = false ;
26842696 fPauseSend = false ;
26852697 nProcessQueueSize = 0 ;
26862698
2687- GetRandBytes ((unsigned char *)&nLocalHostNonce, sizeof (nLocalHostNonce));
2688- nMyStartingHeight = nMyStartingHeightIn;
2689-
26902699 BOOST_FOREACH (const std::string &msg, getAllNetMessageTypes ())
26912700 mapRecvBytesPerMsgCmd[msg] = 0 ;
26922701 mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0 ;
0 commit comments