From 231532d6d06bf7e539e44a2dff53d815c9e9164c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 29 Sep 2016 00:03:54 +0400 Subject: [PATCH] Align governance proto logic with logic for similar proto for other modules (#1049) i.e MSG_GOVERNANCE_PEER_PROTO_VERSION -> MIN_GOVERNANCE_PEER_PROTO_VERSION (to check other peers) + PROTOCOL_VERSION (to announce own version) --- src/governance-vote.cpp | 2 +- src/governance.cpp | 12 +++--------- src/governance.h | 1 + src/masternode-sync.cpp | 2 +- src/version.h | 3 --- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/governance-vote.cpp b/src/governance-vote.cpp index 7f5d7108da..6873561947 100644 --- a/src/governance-vote.cpp +++ b/src/governance-vote.cpp @@ -236,7 +236,7 @@ CGovernanceVote::CGovernanceVote(CTxIn vinMasternodeIn, uint256 nParentHashIn, v void CGovernanceVote::Relay() { CInv inv(MSG_GOVERNANCE_OBJECT_VOTE, GetHash()); - RelayInv(inv, MSG_GOVERNANCE_PEER_PROTO_VERSION); + RelayInv(inv, PROTOCOL_VERSION); } bool CGovernanceVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) diff --git a/src/governance.cpp b/src/governance.cpp index 92fb029aa2..d0d4f9d616 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -89,13 +89,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C if(fLiteMode) return; if(!masternodeSync.IsBlockchainSynced()) return; - // - // REMOVE AFTER MIGRATION TO 12.1 - // - if(pfrom->nVersion < 70201) return; - // - // END REMOVE - // + if(pfrom->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) return; LOCK(governance.cs); @@ -864,7 +858,7 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s // IF ABSOLUTE NO COUNT (NO-YES VALID VOTES) IS MORE THAN 10% OF THE NETWORK MASTERNODES, OBJ IS INVALID - if(GetAbsoluteNoCount(VOTE_SIGNAL_VALID) > mnodeman.CountEnabled(MSG_GOVERNANCE_PEER_PROTO_VERSION)/10) { + if(GetAbsoluteNoCount(VOTE_SIGNAL_VALID) > mnodeman.CountEnabled(MIN_GOVERNANCE_PEER_PROTO_VERSION)/10) { strError = "Automated removal"; return false; } @@ -1073,7 +1067,7 @@ int CGovernanceObject::GetAbstainCount(vote_signal_enum_t eVoteSignalIn) void CGovernanceObject::Relay() { CInv inv(MSG_GOVERNANCE_OBJECT, GetHash()); - RelayInv(inv, MSG_GOVERNANCE_PEER_PROTO_VERSION); + RelayInv(inv, PROTOCOL_VERSION); } std::string CGovernanceManager::ToString() const diff --git a/src/governance.h b/src/governance.h index f7b56955f2..098d0958b5 100644 --- a/src/governance.h +++ b/src/governance.h @@ -30,6 +30,7 @@ class CGovernanceObject; class CGovernanceVote; static const int MAX_GOVERNANCE_OBJECT_DATA_SIZE = 16 * 1024; +static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70201; static const int GOVERNANCE_OBJECT_UNKNOWN = 0; static const int GOVERNANCE_OBJECT_PROPOSAL = 1; diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 732b11289b..9b85700d39 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -365,7 +365,7 @@ void CMasternodeSync::ProcessTick() if(netfulfilledman.HasFulfilledRequest(pnode->addr, "governance-sync")) continue; netfulfilledman.AddFulfilledRequest(pnode->addr, "governance-sync"); - if (pnode->nVersion < MSG_GOVERNANCE_PEER_PROTO_VERSION) continue; + if (pnode->nVersion < MIN_GOVERNANCE_PEER_PROTO_VERSION) continue; nRequestedMasternodeAttempt++; pnode->PushMessage(NetMsgType::MNGOVERNANCESYNC, uint256()); //sync masternode votes diff --git a/src/version.h b/src/version.h index 63585fe2d8..585cb4b215 100644 --- a/src/version.h +++ b/src/version.h @@ -21,9 +21,6 @@ static const int GETHEADERS_VERSION = 70077; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION = 70103; -//! minimum peer version for masternode budgets -static const int MSG_GOVERNANCE_PEER_PROTO_VERSION = 70201; - //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this static const int CADDR_TIME_VERSION = 31402;