mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
Fixed HaveBudget, allow failure after 3 tries
This commit is contained in:
parent
a069a5df5e
commit
8acfd77750
@ -516,10 +516,12 @@ bool CBudgetManager::HasNextFinalizedBudget()
|
|||||||
if(!pindexPrev) return false;
|
if(!pindexPrev) return false;
|
||||||
|
|
||||||
int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
|
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;
|
if(budget.IsBudgetPaymentBlock(nBlockStart)) return true;
|
||||||
|
|
||||||
|
LogPrintf("CBudgetManager::HasNextFinalizedBudget() - Client is missing budget\n");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,13 +199,14 @@ void CMasternodeSync::Process()
|
|||||||
if(RequestedMasternodeAssets == MASTERNODE_SYNC_BUDGET){
|
if(RequestedMasternodeAssets == MASTERNODE_SYNC_BUDGET){
|
||||||
//we'll start rejecting votes if we accidentally get set as synced too soon
|
//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(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();
|
GetNextAsset();
|
||||||
} else { //we've failed to sync, this state will reject the next budget block
|
} 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");
|
LogPrintf("CMasternodeSync::Process - ERROR - Sync has failed, will retry later\n");
|
||||||
RequestedMasternodeAssets = MASTERNODE_SYNC_FAILED;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_FAILED;
|
||||||
RequestedMasternodeAttempt = 0;
|
RequestedMasternodeAttempt = 0;
|
||||||
lastFailure = GetTime();
|
lastFailure = GetTime();
|
||||||
|
nCountFailures++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
int64_t lastMasternodeWinner;
|
int64_t lastMasternodeWinner;
|
||||||
int64_t lastBudgetItem;
|
int64_t lastBudgetItem;
|
||||||
int64_t lastFailure;
|
int64_t lastFailure;
|
||||||
|
int64_t nCountFailures;
|
||||||
|
|
||||||
// Count peers we've requested the list from
|
// Count peers we've requested the list from
|
||||||
int RequestedMasternodeAssets;
|
int RequestedMasternodeAssets;
|
||||||
|
Loading…
Reference in New Issue
Block a user