test
This commit is contained in:
11
src/komodo.h
11
src/komodo.h
@@ -520,12 +520,14 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
||||
|
||||
int32_t komodo_heightnotary(int32_t height,uint8_t *pubkey33)
|
||||
{
|
||||
int32_t i;
|
||||
// -1 if not notary, 0 if notary, 1 if special notary
|
||||
int32_t i,notaryid,modval = -1;
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" komodo_heightnotary.%d\n",height);
|
||||
if ( (notaryid= komodo_notaryfind(pubkey33)) >= 0 )
|
||||
modval = ((height % numnotaries) == notaryid);
|
||||
printf(" komodo_heightnotary.%d notaryid.%d mod.%d\n",height,notaryid,modval);
|
||||
return(0);
|
||||
// -1 if not notary, 0 if notary, 1 if special notary
|
||||
}
|
||||
|
||||
int32_t komodo_block2height(CBlock *block)
|
||||
@@ -560,7 +562,10 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 )
|
||||
{
|
||||
printf("from index2pubkey33\n");
|
||||
komodo_block2pubkey33(pubkey33,block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1351,6 +1351,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
|
||||
return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
|
||||
}
|
||||
// Check the header
|
||||
printf("from readblock\n");
|
||||
komodo_block2pubkey33(pubkey33,block);
|
||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||
@@ -2961,6 +2962,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
|
||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||
|
||||
// Check proof of work matches claimed amount
|
||||
printf("from checkblockheader\n");
|
||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
|
||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||
|
||||
@@ -307,6 +307,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
pindexNew->nStatus = diskindex.nStatus;
|
||||
pindexNew->nTx = diskindex.nTx;
|
||||
uint8_t pubkey33[33];
|
||||
printf("from txdb\n");
|
||||
komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->nHeight);
|
||||
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
|
||||
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
||||
|
||||
Reference in New Issue
Block a user