Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not send excessive messages in governance sync #2124

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions src/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, const std::string& strComm
}

if (nProp == uint256()) {
SyncAll(pfrom, connman);
SyncObjects(pfrom, connman);
} else {
SyncSingleObjAndItsVotes(pfrom, nProp, filter, connman);
SyncSingleObjVotes(pfrom, nProp, filter, connman);
}
LogPrint("gobject", "MNGOVERNANCESYNC -- syncing governance objects to our peer at %s\n", pfrom->addr.ToString());
}
Expand Down Expand Up @@ -647,7 +647,7 @@ bool CGovernanceManager::ConfirmInventoryRequest(const CInv& inv)
return true;
}

void CGovernanceManager::SyncSingleObjAndItsVotes(CNode* pnode, const uint256& nProp, const CBloomFilter& filter, CConnman& connman)
void CGovernanceManager::SyncSingleObjVotes(CNode* pnode, const uint256& nProp, const CBloomFilter& filter, CConnman& connman)
{
// do not provide any data until our node is synced
if (!masternodeSync.IsSynced()) return;
Expand Down Expand Up @@ -677,10 +677,6 @@ void CGovernanceManager::SyncSingleObjAndItsVotes(CNode* pnode, const uint256& n
return;
}

// Push the govobj inventory message over to the other client
LogPrint("gobject", "CGovernanceManager::%s -- syncing govobj: %s, peer=%d\n", __func__, strHash, pnode->id);
pnode->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, it->first));

auto fileVotes = govobj.GetVoteFile();

for (const auto& vote : fileVotes.GetVotes()) {
Expand All @@ -696,12 +692,11 @@ void CGovernanceManager::SyncSingleObjAndItsVotes(CNode* pnode, const uint256& n
}

CNetMsgMaker msgMaker(pnode->GetSendVersion());
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, 1));
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ_VOTE, nVoteCount));
LogPrintf("CGovernanceManager::%s -- sent 1 object and %d votes to peer=%d\n", __func__, nVoteCount, pnode->id);
LogPrintf("CGovernanceManager::%s -- sent %d votes to peer=%d\n", __func__, nVoteCount, pnode->id);
}

void CGovernanceManager::SyncAll(CNode* pnode, CConnman& connman) const
void CGovernanceManager::SyncObjects(CNode* pnode, CConnman& connman) const
{
// do not provide any data until our node is synced
if (!masternodeSync.IsSynced()) return;
Expand All @@ -716,7 +711,6 @@ void CGovernanceManager::SyncAll(CNode* pnode, CConnman& connman) const
netfulfilledman.AddFulfilledRequest(pnode->addr, NetMsgType::MNGOVERNANCESYNC);

int nObjCount = 0;
int nVoteCount = 0;

// SYNC GOVERNANCE OBJECTS WITH OTHER CLIENT

Expand Down Expand Up @@ -746,8 +740,7 @@ void CGovernanceManager::SyncAll(CNode* pnode, CConnman& connman) const

CNetMsgMaker msgMaker(pnode->GetSendVersion());
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, nObjCount));
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ_VOTE, nVoteCount));
LogPrintf("CGovernanceManager::%s -- sent %d objects and %d votes to peer=%d\n", __func__, nObjCount, nVoteCount, pnode->id);
LogPrintf("CGovernanceManager::%s -- sent %d objects to peer=%d\n", __func__, nObjCount, pnode->id);
}

void CGovernanceManager::MasternodeRateUpdate(const CGovernanceObject& govobj)
Expand Down
4 changes: 2 additions & 2 deletions src/governance.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ class CGovernanceManager
*/
bool ConfirmInventoryRequest(const CInv& inv);

void SyncSingleObjAndItsVotes(CNode* pnode, const uint256& nProp, const CBloomFilter& filter, CConnman& connman);
void SyncAll(CNode* pnode, CConnman& connman) const;
void SyncSingleObjVotes(CNode* pnode, const uint256& nProp, const CBloomFilter& filter, CConnman& connman);
void SyncObjects(CNode* pnode, CConnman& connman) const;

void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);

Expand Down