From 84c242fc8c2037f1d94fb32e72360a56f6b08409 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Thu, 15 Dec 2016 11:27:09 -0500 Subject: [PATCH] Restore relaying and fix rate threshold (#1206) * Restore object relaying during orphan processing * Relay votes during orphan processing * Allow relaying of objects and votes during syncing * Double rate check threshold --- src/governance-object.cpp | 2 +- src/governance-vote.cpp | 1 - src/governance.cpp | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/governance-object.cpp b/src/governance-object.cpp index 4bd3d022f..84a331a83 100644 --- a/src/governance-object.cpp +++ b/src/governance-object.cpp @@ -644,7 +644,6 @@ bool CGovernanceObject::GetCurrentMNVotes(const CTxIn& mnCollateralOutpoint, vot void CGovernanceObject::Relay() { - if(!masternodeSync.IsSynced()) return; CInv inv(MSG_GOVERNANCE_OBJECT, GetHash()); RelayInv(inv, PROTOCOL_VERSION); } @@ -732,6 +731,7 @@ void CGovernanceObject::CheckOrphanVotes() LogPrintf("CGovernanceObject::CheckOrphanVotes -- Failed to add orphan vote: %s\n", exception.what()); } else { + vote.Relay(); fRemove = true; } ++it; diff --git a/src/governance-vote.cpp b/src/governance-vote.cpp index d23bad6ca..80286d512 100644 --- a/src/governance-vote.cpp +++ b/src/governance-vote.cpp @@ -235,7 +235,6 @@ CGovernanceVote::CGovernanceVote(CTxIn vinMasternodeIn, uint256 nParentHashIn, v void CGovernanceVote::Relay() const { - if(!masternodeSync.IsSynced()) return; CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash()); RelayInv(inv, PROTOCOL_VERSION); } diff --git a/src/governance.cpp b/src/governance.cpp index 0d9ba9560..2676b75d6 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -280,6 +280,7 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, CGovernance fRemove = true; } else if(govobj.ProcessVote(NULL, vote, exception)) { + vote.Relay(); fRemove = true; } if(fRemove) { @@ -785,7 +786,7 @@ bool CGovernanceManager::MasternodeRateCheck(const CGovernanceObject& govobj, bo switch(nObjectType) { case GOVERNANCE_OBJECT_TRIGGER: // Allow 1 trigger per mn per cycle, with a small fudge factor - dMaxRate = 1.1 / nSuperblockCycleSeconds; + dMaxRate = 2 * 1.1 / double(nSuperblockCycleSeconds); buffer = it->second.triggerBuffer; buffer.AddTimestamp(nTimestamp); dRate = buffer.GetRate(); @@ -794,7 +795,7 @@ bool CGovernanceManager::MasternodeRateCheck(const CGovernanceObject& govobj, bo } break; case GOVERNANCE_OBJECT_WATCHDOG: - dMaxRate = 1.1 / 3600.; + dMaxRate = 2 * 1.1 / 3600.; buffer = it->second.watchdogBuffer; buffer.AddTimestamp(nTimestamp); dRate = buffer.GetRate(); @@ -907,6 +908,7 @@ void CGovernanceManager::CheckMasternodeOrphanObjects() if(AddGovernanceObject(govobj)) { LogPrintf("CGovernanceManager::CheckMasternodeOrphanObjects -- %s new\n", govobj.GetHash().ToString()); + govobj.Relay(); mapMasternodeOrphanObjects.erase(it++); } else {