Fixed HaveBudget, allow failure after 3 tries

This commit is contained in:
Evan Duffield 2015-07-28 13:14:32 -07:00
parent a069a5df5e
commit 8acfd77750
3 changed files with 6 additions and 2 deletions

View File

@ -516,10 +516,12 @@ bool CBudgetManager::HasNextFinalizedBudget()
if(!pindexPrev) return false;
int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
if(nBlockStart - pindexPrev->nHeight > 576*2) return false; //we wouldn't have the budget yet
if(nBlockStart - pindexPrev->nHeight > 576*2) return true; //we wouldn't have the budget yet
if(budget.IsBudgetPaymentBlock(nBlockStart)) return true;
LogPrintf("CBudgetManager::HasNextFinalizedBudget() - Client is missing budget\n");
return false;
}

View File

@ -199,13 +199,14 @@ void CMasternodeSync::Process()
if(RequestedMasternodeAssets == MASTERNODE_SYNC_BUDGET){
//we'll start rejecting votes if we accidentally get set as synced too soon
if(lastBudgetItem > 0 && lastBudgetItem < GetTime() - MASTERNODE_SYNC_TIMEOUT*3 && RequestedMasternodeAttempt >= 4){ //hasn't received a new item in the last five seconds, so we'll move to the
if(budget.HasNextFinalizedBudget()) {
if(budget.HasNextFinalizedBudget() || nCountFailures >= 2) {
GetNextAsset();
} else { //we've failed to sync, this state will reject the next budget block
LogPrintf("CMasternodeSync::Process - ERROR - Sync has failed, will retry later\n");
RequestedMasternodeAssets = MASTERNODE_SYNC_FAILED;
RequestedMasternodeAttempt = 0;
lastFailure = GetTime();
nCountFailures++;
}
return;
}

View File

@ -29,6 +29,7 @@ public:
int64_t lastMasternodeWinner;
int64_t lastBudgetItem;
int64_t lastFailure;
int64_t nCountFailures;
// Count peers we've requested the list from
int RequestedMasternodeAssets;