Auto merge of #2473 - ebfull:init-proto-hotfix-release, r=ebfull
Revert changes to INIT_PROTO_VERSION This reverts https://github.com/zcash/zcash/pull/2245 in order to fix degraded networking behavior for 1.0.10 clients.
This commit is contained in:
55
src/main.cpp
55
src/main.cpp
@@ -4358,6 +4358,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pfrom->nVersion == 10300)
|
||||||
|
pfrom->nVersion = 300;
|
||||||
if (!vRecv.empty())
|
if (!vRecv.empty())
|
||||||
vRecv >> addrFrom >> nNonce;
|
vRecv >> addrFrom >> nNonce;
|
||||||
if (!vRecv.empty()) {
|
if (!vRecv.empty()) {
|
||||||
@@ -4416,8 +4418,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get recent addresses
|
// Get recent addresses
|
||||||
pfrom->PushMessage("getaddr");
|
if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000)
|
||||||
pfrom->fGetAddr = true;
|
{
|
||||||
|
pfrom->PushMessage("getaddr");
|
||||||
|
pfrom->fGetAddr = true;
|
||||||
|
}
|
||||||
addrman.Good(pfrom->addr);
|
addrman.Good(pfrom->addr);
|
||||||
} else {
|
} else {
|
||||||
if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom)
|
if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom)
|
||||||
@@ -4476,6 +4481,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
vector<CAddress> vAddr;
|
vector<CAddress> vAddr;
|
||||||
vRecv >> 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)
|
if (vAddr.size() > 1000)
|
||||||
{
|
{
|
||||||
Misbehaving(pfrom->GetId(), 20);
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
@@ -4510,6 +4518,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
multimap<uint256, CNode*> mapMix;
|
multimap<uint256, CNode*> mapMix;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||||
{
|
{
|
||||||
|
if (pnode->nVersion < CADDR_TIME_VERSION)
|
||||||
|
continue;
|
||||||
unsigned int nPointer;
|
unsigned int nPointer;
|
||||||
memcpy(&nPointer, &pnode, sizeof(nPointer));
|
memcpy(&nPointer, &pnode, sizeof(nPointer));
|
||||||
uint256 hashKey = ArithToUint256(UintToArith256(hashRand) ^ nPointer);
|
uint256 hashKey = ArithToUint256(UintToArith256(hashRand) ^ nPointer);
|
||||||
@@ -4960,20 +4970,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
|
|
||||||
else if (strCommand == "ping")
|
else if (strCommand == "ping")
|
||||||
{
|
{
|
||||||
uint64_t nonce = 0;
|
if (pfrom->nVersion > BIP0031_VERSION)
|
||||||
vRecv >> nonce;
|
{
|
||||||
// Echo the message back with the nonce. This allows for two useful features:
|
uint64_t nonce = 0;
|
||||||
//
|
vRecv >> nonce;
|
||||||
// 1) A remote node can quickly check if the connection is operational
|
// Echo the message back with the nonce. This allows for two useful features:
|
||||||
// 2) Remote nodes can measure the latency of the network thread. If this node
|
//
|
||||||
// is overloaded it won't respond to pings quickly and the remote node can
|
// 1) A remote node can quickly check if the connection is operational
|
||||||
// avoid sending us more work, like chain download requests.
|
// 2) Remote nodes can measure the latency of the network thread. If this node
|
||||||
//
|
// is overloaded it won't respond to pings quickly and the remote node can
|
||||||
// The nonce stops the remote getting confused between different pings: without
|
// avoid sending us more work, like chain download requests.
|
||||||
// it, if the remote node sends a ping once per second and this node takes 5
|
//
|
||||||
// seconds to respond to each, the 5th ping the remote sends would appear to
|
// The nonce stops the remote getting confused between different pings: without
|
||||||
// return very quickly.
|
// it, if the remote node sends a ping once per second and this node takes 5
|
||||||
pfrom->PushMessage("pong", nonce);
|
// seconds to respond to each, the 5th ping the remote sends would appear to
|
||||||
|
// return very quickly.
|
||||||
|
pfrom->PushMessage("pong", nonce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5301,8 +5314,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
}
|
}
|
||||||
pto->fPingQueued = false;
|
pto->fPingQueued = false;
|
||||||
pto->nPingUsecStart = GetTimeMicros();
|
pto->nPingUsecStart = GetTimeMicros();
|
||||||
pto->nPingNonceSent = nonce;
|
if (pto->nVersion > BIP0031_VERSION) {
|
||||||
pto->PushMessage("ping", nonce);
|
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()
|
TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState()
|
||||||
|
|||||||
@@ -1194,7 +1194,7 @@ void ThreadSocketHandler()
|
|||||||
LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend);
|
LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend);
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
}
|
}
|
||||||
else if (nTime - pnode->nLastRecv > TIMEOUT_INTERVAL)
|
else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90*60))
|
||||||
{
|
{
|
||||||
LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv);
|
LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv);
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ public:
|
|||||||
Init();
|
Init();
|
||||||
if (nType & SER_DISK)
|
if (nType & SER_DISK)
|
||||||
READWRITE(nVersion);
|
READWRITE(nVersion);
|
||||||
if ((nType & SER_DISK) || !(nType & SER_GETHASH))
|
if ((nType & SER_DISK) ||
|
||||||
|
(nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
|
||||||
READWRITE(nTime);
|
READWRITE(nTime);
|
||||||
READWRITE(nServices);
|
READWRITE(nServices);
|
||||||
READWRITE(*(CService*)this);
|
READWRITE(*(CService*)this);
|
||||||
|
|||||||
@@ -12,9 +12,26 @@
|
|||||||
static const int PROTOCOL_VERSION = 170002;
|
static const int PROTOCOL_VERSION = 170002;
|
||||||
|
|
||||||
//! initial proto version, to be increased after version/verack negotiation
|
//! initial proto version, to be increased after version/verack negotiation
|
||||||
static const int INIT_PROTO_VERSION = 170002;
|
static const int INIT_PROTO_VERSION = 209;
|
||||||
|
|
||||||
|
//! In this version, 'getheaders' was introduced.
|
||||||
|
static const int GETHEADERS_VERSION = 31800;
|
||||||
|
|
||||||
//! disconnect from peers older than this proto version
|
//! disconnect from peers older than this proto version
|
||||||
static const int MIN_PEER_PROTO_VERSION = 170002;
|
static const int MIN_PEER_PROTO_VERSION = 170002;
|
||||||
|
|
||||||
|
//! nTime field added to CAddress, starting with this version;
|
||||||
|
//! if possible, avoid requesting addresses nodes older than this
|
||||||
|
static const int CADDR_TIME_VERSION = 31402;
|
||||||
|
|
||||||
|
//! only request blocks from nodes outside this range of versions
|
||||||
|
static const int NOBLKS_VERSION_START = 32000;
|
||||||
|
static const int NOBLKS_VERSION_END = 32400;
|
||||||
|
|
||||||
|
//! BIP 0031, pong message, is enabled for all versions AFTER this one
|
||||||
|
static const int BIP0031_VERSION = 60000;
|
||||||
|
|
||||||
|
//! "mempool" command, enhanced "getdata" behavior starts with this version
|
||||||
|
static const int MEMPOOL_GD_VERSION = 60002;
|
||||||
|
|
||||||
#endif // BITCOIN_VERSION_H
|
#endif // BITCOIN_VERSION_H
|
||||||
|
|||||||
Reference in New Issue
Block a user