|
|
@ -4418,8 +4418,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
} |
|
|
|
|
|
|
|
// Get recent addresses
|
|
|
|
if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000) |
|
|
|
{ |
|
|
|
pfrom->PushMessage("getaddr"); |
|
|
|
pfrom->fGetAddr = true; |
|
|
|
} |
|
|
|
addrman.Good(pfrom->addr); |
|
|
|
} else { |
|
|
|
if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom) |
|
|
@ -4478,6 +4481,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
vector<CAddress> vAddr; |
|
|
|
vRecv >> vAddr; |
|
|
|
|
|
|
|
// Don't want addr from older versions unless seeding
|
|
|
|
if (pfrom->nVersion < CADDR_TIME_VERSION && addrman.size() > 1000) |
|
|
|
return true; |
|
|
|
if (vAddr.size() > 1000) |
|
|
|
{ |
|
|
|
Misbehaving(pfrom->GetId(), 20); |
|
|
@ -4512,6 +4518,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
multimap<uint256, CNode*> mapMix; |
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) |
|
|
|
{ |
|
|
|
if (pnode->nVersion < CADDR_TIME_VERSION) |
|
|
|
continue; |
|
|
|
unsigned int nPointer; |
|
|
|
memcpy(&nPointer, &pnode, sizeof(nPointer)); |
|
|
|
uint256 hashKey = ArithToUint256(UintToArith256(hashRand) ^ nPointer); |
|
|
@ -4961,6 +4969,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
|
|
|
|
|
|
|
|
else if (strCommand == "ping") |
|
|
|
{ |
|
|
|
if (pfrom->nVersion > BIP0031_VERSION) |
|
|
|
{ |
|
|
|
uint64_t nonce = 0; |
|
|
|
vRecv >> nonce; |
|
|
@ -4977,6 +4987,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
// return very quickly.
|
|
|
|
pfrom->PushMessage("pong", nonce); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (strCommand == "pong") |
|
|
@ -5303,8 +5314,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) |
|
|
|
} |
|
|
|
pto->fPingQueued = false; |
|
|
|
pto->nPingUsecStart = GetTimeMicros(); |
|
|
|
if (pto->nVersion > BIP0031_VERSION) { |
|
|
|
pto->nPingNonceSent = nonce; |
|
|
|
pto->PushMessage("ping", nonce); |
|
|
|
} else { |
|
|
|
// Peer is too old to support ping command with nonce, pong will never arrive.
|
|
|
|
pto->nPingNonceSent = 0; |
|
|
|
pto->PushMessage("ping"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState()
|
|
|
|