aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index e5bf0077f..62415fb43 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -1888,6 +1888,43 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_calcpow(const COMMAND_RPC_CALCPOW::request& req, COMMAND_RPC_CALCPOW::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
+ {
+ RPC_TRACKER(calcpow);
+
+ blobdata blockblob;
+ if(!string_tools::parse_hexstr_to_binbuff(req.block_blob, blockblob))
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB;
+ error_resp.message = "Wrong block blob";
+ return false;
+ }
+ if(!m_core.check_incoming_block_size(blockblob))
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_WRONG_BLOCKBLOB_SIZE;
+ error_resp.message = "Block blob size is too big, rejecting block";
+ return false;
+ }
+ crypto::hash seed_hash, pow_hash;
+ std::string buf;
+ if(req.seed_hash.size())
+ {
+ if (!string_tools::parse_hexstr_to_binbuff(req.seed_hash, buf) ||
+ buf.size() != sizeof(crypto::hash))
+ {
+ error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
+ error_resp.message = "Wrong seed hash";
+ return false;
+ }
+ buf.copy(reinterpret_cast<char *>(&seed_hash), sizeof(crypto::hash));
+ }
+
+ cryptonote::get_block_longhash(&(m_core.get_blockchain_storage()), blockblob, pow_hash, req.height,
+ req.major_version, req.seed_hash.size() ? &seed_hash : NULL, 0);
+ res = string_tools::pod_to_hex(pow_hash);
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
{
RPC_TRACKER(submitblock);