Skip to content

Commit

Permalink
[Budget] Guard against chainactive tip clash
Browse files Browse the repository at this point in the history
  • Loading branch information
Warrows committed Apr 26, 2019
1 parent 3601d00 commit 6e48490
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,12 @@ std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
std::vector<CBudgetProposal*> vBudgetProposalsRet;

CAmount nBudgetAllocated = 0;
CBlockIndex* pindexPrev = chainActive.Tip();

CBlockIndex* pindexPrev;
{
LOCK(cs_main);
pindexPrev = chainActive.Tip();
}
if (pindexPrev == NULL) return vBudgetProposalsRet;

int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % Params().GetBudgetCycleBlocks() + Params().GetBudgetCycleBlocks();
Expand Down
6 changes: 5 additions & 1 deletion src/qt/governancepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ void GovernancePage::updateProposalList()
std::vector<CBudgetProposal*> proposalsList = budget.GetAllProposals();
std::sort (proposalsList.begin(), proposalsList.end(), sortProposalsByVotes());
int nRow = 0;
CBlockIndex* pindexPrev = chainActive.Tip();
CBlockIndex* pindexPrev;
{
LOCK(cs_main);
pindexPrev = chainActive.Tip();
}
if (!pindexPrev) return;
int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % Params().GetBudgetCycleBlocks() + Params().GetBudgetCycleBlocks();
int nBlocksLeft = nBlockStart - pindexPrev->nHeight;
Expand Down

0 comments on commit 6e48490

Please sign in to comment.