Change rest of sync process to direct inv messages / reduced sync timeout

This commit is contained in:
Evan Duffield 2015-07-25 20:17:53 -07:00
parent 61becf2f11
commit 04fc6e1fb4
3 changed files with 11 additions and 6 deletions

View File

@ -947,19 +947,21 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp)
*/
vector<CInv> vInv;
std::map<uint256, CBudgetProposalBroadcast>::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<uint256, CBudgetVote>::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<uint256, CFinalizedBudgetVote>::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)

View File

@ -758,15 +758,17 @@ void CMasternodePayments::Sync(CNode* node, int nCountNeeded)
int nCount = (mnodeman.CountEnabled()*2);
if(nCountNeeded > nCount) nCountNeeded = nCount;
vector<CInv> vInv;
std::map<uint256, CMasternodePaymentWinner>::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

View File

@ -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;