diff options
| author | Riccardo Spagni <ric@spagni.net> | 2020-09-06 15:49:36 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2020-09-06 15:49:37 +0200 |
| commit | aefa7740c38754b31a4f5748569ac1af59034667 (patch) | |
| tree | ffb822e7c7e0929d70b706f26f29f94caec7aecd /src/cryptonote_core/cryptonote_tx_utils.cpp | |
| parent | 2a7086caa8a63f16ee360d11fae3036fa61598eb (diff) | |
| parent | d20ff4f648ea3b716825ea34db05b98ad24239b4 (diff) | |
| download | monzero-core-aefa7740c38754b31a4f5748569ac1af59034667.tar.gz monzero-core-aefa7740c38754b31a4f5748569ac1af59034667.tar.xz monzero-core-aefa7740c38754b31a4f5748569ac1af59034667.zip | |
Merge pull request #6111
d20ff4f64 functional_tests: add a large (many randomx epochs) p2p reorg test (moneromooo-monero)
6a0b3b1f8 functional_tests: add randomx tests (moneromooo-monero)
9d42649d5 core: fix mining from a block that's not the current top (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/cryptonote_tx_utils.cpp')
| -rw-r--r-- | src/cryptonote_core/cryptonote_tx_utils.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 7ea7e81d9..7400c4328 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -663,9 +663,9 @@ namespace cryptonote bl.minor_version = CURRENT_BLOCK_MINOR_VERSION; bl.timestamp = 0; bl.nonce = nonce; - miner::find_nonce_for_given_block([](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash){ - return cryptonote::get_block_longhash(NULL, b, hash, height, threads); - }, bl, 1, 0); + miner::find_nonce_for_given_block([](const cryptonote::block &b, uint64_t height, const crypto::hash *seed_hash, unsigned int threads, crypto::hash &hash){ + return cryptonote::get_block_longhash(NULL, b, hash, height, seed_hash, threads); + }, bl, 1, 0, NULL); bl.invalidate_hashes(); return true; } @@ -676,7 +676,7 @@ namespace cryptonote rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1); } - bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners) + bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash, const int miners) { // block 202612 bug workaround if (height == 202612) @@ -693,7 +693,7 @@ namespace cryptonote if (pbc != NULL) { seed_height = rx_seedheight(height); - hash = pbc->get_pending_block_id_by_height(seed_height); + hash = seed_hash ? *seed_hash : pbc->get_pending_block_id_by_height(seed_height); main_height = pbc->get_current_blockchain_height(); } else { @@ -701,7 +701,7 @@ namespace cryptonote seed_height = 0; main_height = 0; } - rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, miners, 0); + rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, seed_hash ? 0 : miners, !!seed_hash); } else { const int pow_variant = b.major_version >= 7 ? b.major_version - 6 : 0; crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height); @@ -709,6 +709,11 @@ namespace cryptonote return true; } + 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 p = crypto::null_hash; |
