net: Check against the current epoch's version when rejecting nodes
This commit is contained in:
@@ -5016,15 +5016,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
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();
|
||||
if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER)
|
||||
&& pfrom->nVersion < params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)
|
||||
auto currentEpoch = CurrentEpoch(GetHeight(), params);
|
||||
if (pfrom->nVersion < params.vUpgrades[currentEpoch].nProtocolVersion)
|
||||
{
|
||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||
strprintf("Version must be %d or greater",
|
||||
params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion));
|
||||
params.vUpgrades[currentEpoch].nProtocolVersion));
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user