Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.12.1.x pre-enabled status from masternodes #561

Merged
merged 1 commit into from
Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,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;
Expand Down Expand Up @@ -398,7 +402,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,
Expand Down Expand Up @@ -427,8 +431,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);
}
Expand Down Expand Up @@ -586,7 +590,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
Expand Down
31 changes: 19 additions & 12 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -246,6 +247,11 @@ class CMasternode
return activeState == MASTERNODE_ENABLED;
}

bool IsPreEnabled()
{
return activeState == MASTERNODE_PRE_ENABLED;
}

int GetMasternodeInputAge()
{
if(chainActive.Tip() == NULL) return 0;
Expand All @@ -259,13 +265,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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down