Fix masternode rate checks (#1187)

* Added logging to PushInventory

* Fix LogPrint format

* Log errors found during governance syncing

* Turn off rate checks during syncing

* Turn off rate check during maintenance
This commit is contained in:
Tim Flynn 2016-12-04 15:33:39 -05:00 committed by UdjinM6
parent 3ebcb78e12
commit 9f2d79d920
2 changed files with 43 additions and 15 deletions

View File

@ -368,6 +368,8 @@ void CGovernanceManager::UpdateCachesAndClean()
if(!pCurrentBlockIndex) return; if(!pCurrentBlockIndex) return;
fRateChecksEnabled = false;
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- After pCurrentBlockIndex (not NULL)\n"); LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- After pCurrentBlockIndex (not NULL)\n");
// UPDATE CACHE FOR EACH OBJECT THAT IS FLAGGED DIRTYCACHE=TRUE // UPDATE CACHE FOR EACH OBJECT THAT IS FLAGGED DIRTYCACHE=TRUE
@ -423,6 +425,8 @@ void CGovernanceManager::UpdateCachesAndClean()
++it; ++it;
} }
} }
fRateChecksEnabled = true;
} }
CGovernanceObject *CGovernanceManager::FindGovernanceObject(const uint256& nHash) CGovernanceObject *CGovernanceManager::FindGovernanceObject(const uint256& nHash)
@ -625,31 +629,51 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
// SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT // SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT
LogPrint("gobject", "CGovernanceManager::Sync -- syncing to peer=%d, nProp = %s\n", pfrom->id, nProp.ToString());
{ {
LOCK(cs); LOCK(cs);
fRateChecksEnabled = false;
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) { for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
uint256 h = it->first; uint256 h = it->first;
CGovernanceObject& govobj = it->second; CGovernanceObject& govobj = it->second;
std::string strError; if((nProp != uint256()) && (h != nProp)) {
if(govobj.IsSetCachedValid() && continue;
(nProp == uint256() || h == nProp) && }
govobj.IsValidLocally(pCurrentBlockIndex, strError, true)) {
// Push the inventory budget proposal message over to the other client
pfrom->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, h));
++nInvCount;
std::vector<CGovernanceVote> vecVotes = govobj.GetVoteFile().GetVotes(); LogPrint("gobject", "CGovernanceManager::Sync -- attempting to sync govobj: %s, peer=%d\n", govobj.GetHash().ToString(), pfrom->id);
for(size_t i = 0; i < vecVotes.size(); ++i) {
if(!vecVotes[i].IsValid(true)) { std::string strError;
continue; bool fIsValid = govobj.IsValidLocally(pCurrentBlockIndex, strError, true);
} if(!fIsValid) {
pfrom->PushInventory(CInv(MSG_GOVERNANCE_OBJECT_VOTE, vecVotes[i].GetHash())); LogPrintf("CGovernanceManager::Sync -- not syncing invalid govobj: %s, strError = %s, fCachedValid = %d, peer=%d\n",
++nInvCount; govobj.GetHash().ToString(), strError, govobj.IsSetCachedValid(), pfrom->id);
continue;
}
if(!govobj.IsSetCachedValid()) {
LogPrintf("CGovernanceManager::Sync -- invalid flag cached, not syncing govobj: %s, fCachedValid = %d, peer=%d\n",
govobj.GetHash().ToString(), govobj.IsSetCachedValid(), pfrom->id);
continue;
}
// Push the inventory budget proposal message over to the other client
LogPrint("gobject", "CGovernanceManager::Sync -- syncing govobj: %s, peer=%d\n", govobj.GetHash().ToString(), pfrom->id);
pfrom->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, h));
++nInvCount;
std::vector<CGovernanceVote> vecVotes = govobj.GetVoteFile().GetVotes();
for(size_t i = 0; i < vecVotes.size(); ++i) {
if(!vecVotes[i].IsValid(true)) {
continue;
} }
pfrom->PushInventory(CInv(MSG_GOVERNANCE_OBJECT_VOTE, vecVotes[i].GetHash()));
++nInvCount;
} }
} }
fRateChecksEnabled = true;
} }
pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, nInvCount); pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, nInvCount);

View File

@ -15,6 +15,7 @@
#include "streams.h" #include "streams.h"
#include "sync.h" #include "sync.h"
#include "uint256.h" #include "uint256.h"
#include "util.h"
#include <deque> #include <deque>
#include <stdint.h> #include <stdint.h>
@ -510,8 +511,11 @@ public:
{ {
{ {
LOCK(cs_inventory); LOCK(cs_inventory);
if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash)) if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash)) {
LogPrint("net", "PushInventory -- filtered inv: %s peer=%d\n", inv.ToString(), id);
return; return;
}
LogPrint("net", "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
vInventoryToSend.push_back(inv); vInventoryToSend.push_back(inv);
} }
} }