|
|
|
@ -15,23 +15,16 @@
@@ -15,23 +15,16 @@
|
|
|
|
|
extern "C" void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed, uint64_t height); |
|
|
|
|
extern "C" void cn_fast_hash(const void *data, size_t length, char *hash); |
|
|
|
|
|
|
|
|
|
uint256 CBlockHeader::GetHash() const |
|
|
|
|
uint256 CBlockHeader::GetOriginalBlockHash() const |
|
|
|
|
{ |
|
|
|
|
CHashWriter hashWriter(SER_GETHASH, PROTOCOL_VERSION); |
|
|
|
|
hashWriter.write(BEGIN(nVersion), 80); |
|
|
|
|
return hashWriter.GetHash(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint256 CBlockHeader::GetCryptonoteFastHash() const |
|
|
|
|
uint256 CBlockHeader::GetHash() const |
|
|
|
|
{ |
|
|
|
|
uint256 thash; |
|
|
|
|
// prev_id of CN header is used to store the kevacoin block hash.
|
|
|
|
|
// The value of prev_id and block hash must be the same to prove
|
|
|
|
|
// that PoW has been properly done.
|
|
|
|
|
if (GetHash() != cnHeader.prev_id) { |
|
|
|
|
memset(thash.begin(), 0xff, thash.size()); |
|
|
|
|
return thash; |
|
|
|
|
} |
|
|
|
|
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeader); |
|
|
|
|
cn_fast_hash(blob.data(), blob.size(), BEGIN(thash)); |
|
|
|
|
return thash; |
|
|
|
@ -43,7 +36,7 @@ uint256 CBlockHeader::GetPoWHash() const
@@ -43,7 +36,7 @@ uint256 CBlockHeader::GetPoWHash() const
|
|
|
|
|
// prev_id of CN header is used to store the kevacoin block hash.
|
|
|
|
|
// The value of prev_id and block hash must be the same to prove
|
|
|
|
|
// that PoW has been properly done.
|
|
|
|
|
if (GetHash() != cnHeader.prev_id) { |
|
|
|
|
if (GetOriginalBlockHash() != cnHeader.prev_id) { |
|
|
|
|
memset(thash.begin(), 0xff, thash.size()); |
|
|
|
|
return thash; |
|
|
|
|
} |
|
|
|
@ -56,7 +49,7 @@ std::string CBlock::ToString() const
@@ -56,7 +49,7 @@ std::string CBlock::ToString() const
|
|
|
|
|
{ |
|
|
|
|
std::stringstream s; |
|
|
|
|
s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n", |
|
|
|
|
GetHash().ToString(), |
|
|
|
|
GetOriginalBlockHash().ToString(), |
|
|
|
|
nVersion, |
|
|
|
|
hashPrevBlock.ToString(), |
|
|
|
|
hashMerkleRoot.ToString(), |
|
|
|
|