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.11.2.x check expired MNs right on client start #210

Merged
merged 2 commits into from
Mar 2, 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
6 changes: 4 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,12 @@ bool AppInit2(boost::thread_group& threadGroup)
CMasternodeDB mndb;
if (!mndb.Read(mnodeman))
LogPrintf("Invalid or missing masternodes.dat; recreating\n");
else
mnodeman.CheckAndRemove(); // clean out expired
}

LogPrintf("Loaded %i masternodes from masternodes.dat %dms\n",
mnodeman.size(), GetTimeMillis() - nStart);
LogPrintf("Loaded info from masternodes.dat %dms\n", GetTimeMillis() - nStart);
LogPrintf(" %s\n", mnodeman.ToString());


fMasterNode = GetBoolArg("-masternode", false);
Expand Down
19 changes: 16 additions & 3 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ void DumpMasternodes()
CMasternodeDB mndb;
mndb.Write(mnodeman);

LogPrintf("Flushed %d masternodes to masternodes.dat %dms\n", mnodeman.size(), GetTimeMillis() - nStart);
LogPrintf("Flushed info to masternodes.dat %dms\n", GetTimeMillis() - nStart);
LogPrintf(" %s\n", mnodeman.ToString());
}

CMasternodeMan::CMasternodeMan() {}
Expand All @@ -139,7 +140,7 @@ bool CMasternodeMan::Add(CMasternode &mn)

if (pmn == NULL)
{
LogPrintf("CMasternodeMan: Adding new masternode %s\n", mn.addr.ToString().c_str());
if(fDebug) LogPrintf("CMasternodeMan: Adding new masternode %s - %i now\n", mn.addr.ToString().c_str(), size() + 1);
vMasternodes.push_back(mn);
return true;
}
Expand All @@ -165,7 +166,7 @@ void CMasternodeMan::CheckAndRemove()
vector<CMasternode>::iterator it = vMasternodes.begin();
while(it != vMasternodes.end()){
if((*it).activeState == 4 || (*it).activeState == 3){
LogPrintf("CMasternodeMan: Removing inactive masternode %s\n", (*it).addr.ToString().c_str());
if(fDebug) LogPrintf("CMasternodeMan: Removing inactive masternode %s - %i now\n", (*it).addr.ToString().c_str(), size() - 1);
it = vMasternodes.erase(it);
} else {
++it;
Expand Down Expand Up @@ -628,3 +629,15 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
}

}

std::string CMasternodeMan::ToString()
{
std::ostringstream info;

info << "masternodes: " << (int)vMasternodes.size() <<
", peers who asked us for masternode list: " << (int)mAskedUsForMasternodeList.size() <<
", peers we asked for masternode list: " << (int)mWeAskedForMasternodeList.size() <<
", entries in masternode list we asked for: " << (int)mWeAskedForMasternodeListEntry.size();

return info.str();
}
2 changes: 2 additions & 0 deletions src/masternodeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class CMasternodeMan
// Return the number of (unique) masternodes
int size() { return vMasternodes.size(); }

std::string ToString();

};

#endif