This commit is contained in:
jl777
2016-10-20 07:33:44 -03:00
parent 6830264a00
commit 9ebb63d751
2 changed files with 9 additions and 5 deletions

View File

@@ -122,7 +122,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
fprintf(stderr," height.%d special.%d\n",height,special);
if ( special < 0 )
bnTarget /= 8;
else bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
else
{
if (UintToArith256(hash) <= bnTarget) // accept normal diff
return true;
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
}
}
// Check range
@@ -131,8 +136,9 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
// Check proof of work matches claimed amount
if (UintToArith256(hash) > bnTarget)
{
return error("CheckProofOfWork(): hash doesn't match nBits");
}
return true;
}

View File

@@ -266,8 +266,6 @@ bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) {
return true;
}
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp);
bool CBlockTreeDB::LoadBlockIndexGuts()
{
boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());
@@ -308,7 +306,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
pindexNew->nTx = diskindex.nTx;
uint8_t pubkey33[33];
komodo_index2pubkey33(pubkey33,pindexNew);
if (!CheckProofOfWork(pindexNew->height,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
pcursor->Next();
} else {