From ebf4c0671e617f0cbbf59967e65eb7da758058cf Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 12 Sep 2018 09:27:28 +0100 Subject: [PATCH] net: Check against the current epoch's version when rejecting nodes --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 54928d3f1..9b0ce308d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; }