p2p: remove some old protocol version checks/dead code (#3647)

Signed-off-by: pasta <pasta@dashboost.org>
This commit is contained in:
PastaPastaPasta 2020-08-14 07:42:15 -04:00 committed by GitHub
parent d12137b9c2
commit 7725e6fa4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 64 deletions

View File

@ -510,7 +510,7 @@ void CQuorumBlockProcessor::AddMinableCommitment(const CFinalCommitment& fqc)
// We only relay the new commitment if it's new or better then the old one
if (relay) {
CInv inv(MSG_QUORUM_FINAL_COMMITMENT, commitmentHash);
g_connman->RelayInv(inv, DMN_PROTO_VERSION);
g_connman->RelayInv(inv);
}
}

View File

@ -1413,7 +1413,7 @@ void CConnman::InactivityCheck(CNode *pnode)
LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend);
pnode->fDisconnect = true;
}
else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90*60))
else if (nTime - pnode->nLastRecv > TIMEOUT_INTERVAL)
{
LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv);
pnode->fDisconnect = true;

View File

@ -2057,14 +2057,9 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
(strCommand == NetMsgType::FILTERLOAD ||
strCommand == NetMsgType::FILTERADD))
{
if (pfrom->nVersion >= NO_BLOOM_VERSION) {
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 100);
return false;
} else {
pfrom->fDisconnect = true;
return false;
}
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 100);
return false;
}
if (strCommand == NetMsgType::REJECT)
@ -2322,15 +2317,13 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
CMNAuth::PushMNAUTH(pfrom, *connman);
}
if (pfrom->nVersion >= SENDHEADERS_VERSION) {
// Tell our peer we prefer to receive headers rather than inv's
// We send this to non-NODE NETWORK peers as well, because even
// non-NODE NETWORK peers can announce blocks (such as pruning
// nodes)
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDHEADERS));
}
// Tell our peer we prefer to receive headers rather than inv's
// We send this to non-NODE NETWORK peers as well, because even
// non-NODE NETWORK peers can announce blocks (such as pruning
// nodes)
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::SENDHEADERS));
if (pfrom->nVersion >= SHORT_IDS_BLOCKS_VERSION && !pfrom->fMasternode) {
if (!pfrom->fMasternode) {
// Tell our peer we are willing to provide version-1 cmpctblocks
// However, we do not request new block announcements using
// cmpctblock messages.
@ -3348,23 +3341,20 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
}
if (strCommand == NetMsgType::PING) {
if (pfrom->nVersion > BIP0031_VERSION)
{
uint64_t nonce = 0;
vRecv >> nonce;
// Echo the message back with the nonce. This allows for two useful features:
//
// 1) A remote node can quickly check if the connection is operational
// 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
// avoid sending us more work, like chain download requests.
//
// The nonce stops the remote getting confused between different pings: without
// 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
// return very quickly.
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::PONG, nonce));
}
uint64_t nonce = 0;
vRecv >> nonce;
// Echo the message back with the nonce. This allows for two useful features:
//
// 1) A remote node can quickly check if the connection is operational
// 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
// avoid sending us more work, like chain download requests.
//
// The nonce stops the remote getting confused between different pings: without
// 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
// return very quickly.
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::PONG, nonce));
return true;
}
@ -3908,14 +3898,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
}
pto->fPingQueued = false;
pto->nPingUsecStart = GetTimeMicros();
if (pto->nVersion > BIP0031_VERSION) {
pto->nPingNonceSent = nonce;
connman->PushMessage(pto, msgMaker.Make(NetMsgType::PING, nonce));
} else {
// Peer is too old to support ping command with nonce, pong will never arrive.
pto->nPingNonceSent = 0;
connman->PushMessage(pto, msgMaker.Make(NetMsgType::PING));
}
pto->nPingNonceSent = nonce;
connman->PushMessage(pto, msgMaker.Make(NetMsgType::PING, nonce));
}
TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState()

View File

@ -16,9 +16,6 @@ static const int PROTOCOL_VERSION = 70218;
//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
//! In this version, 'getheaders' was introduced.
static const int GETHEADERS_VERSION = 70077;
//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 70213;
@ -29,24 +26,6 @@ static const int MIN_MASTERNODE_PROTO_VERSION = 70218;
//! if possible, avoid requesting addresses nodes older than this
static const int CADDR_TIME_VERSION = 31402;
//! BIP 0031, pong message, is enabled for all versions AFTER this one
static const int BIP0031_VERSION = 60000;
//! "filter*" commands are disabled without NODE_BLOOM after and including this version
static const int NO_BLOOM_VERSION = 70201;
//! "sendheaders" command and announcing blocks with headers starts with this version
static const int SENDHEADERS_VERSION = 70201;
//! DIP0001 was activated in this version
static const int DIP0001_PROTOCOL_VERSION = 70208;
//! short-id-based block download starts with this version
static const int SHORT_IDS_BLOCKS_VERSION = 70209;
//! introduction of DIP3/deterministic masternodes
static const int DMN_PROTO_VERSION = 70213;
//! introduction of LLMQs
static const int LLMQS_PROTO_VERSION = 70214;