mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
rpc: get_block_template add optional extra_nonce
Circumvents the need to create a new blockhashing blob when you already know the data you want to set in the extra_nonce (so use this instead of reserve_size).
This commit is contained in:
parent
633f14b976
commit
6560bfa64c
2 changed files with 27 additions and 1 deletions
|
@ -1216,6 +1216,20 @@ namespace cryptonote
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.reserve_size && !req.extra_nonce.empty())
|
||||||
|
{
|
||||||
|
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
|
||||||
|
error_resp.message = "Cannot specify both a reserve_size and an extra_nonce";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(req.extra_nonce.size() > 510)
|
||||||
|
{
|
||||||
|
error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_RESERVE_SIZE;
|
||||||
|
error_resp.message = "Too big extra_nonce size, maximum 510 hex chars";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cryptonote::address_parse_info info;
|
cryptonote::address_parse_info info;
|
||||||
|
|
||||||
if(!req.wallet_address.size() || !cryptonote::get_account_address_from_str(info, nettype(), req.wallet_address))
|
if(!req.wallet_address.size() || !cryptonote::get_account_address_from_str(info, nettype(), req.wallet_address))
|
||||||
|
@ -1233,6 +1247,16 @@ namespace cryptonote
|
||||||
|
|
||||||
block b;
|
block b;
|
||||||
cryptonote::blobdata blob_reserve;
|
cryptonote::blobdata blob_reserve;
|
||||||
|
if(!req.extra_nonce.empty())
|
||||||
|
{
|
||||||
|
if(!string_tools::parse_hexstr_to_binbuff(req.extra_nonce, blob_reserve))
|
||||||
|
{
|
||||||
|
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
|
||||||
|
error_resp.message = "Parameter extra_nonce should be a hex string";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
blob_reserve.resize(req.reserve_size, 0);
|
blob_reserve.resize(req.reserve_size, 0);
|
||||||
cryptonote::difficulty_type wdiff;
|
cryptonote::difficulty_type wdiff;
|
||||||
crypto::hash prev_block;
|
crypto::hash prev_block;
|
||||||
|
|
|
@ -919,11 +919,13 @@ namespace cryptonote
|
||||||
uint64_t reserve_size; //max 255 bytes
|
uint64_t reserve_size; //max 255 bytes
|
||||||
std::string wallet_address;
|
std::string wallet_address;
|
||||||
std::string prev_block;
|
std::string prev_block;
|
||||||
|
std::string extra_nonce;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(reserve_size)
|
KV_SERIALIZE(reserve_size)
|
||||||
KV_SERIALIZE(wallet_address)
|
KV_SERIALIZE(wallet_address)
|
||||||
KV_SERIALIZE(prev_block)
|
KV_SERIALIZE(prev_block)
|
||||||
|
KV_SERIALIZE(extra_nonce)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<request_t> request;
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
|
|
Loading…
Reference in a new issue