cryptonote_basic: add overload for get_block_longhash()

This commit is contained in:
jeffro256
2025-09-07 09:58:20 -05:00
parent 7fe199facc
commit 488bf71925
3 changed files with 34 additions and 21 deletions
@@ -1605,6 +1605,31 @@ namespace cryptonote
return get_tx_tree_hash(txs_ids);
}
//---------------------------------------------------------------
crypto::hash get_block_longhash(const blobdata_ref block_hashing_blob,
const uint64_t height,
const uint8_t major_version,
const crypto::hash &seed_hash)
{
crypto::hash res;
if (height == 202612) // block 202612 bug workaround
{
static const std::string longhash_202612 = "84f64766475d51837ac9efbef1926486e58563c95a19fef4aec3254f03000000";
epee::string_tools::hex_to_pod(longhash_202612, res);
}
else if (major_version >= RX_BLOCK_VERSION) // RandomX
{
crypto::rx_slow_hash(seed_hash.data, block_hashing_blob.data(), block_hashing_blob.size(), res.data);
}
else // CryptoNight
{
const int pow_variant = major_version >= 7 ? major_version - 6 : 0;
crypto::cn_slow_hash(block_hashing_blob.data(), block_hashing_blob.size(), res, pow_variant, height);
}
return res;
}
//---------------------------------------------------------------
bool is_valid_decomposed_amount(uint64_t amount)
{
if (0 == amount)