|
|
@ -2103,18 +2103,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
CAddress addrFrom; |
|
|
|
CAddress addrFrom; |
|
|
|
uint64 nNonce = 1; |
|
|
|
uint64 nNonce = 1; |
|
|
|
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; |
|
|
|
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; |
|
|
|
|
|
|
|
if (pfrom->nVersion < 209) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Since Februari 20, 2012, the protocol is initiated at version 209,
|
|
|
|
|
|
|
|
// and earlier versions are no longer supported
|
|
|
|
|
|
|
|
printf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion); |
|
|
|
|
|
|
|
pfrom->fDisconnect = true; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (pfrom->nVersion == 10300) |
|
|
|
if (pfrom->nVersion == 10300) |
|
|
|
pfrom->nVersion = 300; |
|
|
|
pfrom->nVersion = 300; |
|
|
|
if (pfrom->nVersion >= 106 && !vRecv.empty()) |
|
|
|
if (!vRecv.empty()) |
|
|
|
vRecv >> addrFrom >> nNonce; |
|
|
|
vRecv >> addrFrom >> nNonce; |
|
|
|
if (pfrom->nVersion >= 106 && !vRecv.empty()) |
|
|
|
if (!vRecv.empty()) |
|
|
|
vRecv >> pfrom->strSubVer; |
|
|
|
vRecv >> pfrom->strSubVer; |
|
|
|
if (pfrom->nVersion >= 209 && !vRecv.empty()) |
|
|
|
if (!vRecv.empty()) |
|
|
|
vRecv >> pfrom->nStartingHeight; |
|
|
|
vRecv >> pfrom->nStartingHeight; |
|
|
|
|
|
|
|
|
|
|
|
if (pfrom->nVersion == 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Disconnect if we connected to ourself
|
|
|
|
// Disconnect if we connected to ourself
|
|
|
|
if (nNonce == nLocalHostNonce && nNonce > 1) |
|
|
|
if (nNonce == nLocalHostNonce && nNonce > 1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2132,11 +2138,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
AddTimeData(pfrom->addr, nTime); |
|
|
|
AddTimeData(pfrom->addr, nTime); |
|
|
|
|
|
|
|
|
|
|
|
// Change version
|
|
|
|
// Change version
|
|
|
|
if (pfrom->nVersion >= 209) |
|
|
|
|
|
|
|
pfrom->PushMessage("verack"); |
|
|
|
pfrom->PushMessage("verack"); |
|
|
|
pfrom->vSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); |
|
|
|
pfrom->vSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); |
|
|
|
if (pfrom->nVersion < 209) |
|
|
|
|
|
|
|
pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pfrom->fInbound) |
|
|
|
if (!pfrom->fInbound) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2200,8 +2203,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
vRecv >> vAddr; |
|
|
|
vRecv >> vAddr; |
|
|
|
|
|
|
|
|
|
|
|
// Don't want addr from older versions unless seeding
|
|
|
|
// Don't want addr from older versions unless seeding
|
|
|
|
if (pfrom->nVersion < 209) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000) |
|
|
|
if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
if (vAddr.size() > 1000) |
|
|
|
if (vAddr.size() > 1000) |
|
|
@ -2663,8 +2664,6 @@ bool ProcessMessages(CNode* pfrom) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Checksum
|
|
|
|
// Checksum
|
|
|
|
if (vRecv.GetVersion() >= 209) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); |
|
|
|
uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); |
|
|
|
unsigned int nChecksum = 0; |
|
|
|
unsigned int nChecksum = 0; |
|
|
|
memcpy(&nChecksum, &hash, sizeof(nChecksum)); |
|
|
|
memcpy(&nChecksum, &hash, sizeof(nChecksum)); |
|
|
@ -2674,7 +2673,6 @@ bool ProcessMessages(CNode* pfrom) |
|
|
|
strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum); |
|
|
|
strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Copy message to its own buffer
|
|
|
|
// Copy message to its own buffer
|
|
|
|
CDataStream vMsg(vRecv.begin(), vRecv.begin() + nMessageSize, vRecv.nType, vRecv.nVersion); |
|
|
|
CDataStream vMsg(vRecv.begin(), vRecv.begin() + nMessageSize, vRecv.nType, vRecv.nVersion); |
|
|
|