more checks for IsValidBlockHeight()

This commit is contained in:
UdjinM6 2016-08-21 06:28:32 +03:00
parent f7b6234cc2
commit ade8f64163
2 changed files with 12 additions and 7 deletions

View File

@ -350,6 +350,10 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)
bool CSuperblockManager::GetBestSuperblock(CSuperblock_sptr& pBlock, int nBlockHeight)
{
if(!CSuperblock::IsValidBlockHeight(nBlockHeight)) {
return false;
}
AssertLockHeld(governance.cs);
std::vector<CSuperblock_sptr> vecTriggers = triggerman.GetActiveTriggers();
int nYesCount = 0;
@ -633,6 +637,10 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
// internal to *this and since CSuperblock's are accessed only through
// shared pointers there's no way our object can get deleted while this
// code is running.
if(!IsValidBlockHeight(nBlockHeight)) {
LogPrintf("CSuperblock::IsValid -- ERROR: Block invalid, incorrect block height\n");
return false;
}
std::string strPayeesPossible = "";

View File

@ -185,9 +185,9 @@ bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount bloc
void FillBlockPayee(CMutableTransaction& txNew, CAmount blockReward, int nBlockHeight)
{
// only create superblocks after hardfork block AND if spork is enabled AND if superblock is actually triggered
if(nBlockHeight > Params().GetConsensus().nSuperblockStartBlock &&
sporkManager.IsSporkActive(SPORK_9_MASTERNODE_SUPERBLOCK_ENFORCEMENT) &&
// only create superblocks if spork is enabled AND if superblock is actually triggered
// (height should be validated inside)
if(sporkManager.IsSporkActive(SPORK_9_MASTERNODE_SUPERBLOCK_ENFORCEMENT) &&
CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) {
LogPrint("gobject", "FillBlockPayee -- triggered superblock creation at height %d\n", nBlockHeight);
CSuperblockManager::CreateSuperblock(txNew, nBlockHeight);
@ -200,15 +200,12 @@ void FillBlockPayee(CMutableTransaction& txNew, CAmount blockReward, int nBlockH
std::string GetRequiredPaymentsString(int nBlockHeight)
{
// IF THIS HEIGHT IS A SUPERBLOCK, GET THE REQUIRED PAYEES
// IF WE HAVE A ACTIVATED TRIGGER FOR THIS HEIGHT - IT IS A SUPERBLOCK, GET THE REQUIRED PAYEES
if(CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) {
// IF WE HAVE A ACTIVATED TRIGGER
return CSuperblockManager::GetRequiredPaymentsString(nBlockHeight);
}
// OTHERWISE, PAY MASTERNODE
return mnpayments.GetRequiredPaymentsString(nBlockHeight);
}