diff --git a/src/masternode.cpp b/src/masternode.cpp index a3835d52f..edcc51405 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -121,7 +121,7 @@ bool CMasternode::UpdateFromNewBroadcast(CMasternodeBroadcast& mnb) nTimeLastChecked = 0; nTimeLastWatchdogVote = mnb.sigTime; int nDos = 0; - if(mnb.lastPing == CMasternodePing() || (mnb.lastPing != CMasternodePing() && mnb.lastPing.CheckAndUpdate(this, nDos))) { + if(mnb.lastPing == CMasternodePing() || (mnb.lastPing != CMasternodePing() && mnb.lastPing.CheckAndUpdate(this, true, nDos))) { lastPing = mnb.lastPing; mnodeman.mapSeenMasternodePing.insert(std::make_pair(lastPing.GetHash(), lastPing)); } @@ -856,7 +856,7 @@ bool CMasternodePing::SimpleCheck(int& nDos) return true; } -bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, int& nDos) +bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos) { // don't ban by default nDos = 0; @@ -870,6 +870,18 @@ bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, int& nDos) return false; } + if(!fFromNewBroadcast) { + if (pmn->IsUpdateRequired()) { + LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode protocol is outdated, masternode=%s\n", vin.prevout.ToStringShort()); + return false; + } + + if (pmn->IsNewStartRequired()) { + LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode is completely expired, new start is required, masternode=%s\n", vin.prevout.ToStringShort()); + return false; + } + } + { LOCK(cs_main); BlockMap::iterator mi = mapBlockIndex.find(blockHash); @@ -882,16 +894,6 @@ bool CMasternodePing::CheckAndUpdate(CMasternode* pmn, int& nDos) LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- New ping: masternode=%s blockHash=%s sigTime=%d\n", vin.prevout.ToStringShort(), blockHash.ToString(), sigTime); - if (pmn->IsUpdateRequired()) { - LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode protocol is outdated, masternode=%s\n", vin.prevout.ToStringShort()); - return false; - } - - if (pmn->IsNewStartRequired()) { - LogPrint("masternode", "CMasternodePing::CheckAndUpdate -- masternode is completely expired, new start is required, masternode=%s\n", vin.prevout.ToStringShort()); - return false; - } - // LogPrintf("mnping - Found corresponding mn for vin: %s\n", vin.prevout.ToStringShort()); // update only if there is no known ping for this masternode or // last ping was more then MASTERNODE_MIN_MNP_SECONDS-60 ago comparing to this one diff --git a/src/masternode.h b/src/masternode.h index 518b90e41..ba62182c9 100644 --- a/src/masternode.h +++ b/src/masternode.h @@ -81,7 +81,7 @@ public: bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); bool CheckSignature(CPubKey& pubKeyMasternode, int &nDos); bool SimpleCheck(int& nDos); - bool CheckAndUpdate(CMasternode* pmn, int& nDos); + bool CheckAndUpdate(CMasternode* pmn, bool fFromNewBroadcast, int& nDos); void Relay(); CMasternodePing& operator=(CMasternodePing from) diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index dd51d23bd..f75cc9714 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -744,7 +744,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if(pmn && pmn->IsNewStartRequired()) return; int nDos = 0; - if(mnp.CheckAndUpdate(pmn, nDos)) return; + if(mnp.CheckAndUpdate(pmn, false, nDos)) return; if(nDos > 0) { // if anything significant failed, mark that node