mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-09-03 10:22:09 +00:00
WIP: fixed PoW hash computation.
This commit is contained in:
parent
9e442eb109
commit
3a657f0615
@ -29,16 +29,15 @@ uint256 CBlockHeader::GetPoWHash() const
|
|||||||
cn_slow_hash(BEGIN(nVersion), 80, BEGIN(thash), 2, 0, 0);
|
cn_slow_hash(BEGIN(nVersion), 80, BEGIN(thash), 2, 0, 0);
|
||||||
return thash;
|
return thash;
|
||||||
}
|
}
|
||||||
arith_uint256 blockHash = UintToArith256(GetHash());
|
|
||||||
arith_uint256 expectedHash = UintToArith256(cnHeader.prev_id);
|
// prev_id of CN header is used to store the kevacoin block hash.
|
||||||
// blockHash should be the same as expectedHash. If so, after the
|
// The value of prev_id and block hash must be the same to prove
|
||||||
// following XOR operatiosn, the value of expectedHash is not changed.
|
// that PoW has been properly done.
|
||||||
blockHash ^= expectedHash;
|
if (GetHash() != cnHeader.prev_id) {
|
||||||
expectedHash ^= blockHash;
|
memset(thash.begin(), 0xff, thash.size());
|
||||||
CryptoNoteHeader cnHeaderCompute = cnHeader;
|
return thash;
|
||||||
// Cryptonote prev_id is used to store kevacoin block hash.
|
}
|
||||||
cnHeaderCompute.prev_id = ArithToUint256(expectedHash);
|
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeader);
|
||||||
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeaderCompute);
|
|
||||||
cn_slow_hash(blob.data(), blob.size(), BEGIN(thash), 2, 0, 0);
|
cn_slow_hash(blob.data(), blob.size(), BEGIN(thash), 2, 0, 0);
|
||||||
return thash;
|
return thash;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user