diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-11-08 17:30:18 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2020-08-27 15:13:00 +0000 |
commit | 9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee (patch) | |
tree | d3e5a6a12cbd0bd4d3906afd4d9b350667aceda3 /src/rpc/core_rpc_server.cpp | |
parent | Merge pull request #6771 (diff) | |
download | monero-9d42649d58a1a898b8fd1be17f42fb6b7ad1f6ee.tar.xz |
core: fix mining from a block that's not the current top
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 9e17bed63..555da9ddd 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1642,7 +1642,7 @@ namespace cryptonote bool core_rpc_server::get_block_template(const account_public_address &address, const crypto::hash *prev_block, const cryptonote::blobdata &extra_nonce, size_t &reserved_offset, cryptonote::difficulty_type &difficulty, uint64_t &height, uint64_t &expected_reward, block &b, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, epee::json_rpc::error &error_resp) { b = boost::value_initialized<cryptonote::block>(); - if(!m_core.get_block_template(b, prev_block, address, difficulty, height, expected_reward, extra_nonce)) + if(!m_core.get_block_template(b, prev_block, address, difficulty, height, expected_reward, extra_nonce, seed_height, seed_hash)) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.message = "Internal error: failed to create block template"; @@ -1659,17 +1659,6 @@ namespace cryptonote return false; } - if (b.major_version >= RX_BLOCK_VERSION) - { - uint64_t next_height; - crypto::rx_seedheights(height, &seed_height, &next_height); - seed_hash = m_core.get_block_id_by_height(seed_height); - if (next_height != seed_height) - next_seed_hash = m_core.get_block_id_by_height(next_height); - else - next_seed_hash = seed_hash; - } - if (extra_nonce.empty()) { reserved_offset = 0; @@ -1897,9 +1886,16 @@ namespace cryptonote return false; } b.nonce = req.starting_nonce; - miner::find_nonce_for_given_block([this](const cryptonote::block &b, uint64_t height, unsigned int threads, crypto::hash &hash) { - return cryptonote::get_block_longhash(&(m_core.get_blockchain_storage()), b, hash, height, threads); - }, b, template_res.difficulty, template_res.height); + crypto::hash seed_hash = crypto::null_hash; + if (b.major_version >= RX_BLOCK_VERSION && !epee::string_tools::hex_to_pod(template_res.seed_hash, seed_hash)) + { + error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; + error_resp.message = "Error converting seed hash"; + return false; + } + miner::find_nonce_for_given_block([this](const cryptonote::block &b, uint64_t height, const crypto::hash *seed_hash, unsigned int threads, crypto::hash &hash) { + return cryptonote::get_block_longhash(&(m_core.get_blockchain_storage()), b, hash, height, seed_hash, threads); + }, b, template_res.difficulty, template_res.height, &seed_hash); submit_req.front() = string_tools::buff_to_hex_nodelimer(block_to_blob(b)); r = on_submitblock(submit_req, submit_res, error_resp, ctx); |