diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 4a73ae0529ce3..49e3b6917d164 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -32,7 +32,8 @@ void CActiveMasternode::ManageStatus() pmn = mnodeman.Find(pubKeyMasternode); if(pmn != NULL) { pmn->Check(); - if(pmn->IsEnabled() && pmn->protocolVersion == PROTOCOL_VERSION) EnableHotColdMasterNode(pmn->vin, pmn->addr); + if((pmn->IsEnabled() || pmn->IsPreEnabled()) && pmn->protocolVersion == PROTOCOL_VERSION) + EnableHotColdMasterNode(pmn->vin, pmn->addr); } } diff --git a/src/masternode.cpp b/src/masternode.cpp index db7e722b11661..c7bd925ecd23a 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -183,6 +183,10 @@ void CMasternode::Check(bool forceCheck) //once spent, stop doing the checks if(activeState == MASTERNODE_VIN_SPENT) return; + if(lastPing.sigTime - sigTime < MASTERNODE_MIN_MNP_SECONDS){ + activeState = MASTERNODE_PRE_ENABLED; + return; + } if(!IsPingedWithin(MASTERNODE_REMOVAL_SECONDS)){ activeState = MASTERNODE_REMOVE; @@ -392,7 +396,7 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos) //search existing Masternode list, this is where we update existing Masternodes with new mnb broadcasts CMasternode* pmn = mnodeman.Find(vin); - // no such masternode or it's not enabled already, nothing to update + // no such masternode or it's not enabled yet/already, nothing to update if(pmn == NULL || (pmn != NULL && !pmn->IsEnabled())) return true; // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, @@ -421,8 +425,8 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) CMasternode* pmn = mnodeman.Find(vin); if(pmn != NULL) { - // nothing to do here if we already know about this masternode and it's enabled - if(pmn->IsEnabled()) return true; + // nothing to do here if we already know about this masternode and it's (pre)enabled + if(pmn->IsEnabled() || pmn->IsPreEnabled()) return true; // if it's not enabled, remove old MN first and continue else mnodeman.Remove(pmn->vin); } @@ -582,7 +586,7 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled) CMasternode* pmn = mnodeman.Find(vin); if(pmn != NULL && pmn->protocolVersion >= masternodePayments.GetMinMasternodePaymentsProto()) { - if (fRequireEnabled && !pmn->IsEnabled()) return false; + if (fRequireEnabled && !pmn->IsEnabled() && !pmn->IsPreEnabled()) return false; // LogPrintf("mnping - Found corresponding mn for vin: %s\n", vin.ToString()); // update only if there is no known ping for this masternode or diff --git a/src/masternode.h b/src/masternode.h index da97d0e7e560e..281cb20608e74 100644 --- a/src/masternode.h +++ b/src/masternode.h @@ -111,11 +111,12 @@ class CMasternode int64_t lastTimeChecked; public: enum state { - MASTERNODE_ENABLED = 1, - MASTERNODE_EXPIRED = 2, - MASTERNODE_VIN_SPENT = 3, - MASTERNODE_REMOVE = 4, - MASTERNODE_POS_ERROR = 5 + MASTERNODE_PRE_ENABLED, + MASTERNODE_ENABLED, + MASTERNODE_EXPIRED, + MASTERNODE_VIN_SPENT, + MASTERNODE_REMOVE, + MASTERNODE_POS_ERROR }; CTxIn vin; @@ -243,6 +244,11 @@ class CMasternode return activeState == MASTERNODE_ENABLED; } + bool IsPreEnabled() + { + return activeState == MASTERNODE_PRE_ENABLED; + } + int GetMasternodeInputAge() { if(chainActive.Tip() == NULL) return 0; @@ -256,13 +262,14 @@ class CMasternode } std::string Status() { - std::string strStatus = "ACTIVE"; - - if(activeState == CMasternode::MASTERNODE_ENABLED) strStatus = "ENABLED"; - if(activeState == CMasternode::MASTERNODE_EXPIRED) strStatus = "EXPIRED"; - if(activeState == CMasternode::MASTERNODE_VIN_SPENT) strStatus = "VIN_SPENT"; - if(activeState == CMasternode::MASTERNODE_REMOVE) strStatus = "REMOVE"; - if(activeState == CMasternode::MASTERNODE_POS_ERROR) strStatus = "POS_ERROR"; + std::string strStatus = "unknown"; + + if(activeState == CMasternode::MASTERNODE_PRE_ENABLED) strStatus = "PRE_ENABLED"; + if(activeState == CMasternode::MASTERNODE_ENABLED) strStatus = "ENABLED"; + if(activeState == CMasternode::MASTERNODE_EXPIRED) strStatus = "EXPIRED"; + if(activeState == CMasternode::MASTERNODE_VIN_SPENT) strStatus = "VIN_SPENT"; + if(activeState == CMasternode::MASTERNODE_REMOVE) strStatus = "REMOVE"; + if(activeState == CMasternode::MASTERNODE_POS_ERROR) strStatus = "POS_ERROR"; return strStatus; } diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index dc95c0e8d166e..70f23ac26a340 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -210,7 +210,7 @@ bool CMasternodeMan::Add(CMasternode &mn) { LOCK(cs); - if (!mn.IsEnabled()) + if (!mn.IsEnabled() && !mn.IsPreEnabled()) return false; CMasternode *pmn = Find(mn.vin);