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 = "";
|
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);
|
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,
|
// 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
|
// 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)) {
|
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
|
// 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");
|
LogPrint("gobject", "IsBlockValueValid -- Client synced but budget spork is disabled, checking block value against block reward\n");
|
||||||
if(!isNormalBlockValueMet) {
|
if(!isBlockRewardValueMet) {
|
||||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, budgets are disabled",
|
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);
|
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||||
}
|
}
|
||||||
return isNormalBlockValueMet;
|
return isBlockRewardValueMet;
|
||||||
}
|
}
|
||||||
LogPrint("gobject", "IsBlockValueValid -- WARNING: Skipping budget block value checks, accepting block\n");
|
LogPrint("gobject", "IsBlockValueValid -- WARNING: Skipping budget block value checks, accepting block\n");
|
||||||
// TODO: reprocess blocks to make sure they are legit?
|
// TODO: reprocess blocks to make sure they are legit?
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// LogPrint("gobject", "IsBlockValueValid -- Block is not in budget cycle window, checking block value against normal block reward\n");
|
// LogPrint("gobject", "IsBlockValueValid -- Block is not in budget cycle window, checking block value against block reward\n");
|
||||||
if(!isNormalBlockValueMet) {
|
if(!isBlockRewardValueMet) {
|
||||||
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",
|
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);
|
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||||
}
|
}
|
||||||
return isNormalBlockValueMet;
|
return isBlockRewardValueMet;
|
||||||
}
|
}
|
||||||
|
|
||||||
// superblocks started
|
// superblocks started
|
||||||
|
|
||||||
CAmount nSuperblockPaymentsLimit = CSuperblock::GetPaymentsLimit(nBlockHeight);
|
CAmount nSuperblockMaxValue = blockReward + CSuperblock::GetPaymentsLimit(nBlockHeight);
|
||||||
bool isSuperblockMaxValueMet = (block.vtx[0].GetValueOut() <= blockReward + nSuperblockPaymentsLimit);
|
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()) {
|
if(!masternodeSync.IsSynced()) {
|
||||||
// not enough data but at least it must NOT exceed superblock max value
|
// not enough data but at least it must NOT exceed superblock max value
|
||||||
if(CSuperblock::IsValidBlockHeight(nBlockHeight)) {
|
if(CSuperblock::IsValidBlockHeight(nBlockHeight)) {
|
||||||
if(fDebug) LogPrintf("IsBlockPayeeValid -- WARNING: Client not synced, checking superblock max bounds only\n");
|
if(fDebug) LogPrintf("IsBlockPayeeValid -- WARNING: Client not synced, checking superblock max bounds only\n");
|
||||||
if(!isSuperblockMaxValueMet) {
|
if(!isSuperblockMaxValueMet) {
|
||||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded superblock payment limit",
|
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded superblock max value",
|
||||||
nBlockHeight, block.vtx[0].GetValueOut(), nSuperblockPaymentsLimit);
|
nBlockHeight, block.vtx[0].GetValueOut(), nSuperblockMaxValue);
|
||||||
}
|
}
|
||||||
return isSuperblockMaxValueMet;
|
return isSuperblockMaxValueMet;
|
||||||
}
|
}
|
||||||
if(!isNormalBlockValueMet) {
|
if(!isBlockRewardValueMet) {
|
||||||
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",
|
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);
|
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||||
}
|
}
|
||||||
// it MUST be a regular block otherwise
|
// 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
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
LogPrint("gobject", "IsBlockValueValid -- No triggered superblock detected at height %d\n", nBlockHeight);
|
LogPrint("gobject", "IsBlockValueValid -- No triggered superblock detected at height %d\n", nBlockHeight);
|
||||||
if(!isNormalBlockValueMet) {
|
if(!isBlockRewardValueMet) {
|
||||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, no triggered superblock detected",
|
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);
|
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// should NOT allow superblocks at all, when superblocks are disabled
|
// should NOT allow superblocks at all, when superblocks are disabled
|
||||||
LogPrint("gobject", "IsBlockValueValid -- Superblocks are disabled, no superblocks allowed\n");
|
LogPrint("gobject", "IsBlockValueValid -- Superblocks are disabled, no superblocks allowed\n");
|
||||||
if(!isNormalBlockValueMet) {
|
if(!isBlockRewardValueMet) {
|
||||||
strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded normal block payment limit, superblocks are disabled",
|
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);
|
nBlockHeight, block.vtx[0].GetValueOut(), blockReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// it MUST be a regular block
|
// it MUST be a regular block
|
||||||
return isNormalBlockValueMet;
|
return isBlockRewardValueMet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
|
bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
|
||||||
|
Loading…
Reference in New Issue
Block a user