mirror of
https://github.com/monero-project/monero.git
synced 2025-08-16 22:10:33 -04:00
Add calcpow RPC
Calculate PoW hash for a block candidate
This commit is contained in:
parent
6d94953be2
commit
0221b01519
5 changed files with 73 additions and 5 deletions
|
@ -1912,6 +1912,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_add_aux_pow(const COMMAND_RPC_ADD_AUX_POW::request& req, COMMAND_RPC_ADD_AUX_POW::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
||||
{
|
||||
RPC_TRACKER(add_aux_pow);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue