aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_tx_utils.cpp
diff options
context:
space:
mode:
authorSChernykh <sergey.v.chernykh@gmail.com>2022-12-10 18:30:59 +0100
committerSChernykh <sergey.v.chernykh@gmail.com>2022-12-14 07:21:00 +0100
commitf698f2b708be742afa286c65868a48f7ef80b0ba (patch)
treea6806569a4d1d0fa3847f55b08cfe4002cff709f /src/cryptonote_core/cryptonote_tx_utils.cpp
parentMerge pull request #8642 (diff)
downloadmonero-f698f2b708be742afa286c65868a48f7ef80b0ba.tar.xz
Refactored rx-slow-hash.c
- Straight-forward call interface: `void rx_slow_hash(const char *seedhash, const void *data, size_t length, char *result_hash)` - Consensus chain seed hash is now updated by calling `rx_set_main_seedhash` whenever a block is added/removed or a reorg happens - `rx_slow_hash` will compute correct hash no matter if `rx_set_main_seedhash` was called or not (the only difference is performance) - New environment variable `MONERO_RANDOMX_FULL_MEM` to force use the full dataset for PoW verification (faster block verification) - When dataset is used for PoW verification, dataset updates don't stall other threads (verification is done in light mode then) - When mining is running, PoW checks now also use dataset for faster verification
Diffstat (limited to 'src/cryptonote_core/cryptonote_tx_utils.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 472026217..bf58a120d 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -669,10 +669,10 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------
- void get_altblock_longhash(const block& b, crypto::hash& res, const uint64_t main_height, const uint64_t height, const uint64_t seed_height, const crypto::hash& seed_hash)
+ void get_altblock_longhash(const block& b, crypto::hash& res, const crypto::hash& seed_hash)
{
blobdata bd = get_block_hashing_blob(b);
- rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1);
+ rx_slow_hash(seed_hash.data, bd.data(), bd.size(), res.data);
}
bool get_block_longhash(const Blockchain *pbc, const blobdata& bd, crypto::hash& res, const uint64_t height, const int major_version, const crypto::hash *seed_hash, const int miners)
@@ -686,20 +686,16 @@ namespace cryptonote
}
if (major_version >= RX_BLOCK_VERSION)
{
- uint64_t seed_height, main_height;
crypto::hash hash;
if (pbc != NULL)
{
- seed_height = rx_seedheight(height);
+ const uint64_t seed_height = rx_seedheight(height);
hash = seed_hash ? *seed_hash : pbc->get_pending_block_id_by_height(seed_height);
- main_height = pbc->get_current_blockchain_height();
} else
{
memset(&hash, 0, sizeof(hash)); // only happens when generating genesis block
- seed_height = 0;
- main_height = 0;
}
- rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, seed_hash ? 0 : miners, !!seed_hash);
+ rx_slow_hash(hash.data, bd.data(), bd.size(), res.data);
} else {
const int pow_variant = major_version >= 7 ? major_version - 6 : 0;
crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height);
@@ -713,20 +709,10 @@ namespace cryptonote
return get_block_longhash(pbc, bd, res, height, b.major_version, seed_hash, miners);
}
- bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners)
- {
- return get_block_longhash(pbc, b, res, height, NULL, miners);
- }
-
- crypto::hash get_block_longhash(const Blockchain *pbc, const block& b, const uint64_t height, const int miners)
+ crypto::hash get_block_longhash(const Blockchain *pbc, const block& b, const uint64_t height, const crypto::hash *seed_hash, const int miners)
{
crypto::hash p = crypto::null_hash;
- get_block_longhash(pbc, b, p, height, miners);
+ get_block_longhash(pbc, b, p, height, seed_hash, miners);
return p;
}
-
- void get_block_longhash_reorg(const uint64_t split_height)
- {
- rx_reorg(split_height);
- }
}