This commit is contained in:
jl777
2016-10-20 09:21:38 -03:00
parent 9499e4decc
commit eea133f1f3

View File

@@ -2037,7 +2037,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
const CChainParams& chainparams = Params();
AssertLockHeld(cs_main);
// Check it again in case a previous version let a bad block in
if (!CheckBlock(pindex->nHeight,block, state, !fJustCheck, !fJustCheck))
if (!CheckBlock(pindex->nHeight,pindex,block, state, !fJustCheck, !fJustCheck))
return false;
// verify that the view's current state corresponds to the previous block
@@ -2950,7 +2950,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
return true;
}
bool CheckBlockHeader(CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
{
uint8_t pubkey33[33];
// Check timestamp
@@ -2962,18 +2962,18 @@ bool CheckBlockHeader(CBlockIndex *pindex, const CBlockHeader& blockhdr, CValida
// Check proof of work matches claimed amount
komodo_index2pubkey33(pubkey33,pindex);
if ( fCheckPOW && !CheckProofOfWork(pindex!=0?pindex->nHeight:0,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
if ( fCheckPOW && !CheckProofOfWork(height:0,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
return true;
}
bool CheckBlock(int32_t height,const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot)
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot)
{
// These are checks that are independent of context.
// Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(height, block, state, fCheckPOW))
if (!CheckBlockHeader(height, pindex,block, state, fCheckPOW))
return false;
// Check the merkle root.
@@ -3130,7 +3130,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
return true;
}
if (!CheckBlockHeader(*ppindex, block, state))
if (!CheckBlockHeader((*ppindex)->nHeight,*ppindex, block, state))
return false;
// Get prev block index
@@ -3187,7 +3187,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
if (fTooFarAhead) return true; // Block height is too high
}
if ((!CheckBlock(pindex->nHeight,block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
if ((!CheckBlock(pindex->nHeight,pindex,block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
if (state.IsInvalid() && !state.CorruptionPossible()) {
pindex->nStatus |= BLOCK_FAILED_VALID;
setDirtyBlockIndex.insert(pindex);
@@ -3236,7 +3236,7 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
{
// Preliminary checks
bool checked = CheckBlock(komodo_block2height(pblock),*pblock, state);
bool checked = CheckBlock(komodo_block2height(pblock),0,*pblock, state);
{
LOCK(cs_main);
@@ -3276,7 +3276,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
// NOTE: CheckBlockHeader is called by CheckBlock
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
return false;
if (!CheckBlock(indexDummy.nHeight,block, state, fCheckPOW, fCheckMerkleRoot))
if (!CheckBlock(indexDummy.nHeight,0,block, state, fCheckPOW, fCheckMerkleRoot))
return false;
if (!ContextualCheckBlock(block, state, pindexPrev))
return false;
@@ -3608,7 +3608,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
if (!ReadBlockFromDisk(block, pindex))
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 1: verify block validity
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,block, state))
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,pindex,block, state))
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 2: verify undo validity
if (nCheckLevel >= 2 && pindex) {