test
This commit is contained in:
17
src/komodo.h
17
src/komodo.h
@@ -522,10 +522,23 @@ int32_t komodo_heightnotary(int32_t height,uint8_t *pubkey33)
|
|||||||
// -1 if not notary, 0 if notary, 1 if special notary
|
// -1 if not notary, 0 if notary, 1 if special notary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_block2height(CBlock *block)
|
||||||
|
{
|
||||||
|
int32_t i,height = 0; uint8_t *ptr = (uint8_t *)block->vin[0].scriptSig.data();
|
||||||
|
if ( block->vin[0].scriptSig.size() > 5 )
|
||||||
|
{
|
||||||
|
for (i=0; i<6; i++)
|
||||||
|
printf("%02x",ptr[i]);
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
height = (height << 8) + ptr[i+2];
|
||||||
|
printf(" <- coinbase ht.%d\n",height);
|
||||||
|
}
|
||||||
|
return(height);
|
||||||
|
}
|
||||||
|
|
||||||
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
||||||
{
|
{
|
||||||
uint8_t *ptr;
|
uint8_t *ptr = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data();
|
||||||
ptr = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data();
|
|
||||||
memcpy(pubkey33,ptr+1,33);
|
memcpy(pubkey33,ptr+1,33);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@@ -2037,7 +2037,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
// Check it again in case a previous version let a bad block in
|
// Check it again in case a previous version let a bad block in
|
||||||
if (!CheckBlock(block, state, !fJustCheck, !fJustCheck))
|
if (!CheckBlock(pindex->nHeight,block, state, !fJustCheck, !fJustCheck))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// verify that the view's current state corresponds to the previous block
|
// verify that the view's current state corresponds to the previous block
|
||||||
@@ -2967,7 +2967,7 @@ bool CheckBlockHeader(int32_t height,const CBlock& block, const CBlockHeader& bl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot)
|
bool CheckBlock(int32_t height,const CBlock& block, CValidationState& state, bool fCheckPOW, bool fCheckMerkleRoot)
|
||||||
{
|
{
|
||||||
// These are checks that are independent of context.
|
// These are checks that are independent of context.
|
||||||
|
|
||||||
@@ -3187,7 +3187,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
|
|||||||
if (fTooFarAhead) return true; // Block height is too high
|
if (fTooFarAhead) return true; // Block height is too high
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!CheckBlock(block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
|
if ((!CheckBlock(pindex->nHeight,block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
|
||||||
if (state.IsInvalid() && !state.CorruptionPossible()) {
|
if (state.IsInvalid() && !state.CorruptionPossible()) {
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
setDirtyBlockIndex.insert(pindex);
|
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)
|
bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
|
||||||
{
|
{
|
||||||
// Preliminary checks
|
// Preliminary checks
|
||||||
bool checked = CheckBlock(*pblock, state);
|
bool checked = CheckBlock(komodo_block2height(pblock),*pblock, state);
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
@@ -3276,7 +3276,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
// NOTE: CheckBlockHeader is called by CheckBlock
|
// NOTE: CheckBlockHeader is called by CheckBlock
|
||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
return false;
|
return false;
|
||||||
if (!CheckBlock(block, state, fCheckPOW, fCheckMerkleRoot))
|
if (!CheckBlock(indexDummy.nHeight,block, state, fCheckPOW, fCheckMerkleRoot))
|
||||||
return false;
|
return false;
|
||||||
if (!ContextualCheckBlock(block, state, pindexPrev))
|
if (!ContextualCheckBlock(block, state, pindexPrev))
|
||||||
return false;
|
return false;
|
||||||
@@ -3608,7 +3608,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||||||
if (!ReadBlockFromDisk(block, pindex))
|
if (!ReadBlockFromDisk(block, pindex))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 1: verify block validity
|
// check level 1: verify block validity
|
||||||
if (nCheckLevel >= 1 && !CheckBlock(block, state))
|
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,block, state))
|
||||||
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 2: verify undo validity
|
// check level 2: verify undo validity
|
||||||
if (nCheckLevel >= 2 && pindex) {
|
if (nCheckLevel >= 2 && pindex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user