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/rpc | |
parent | Merge pull request #6802 (diff) | |
parent | functional_tests: add a large (many randomx epochs) p2p reorg test (diff) | |
download | monero-aefa7740c38754b31a4f5748569ac1af59034667.tar.xz |
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/rpc')
-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 36e86ae5d..82e3e9040 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); |