fix mnb renewal (#1226)

This commit is contained in:
UdjinM6 2016-12-26 10:44:48 +04:00 committed by GitHub
parent 34fd8daf5a
commit cda28d3c72
3 changed files with 16 additions and 14 deletions

View File

@ -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

View File

@ -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)

View File

@ -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