From 70fe35071ffc4b57fd8f6083ff30dde1e39af72b Mon Sep 17 00:00:00 2001 From: random-zebra Date: Sun, 14 Feb 2021 18:42:58 +0100 Subject: [PATCH] [MN] Stop processing legacy masternodes after SPORK_21 is active --- src/masternodeman.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 3a45f25fb85a6..9b80069f087b0 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -6,6 +6,7 @@ #include "masternodeman.h" #include "addrman.h" +#include "evo/deterministicmns.h" #include "fs.h" #include "masternode-payments.h" #include "masternode-sync.h" @@ -190,6 +191,11 @@ CMasternodeMan::CMasternodeMan(): bool CMasternodeMan::Add(CMasternode& mn) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + return false; + } + LOCK(cs); if (!mn.IsAvailableState()) @@ -208,6 +214,11 @@ bool CMasternodeMan::Add(CMasternode& mn) void CMasternodeMan::AskForMN(CNode* pnode, const CTxIn& vin) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + return; + } + std::map::iterator i = mWeAskedForMasternodeListEntry.find(vin.prevout); if (i != mWeAskedForMasternodeListEntry.end()) { int64_t t = (*i).second; @@ -226,6 +237,13 @@ int CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval) { LOCK(cs); + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + LogPrint(BCLog::MASTERNODE, "Removing all legacy mn due to SPORK 21\n"); + Clear(); + return 0; + } + //remove inactive and outdated auto it = mapMasternodes.begin(); while (it != mapMasternodes.end()) { @@ -404,6 +422,11 @@ int CMasternodeMan::CountNetworks(int& ipv4, int& ipv6, int& onion) const void CMasternodeMan::DsegUpdate(CNode* pnode) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + return; + } + LOCK(cs); if (Params().NetworkIDString() == CBaseChainParams::MAIN) { @@ -451,6 +474,11 @@ CMasternode* CMasternodeMan::Find(const CPubKey& pubKeyMasternode) void CMasternodeMan::CheckSpentCollaterals(const std::vector& vtx) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + return; + } + LOCK(cs); for (const auto& tx : vtx) { for (const auto& in : tx->vin) { @@ -715,6 +743,12 @@ int CMasternodeMan::ProcessMNPing(CNode* pfrom, CMasternodePing& mnp) int CMasternodeMan::ProcessGetMNList(CNode* pfrom, CTxIn& vin) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + LogPrint(BCLog::MASTERNODE, "dseg - skip obsolete message\n"); + return 0; + } + if (vin.IsNull()) { //only should ask for this once //local network bool isLocal = (pfrom->addr.IsRFC1918() || pfrom->addr.IsLocal()); @@ -782,6 +816,12 @@ int CMasternodeMan::ProcessMessageInner(CNode* pfrom, std::string& strCommand, C if (fLiteMode) return 0; //disable all Masternode related functionality if (!masternodeSync.IsBlockchainSynced()) return 0; + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + LogPrint(BCLog::MASTERNODE, "%s: skip obsolete message %s\n", __func__, strCommand); + return 0; + } + LOCK(cs_process_message); if (strCommand == NetMsgType::MNBROADCAST) { @@ -817,6 +857,12 @@ void CMasternodeMan::Remove(const COutPoint& collateralOut) void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast& mnb) { + // Skip after legacy obsolete. !TODO: remove when transition to DMN is complete + if (deterministicMNManager->LegacyMNObsolete()) { + LogPrint(BCLog::MASTERNODE, "Removing all legacy mn due to SPORK 21\n"); + return; + } + mapSeenMasternodePing.emplace(mnb.lastPing.GetHash(), mnb.lastPing); mapSeenMasternodeBroadcast.emplace(mnb.GetHash(), mnb); masternodeSync.AddedMasternodeList(mnb.GetHash());