aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/cryptonote_tx_utils.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-08 17:30:18 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-08-27 15:13:00 +0000
commit9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee (patch)
treed3e5a6a12cbd0bd4d3906afd4d9b350667aceda3 /src/cryptonote_core/cryptonote_tx_utils.cpp
parentc695470cff44e9f7fe0257d99cf94962aff1c4a2 (diff)
downloadmonzero-core-9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee.tar.gz
monzero-core-9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee.tar.xz
monzero-core-9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee.zip
core: fix mining from a block that's not the current top
Diffstat (limited to 'src/cryptonote_core/cryptonote_tx_utils.cpp')
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp17
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;