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

Fix crash in CheckAndRemove #732

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 15 additions & 13 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
(*it).activeState == CMasternode::MASTERNODE_VIN_SPENT ||
(forceExpiredRemoval && (*it).activeState == CMasternode::MASTERNODE_EXPIRED) ||
(*it).protocolVersion < mnpayments.GetMinMasternodePaymentsProto()) {
LogPrint("masternode", "CMasternodeMan: Removing inactive Masternode %s - %i now\n", (*it).addr.ToString(), size() - 1);
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing inactive Masternode %s - %i now\n", (*it).addr.ToString(), size() - 1);

//erase all of the broadcasts we've seen from this vin
// -- if we missed a few pings and the node was removed, this will allow is to get it back without them
Expand Down Expand Up @@ -326,21 +326,23 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval)
}
}

// remove expired mapSeenMasternodeBroadcast
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
while(it3 != mapSeenMasternodeBroadcast.end()){
if((*it3).second.lastPing.sigTime < GetTime()-(MASTERNODE_REMOVAL_SECONDS*2)){
mapSeenMasternodeBroadcast.erase(it3++);
masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash());
} else {
++it3;
}
}

// remove expired mapSeenMasternodeBroadcast
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
while(it3 != mapSeenMasternodeBroadcast.end()){
if((*it3).second.lastPing.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode broadcast %s\n", (*it3).second.GetHash().ToString());
masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash());
mapSeenMasternodeBroadcast.erase(it3++);
} else {
++it3;
}
}

// remove expired mapSeenMasternodePing
map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin();
while(it4 != mapSeenMasternodePing.end()){
if((*it4).second.sigTime < GetTime()-(MASTERNODE_REMOVAL_SECONDS*2)){
if((*it4).second.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode ping %s\n", (*it3).second.GetHash().ToString());
mapSeenMasternodePing.erase(it4++);
} else {
++it4;
Expand Down