From 84b03d28e0e1dbac24f4314c0cb4f1b0b591a36d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 25 Aug 2015 13:58:48 +0300 Subject: [PATCH] more mem fixes: - clean mapMasternodeBlocks and mapSeenSyncMNB too - clean mapSeenMasternodeBroadcast by lastPing sigTime nad fix clean threshold --- src/masternode-payments.cpp | 3 ++- src/masternode.cpp | 2 ++ src/masternodeman.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 63a30024b4..18384462b5 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -593,7 +593,7 @@ bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlo void CMasternodePayments::CleanPaymentList() { - LOCK(cs_mapMasternodePayeeVotes); + LOCK2(cs_mapMasternodePayeeVotes, cs_mapMasternodeBlocks); if(chainActive.Tip() == NULL) return; @@ -608,6 +608,7 @@ void CMasternodePayments::CleanPaymentList() LogPrint("mnpayments", "CMasternodePayments::CleanPaymentList - Removing old Masternode payment - block %d\n", winner.nBlockHeight); masternodeSync.mapSeenSyncMNW.erase((*it).first); mapMasternodePayeeVotes.erase(it++); + mapMasternodeBlocks.erase(winner.nBlockHeight); } else { ++it; } diff --git a/src/masternode.cpp b/src/masternode.cpp index 859da51316..ad2545bf31 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -444,6 +444,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) if(!lockMain) { // not mnb fault, let it to be checked again later mnodeman.mapSeenMasternodeBroadcast.erase(GetHash()); + masternodeSync.mapSeenSyncMNB.erase(GetHash()); return false; } @@ -460,6 +461,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) LogPrintf("mnb - Input must have at least %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS); // maybe we miss few blocks, let this mnb to be checked again later mnodeman.mapSeenMasternodeBroadcast.erase(GetHash()); + masternodeSync.mapSeenSyncMNB.erase(GetHash()); return false; } diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index aa7f37b499..b8d83a4872 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -327,8 +327,9 @@ void CMasternodeMan::CheckAndRemove(bool forceExpiredRemoval) // remove expired mapSeenMasternodeBroadcast map::iterator it3 = mapSeenMasternodeBroadcast.begin(); while(it3 != mapSeenMasternodeBroadcast.end()){ - if((*it3).second.sigTime < GetTime()-(MASTERNODE_MIN_MNP_SECONDS*2)){ + if((*it3).second.lastPing.sigTime < GetTime()-(MASTERNODE_REMOVAL_SECONDS*2)){ mapSeenMasternodeBroadcast.erase(it3++); + masternodeSync.mapSeenSyncMNB.erase((*it3).second.GetHash()); } else { ++it3; }