test
This commit is contained in:
@@ -545,7 +545,8 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
|||||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex)
|
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 )
|
memset(pubkey,0,33);
|
||||||
|
if ( pindex != 0 && ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 )
|
||||||
komodo_block2pubkey33(pubkey33,block);
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/main.cpp
10
src/main.cpp
@@ -2950,7 +2950,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBlockHeader(int32_t height,const CBlock& block, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
|
bool CheckBlockHeader(CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
|
||||||
{
|
{
|
||||||
uint8_t pubkey33[33];
|
uint8_t pubkey33[33];
|
||||||
// Check timestamp
|
// Check timestamp
|
||||||
@@ -2961,8 +2961,8 @@ bool CheckBlockHeader(int32_t height,const CBlock& block, const CBlockHeader& bl
|
|||||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
komodo_block2pubkey33(pubkey33,*(CBlock *)&block);
|
komodo_blockindex2pubkey33(pubkey33,pindex);
|
||||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
|
if ( fCheckPOW && !CheckProofOfWork(pindex!=0?pindex->height:0,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
|
||||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2973,7 +2973,7 @@ bool CheckBlock(int32_t height,const CBlock& block, CValidationState& state, boo
|
|||||||
|
|
||||||
// Check that the header is valid (particularly PoW). This is mostly
|
// Check that the header is valid (particularly PoW). This is mostly
|
||||||
// redundant with the call in AcceptBlockHeader.
|
// redundant with the call in AcceptBlockHeader.
|
||||||
if (!CheckBlockHeader(height,block, block, state, fCheckPOW))
|
if (!CheckBlockHeader(height, block, state, fCheckPOW))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check the merkle root.
|
// Check the merkle root.
|
||||||
@@ -3130,7 +3130,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckBlockHeader(*ppindex!=0?(*ppindex)->nHeight:0,block, block, state))
|
if (!CheckBlockHeader(*ppindex, block, state))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Get prev block index
|
// Get prev block index
|
||||||
|
|||||||
Reference in New Issue
Block a user