diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-23 16:20:08 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-11 11:07:58 +0000 |
commit | 064ab123401814b755c776d8e53f132f6a151657 (patch) | |
tree | c08e17486a0cd16e9ff46a2a2158d714aecceaa1 /src/rpc/core_rpc_server.cpp | |
parent | functional_tests: add bans tests (diff) | |
download | monero-064ab123401814b755c776d8e53f132f6a151657.tar.xz |
functional_tests: add more blockchain related tests
Related to emission, reorgs, getting tx data back, output
distribution and histogram
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index b540520c7..71bfcc950 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -496,6 +496,7 @@ namespace cryptonote cryptonote::COMMAND_RPC_GET_OUTPUTS_BIN::request req_bin; req_bin.outputs = req.outputs; + req_bin.get_txid = req.get_txid; cryptonote::COMMAND_RPC_GET_OUTPUTS_BIN::response res_bin; if(!m_core.get_outs(req_bin, res_bin)) { @@ -1259,7 +1260,17 @@ namespace cryptonote cryptonote::blobdata blob_reserve; blob_reserve.resize(req.reserve_size, 0); cryptonote::difficulty_type wdiff; - if(!m_core.get_block_template(b, info.address, wdiff, res.height, res.expected_reward, blob_reserve)) + crypto::hash prev_block; + if (!req.prev_block.empty()) + { + if (!epee::string_tools::hex_to_pod(req.prev_block, prev_block)) + { + error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; + error_resp.message = "Invalid prev_block"; + return false; + } + } + if(!m_core.get_block_template(b, req.prev_block.empty() ? NULL : &prev_block, info.address, wdiff, res.height, res.expected_reward, blob_reserve)) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.message = "Internal error: failed to create block template"; @@ -1345,7 +1356,8 @@ namespace cryptonote return false; } - if(!m_core.handle_block_found(b)) + block_verification_context bvc; + if(!m_core.handle_block_found(b, bvc)) { error_resp.code = CORE_RPC_ERROR_CODE_BLOCK_NOT_ACCEPTED; error_resp.message = "Block not accepted"; @@ -1377,15 +1389,17 @@ namespace cryptonote template_req.reserve_size = 1; template_req.wallet_address = req.wallet_address; + template_req.prev_block = req.prev_block; submit_req.push_back(boost::value_initialized<std::string>()); res.height = m_core.get_blockchain_storage().get_current_blockchain_height(); - bool r; + bool r = CORE_RPC_STATUS_OK; for(size_t i = 0; i < req.amount_of_blocks; i++) { r = on_getblocktemplate(template_req, template_res, error_resp, ctx); res.status = template_res.status; + template_req.prev_block.clear(); if (!r) return false; @@ -1403,6 +1417,7 @@ namespace cryptonote error_resp.message = "Wrong block blob"; return false; } + b.nonce = req.starting_nonce; miner::find_nonce_for_given_block(b, template_res.difficulty, template_res.height); submit_req.front() = string_tools::buff_to_hex_nodelimer(block_to_blob(b)); @@ -1411,6 +1426,8 @@ namespace cryptonote if (!r) return false; + res.blocks.push_back(epee::string_tools::pod_to_hex(get_block_hash(b))); + template_req.prev_block = res.blocks.back(); res.height = template_res.height; } |