net: Check against the current epoch's version when rejecting nodes

This commit is contained in:
Jack Grigg
2018-09-12 09:27:28 +01:00
parent d2b5a2daeb
commit ebf4c0671e

View File

@@ -5016,15 +5016,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return false; return false;
} }
// When Overwinter is active, reject incoming connections from non-Overwinter nodes // Reject incoming connections from nodes that don't know about the current epoch
const Consensus::Params& params = Params().GetConsensus(); const Consensus::Params& params = Params().GetConsensus();
if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER) auto currentEpoch = CurrentEpoch(GetHeight(), params);
&& pfrom->nVersion < params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion) if (pfrom->nVersion < params.vUpgrades[currentEpoch].nProtocolVersion)
{ {
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", strprintf("Version must be %d or greater",
params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)); params.vUpgrades[currentEpoch].nProtocolVersion));
pfrom->fDisconnect = true; pfrom->fDisconnect = true;
return false; return false;
} }