adjust variable names and log messages in IsBlockValueValid (#1192)
This commit is contained in:
parent
15bb93d5e8
commit
cf57c5ca93
@ -37,7 +37,7 @@ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockRewar
|
||||
{
|
||||
strErrorRet = "";
|
||||
|
||||
bool isNormalBlockValueMet = (block.vtx[0].GetValueOut() <= blockReward);
|
||||
bool isBlockRewardValueMet = (block.vtx[0].GetValueOut() <= blockReward);
|
||||
if(fDebug) LogPrintf("block.vtx[0].GetValueOut() %lld <= blockReward %lld\n", block.vtx[0].GetValueOut(), blockReward);
|
||||
|
||||
// we are still using budgets, but we have no data about them anymore,
|
||||
@ -52,48 +52,48 @@ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockRewar
|
||||
// NOTE: make sure SPORK_13_OLD_SUPERBLOCK_FLAG is disabled when 12.1 starts to go live
|
||||
if(masternodeSync.IsSynced() && !sporkManager.IsSporkActive(SPORK_13_OLD_SUPERBLOCK_FLAG)) {
|
||||
// no budget blocks should be accepted here, if SPORK_13_OLD_SUPERBLOCK_FLAG is disabled
|
||||
LogPrint("gobject", "IsBlockValueValid -- Client synced but budget spork is disabled, checking block value against normal block reward\n");
|
||||
if(!isNormalBlockValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, budgets are disabled",
|
||||
LogPrint("gobject", "IsBlockValueValid -- Client synced but budget spork is disabled, checking block value against block reward\n");
|
||||
if(!isBlockRewardValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, budgets are disabled",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||
}
|
||||
return isNormalBlockValueMet;
|
||||
return isBlockRewardValueMet;
|
||||
}
|
||||
LogPrint("gobject", "IsBlockValueValid -- WARNING: Skipping budget block value checks, accepting block\n");
|
||||
// TODO: reprocess blocks to make sure they are legit?
|
||||
return true;
|
||||
}
|
||||
// LogPrint("gobject", "IsBlockValueValid -- Block is not in budget cycle window, checking block value against normal block reward\n");
|
||||
if(!isNormalBlockValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, block is not in budget cycle window",
|
||||
// LogPrint("gobject", "IsBlockValueValid -- Block is not in budget cycle window, checking block value against block reward\n");
|
||||
if(!isBlockRewardValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, block is not in budget cycle window",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||
}
|
||||
return isNormalBlockValueMet;
|
||||
return isBlockRewardValueMet;
|
||||
}
|
||||
|
||||
// superblocks started
|
||||
|
||||
CAmount nSuperblockPaymentsLimit = CSuperblock::GetPaymentsLimit(nBlockHeight);
|
||||
bool isSuperblockMaxValueMet = (block.vtx[0].GetValueOut() <= blockReward + nSuperblockPaymentsLimit);
|
||||
CAmount nSuperblockMaxValue = blockReward + CSuperblock::GetPaymentsLimit(nBlockHeight);
|
||||
bool isSuperblockMaxValueMet = (block.vtx[0].GetValueOut() <= nSuperblockMaxValue);
|
||||
|
||||
LogPrint("gobject", "block.vtx[0].GetValueOut() %lld <= nSuperblockPaymentsLimit %lld\n", block.vtx[0].GetValueOut(), nSuperblockPaymentsLimit);
|
||||
LogPrint("gobject", "block.vtx[0].GetValueOut() %lld <= nSuperblockMaxValue %lld\n", block.vtx[0].GetValueOut(), nSuperblockMaxValue);
|
||||
|
||||
if(!masternodeSync.IsSynced()) {
|
||||
// not enough data but at least it must NOT exceed superblock max value
|
||||
if(CSuperblock::IsValidBlockHeight(nBlockHeight)) {
|
||||
if(fDebug) LogPrintf("IsBlockPayeeValid -- WARNING: Client not synced, checking superblock max bounds only\n");
|
||||
if(!isSuperblockMaxValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded superblock payment limit",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), nSuperblockPaymentsLimit);
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded superblock max value",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), nSuperblockMaxValue);
|
||||
}
|
||||
return isSuperblockMaxValueMet;
|
||||
}
|
||||
if(!isNormalBlockValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, only normal blocks are allowed at this height",
|
||||
if(!isBlockRewardValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, only regular blocks are allowed at this height",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||
}
|
||||
// it MUST be a regular block otherwise
|
||||
return isNormalBlockValueMet;
|
||||
return isBlockRewardValueMet;
|
||||
}
|
||||
|
||||
// we are synced, let's try to check as much data as we can
|
||||
@ -113,21 +113,21 @@ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockRewar
|
||||
return false;
|
||||
}
|
||||
LogPrint("gobject", "IsBlockValueValid -- No triggered superblock detected at height %d\n", nBlockHeight);
|
||||
if(!isNormalBlockValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, no triggered superblock detected",
|
||||
if(!isBlockRewardValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, no triggered superblock detected",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||
}
|
||||
} else {
|
||||
// should NOT allow superblocks at all, when superblocks are disabled
|
||||
LogPrint("gobject", "IsBlockValueValid -- Superblocks are disabled, no superblocks allowed\n");
|
||||
if(!isNormalBlockValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, superblocks are disabled",
|
||||
if(!isBlockRewardValueMet) {
|
||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, superblocks are disabled",
|
||||
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||
}
|
||||
}
|
||||
|
||||
// it MUST be a regular block
|
||||
return isNormalBlockValueMet;
|
||||
return isBlockRewardValueMet;
|
||||
}
|
||||
|
||||
bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
|
||||
|
Loading…
Reference in New Issue
Block a user