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;
fRateChecksEnabled = false;
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- After pCurrentBlockIndex (not NULL)\n");
// UPDATE CACHE FOR EACH OBJECT THAT IS FLAGGED DIRTYCACHE=TRUE
@ -423,6 +425,8 @@ void CGovernanceManager::UpdateCachesAndClean()
++it;
}
}
fRateChecksEnabled = true;
}
CGovernanceObject *CGovernanceManager::FindGovernanceObject(const uint256& nHash)
@ -625,18 +629,38 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
// SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT
LogPrint("gobject", "CGovernanceManager::Sync -- syncing to peer=%d, nProp = %s\n", pfrom->id, nProp.ToString());
{
LOCK(cs);
fRateChecksEnabled = false;
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
uint256 h = it->first;
CGovernanceObject& govobj = it->second;
if((nProp != uint256()) && (h != nProp)) {
continue;
}
LogPrint("gobject", "CGovernanceManager::Sync -- attempting to sync govobj: %s, peer=%d\n", govobj.GetHash().ToString(), pfrom->id);
std::string strError;
if(govobj.IsSetCachedValid() &&
(nProp == uint256() || h == nProp) &&
govobj.IsValidLocally(pCurrentBlockIndex, strError, true)) {
bool fIsValid = govobj.IsValidLocally(pCurrentBlockIndex, strError, true);
if(!fIsValid) {
LogPrintf("CGovernanceManager::Sync -- not syncing invalid govobj: %s, strError = %s, fCachedValid = %d, peer=%d\n",
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;
@ -649,7 +673,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
++nInvCount;
}
}
}
fRateChecksEnabled = true;
}
pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, nInvCount);

View File

@ -15,6 +15,7 @@
#include "streams.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include <deque>
#include <stdint.h>
@ -510,8 +511,11 @@ public:
{
{
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;
}
LogPrint("net", "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
vInventoryToSend.push_back(inv);
}
}