Smarter nHeight detection for masternode payments

This commit is contained in:
Evan Duffield 2015-07-03 22:05:10 -07:00
parent 6becaf0462
commit 42d9a581a1
3 changed files with 20 additions and 7 deletions

View File

@ -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()");
}
}
// -------------------------------------------

View File

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

View File

@ -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);
}
};
//