mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Smarter nHeight detection for masternode payments
This commit is contained in:
parent
6becaf0462
commit
42d9a581a1
18
src/main.cpp
18
src/main.cpp
@ -2938,10 +2938,26 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
if(pindexPrev != NULL)
|
||||
{
|
||||
if(!IsBlockPayeeValid(block.vtx[0], pindexPrev->nHeight+1))
|
||||
int nHeight = 0;
|
||||
if(pindexPrev->GetBlockHash() == block.hashPrevBlock)
|
||||
{
|
||||
nHeight = pindexPrev->nHeight+1;
|
||||
} else { //out of order
|
||||
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex){
|
||||
if(item.first == block.hashPrevBlock) {
|
||||
nHeight = item.second->nHeight+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(nHeight != 0){
|
||||
if(!IsBlockPayeeValid(block.vtx[0], nHeight))
|
||||
{
|
||||
return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
|
||||
}
|
||||
} else {
|
||||
LogPrintf("CheckBlock() : WARNING: Couldn't find previous block, skipping IsBlockPayeeValid()");
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------
|
||||
|
@ -510,7 +510,7 @@ std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
|
||||
CBudgetProposal* prop = &((*it2).second);
|
||||
|
||||
//prop start/end should be inside this period
|
||||
if(prop->nBlockStart <= nBlockStart && prop->nBlockEnd >= nBlockEnd)
|
||||
if(prop->nBlockStart <= nBlockStart && prop->nBlockEnd >= nBlockEnd && prop->GetYeas() > 10)
|
||||
{
|
||||
if(nTotalBudget == nBudgetAllocated){
|
||||
prop->SetAllotted(0);
|
||||
|
@ -98,7 +98,6 @@ public:
|
||||
CFinalizedBudget *FindFinalizedBudget(uint256 nHash);
|
||||
std::pair<std::string, std::string> GetVotes(std::string strProposalName);
|
||||
|
||||
|
||||
void CleanUp();
|
||||
|
||||
int64_t GetTotalBudget(int nHeight);
|
||||
@ -325,8 +324,6 @@ public:
|
||||
READWRITE(vchSig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user