From c861137624166b2564a91c6f2f6c5644128b30f1 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 12 Sep 2018 10:17:33 +0100 Subject: [PATCH] net: Check against the current epoch's version when disconnecting peers --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9b0ce308d..ecc5645da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5149,15 +5149,15 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Disconnect existing peer connection when: // 1. The version message has been received - // 2. Overwinter is active - // 3. Peer version is pre-Overwinter - else if (NetworkUpgradeActive(GetHeight(), chainparams.GetConsensus(), Consensus::UPGRADE_OVERWINTER) - && (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)) + // 2. Peer version is below the minimum version for the current epoch + else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[ + CurrentEpoch(GetHeight(), chainparams.GetConsensus())].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", - chainparams.GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)); + chainparams.GetConsensus().vUpgrades[ + CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)); pfrom->fDisconnect = true; return false; }