From 04fc6e1fb4f87ed500d3d150ddf30a117f93f50c Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Sat, 25 Jul 2015 20:17:53 -0700 Subject: [PATCH] Change rest of sync process to direct inv messages / reduced sync timeout --- src/masternode-budget.cpp | 11 +++++++---- src/masternode-payments.cpp | 4 +++- src/masternode-sync.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index b6faeb702..7016f1fa9 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -947,19 +947,21 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) */ + vector vInv; + std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); while(it1 != mapSeenMasternodeBudgetProposals.end()){ CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); if(pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)){ CInv inv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash()); - pfrom->PushInventory(inv); + vInv.push_back(inv); //send votes std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); while(it2 != pbudgetProposal->mapVotes.end()){ if((*it2).second.fValid){ CInv inv(MSG_BUDGET_VOTE, (*it2).second.GetHash()); - pfrom->PushInventory(inv); + vInv.push_back(inv); } ++it2; } @@ -972,14 +974,14 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); if(pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)){ CInv inv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash()); - pfrom->PushInventory(inv); + vInv.push_back(inv); //send votes std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); while(it4 != pfinalizedBudget->mapVotes.end()){ if((*it4).second.fValid) { CInv inv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash()); - pfrom->PushInventory(inv); + vInv.push_back(inv); } ++it4; } @@ -987,6 +989,7 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) ++it3; } + if(vInv.size() > 0) pfrom->PushMessage("inv", vInv); } bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index ce0c62960..30d0f1dcf 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -758,15 +758,17 @@ void CMasternodePayments::Sync(CNode* node, int nCountNeeded) int nCount = (mnodeman.CountEnabled()*2); if(nCountNeeded > nCount) nCountNeeded = nCount; + vector vInv; std::map::iterator it = mapMasternodePayeeVotes.begin(); while(it != mapMasternodePayeeVotes.end()) { CMasternodePaymentWinner winner = (*it).second; if(winner.nBlockHeight >= chainActive.Tip()->nHeight-nCountNeeded && winner.nBlockHeight <= chainActive.Tip()->nHeight + 20) { CInv inv(MSG_MASTERNODE_WINNER, winner.GetHash()); - node->PushInventory(inv); + vInv.push_back(inv); } ++it; } + if(vInv.size() > 0) node->PushMessage("inv", vInv); } std::string CMasternodePayments::ToString() const diff --git a/src/masternode-sync.h b/src/masternode-sync.h index 0326a14d4..96f199186 100644 --- a/src/masternode-sync.h +++ b/src/masternode-sync.h @@ -13,7 +13,7 @@ #define MASTERNODE_SYNC_FAILED 998 #define MASTERNODE_SYNC_FINISHED 999 -#define MASTERNODE_SYNC_TIMEOUT 15 +#define MASTERNODE_SYNC_TIMEOUT 7 class CMasternodeSync; extern CMasternodeSync masternodeSync;