From 5520bf6895326c833d74bc2a78b1a65647c871cd Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Sun, 5 Feb 2017 04:24:34 -0500 Subject: [PATCH] Masternode index rebuild bug fix (#1318) * Clear old masternode index after vote map rebuild * Add masternode index size to CMasternodeMan::ToString --- src/governance.cpp | 6 +++++- src/masternodeman.cpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/governance.cpp b/src/governance.cpp index c7fad7bc8..fe816b4a5 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -1115,9 +1115,12 @@ int CGovernanceManager::GetMasternodeIndex(const CTxIn& masternodeVin) LOCK(cs); bool fIndexRebuilt = false; int nMNIndex = mnodeman.GetMasternodeIndex(masternodeVin, fIndexRebuilt); - while(fIndexRebuilt) { + if(fIndexRebuilt) { RebuildVoteMaps(); nMNIndex = mnodeman.GetMasternodeIndex(masternodeVin, fIndexRebuilt); + if(fIndexRebuilt) { + LogPrintf("CGovernanceManager::GetMasternodeIndex -- WARNING: vote map rebuild failed\n"); + } } return nMNIndex; } @@ -1127,6 +1130,7 @@ void CGovernanceManager::RebuildVoteMaps() for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) { it->second.RebuildVoteMap(); } + mnodeman.ClearOldMasternodeIndex(); } void CGovernanceManager::AddCachedTriggers() diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index ce964240b..42c9e1e14 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -1362,6 +1362,7 @@ std::string CMasternodeMan::ToString() const ", 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() << + ", masternode index size: " << indexMasternodes.GetSize() << ", nDsqCount: " << (int)nDsqCount; return info.str();