parent
6d94953be2
commit
0221b01519
|
@ -678,7 +678,7 @@ namespace cryptonote
|
||||||
rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1);
|
rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash, const int miners)
|
bool get_block_longhash(const Blockchain *pbc, const blobdata& bd, crypto::hash& res, const uint64_t height, const int major_version, const crypto::hash *seed_hash, const int miners)
|
||||||
{
|
{
|
||||||
// block 202612 bug workaround
|
// block 202612 bug workaround
|
||||||
if (height == 202612)
|
if (height == 202612)
|
||||||
|
@ -687,8 +687,7 @@ namespace cryptonote
|
||||||
epee::string_tools::hex_to_pod(longhash_202612, res);
|
epee::string_tools::hex_to_pod(longhash_202612, res);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
blobdata bd = get_block_hashing_blob(b);
|
if (major_version >= RX_BLOCK_VERSION)
|
||||||
if (b.major_version >= RX_BLOCK_VERSION)
|
|
||||||
{
|
{
|
||||||
uint64_t seed_height, main_height;
|
uint64_t seed_height, main_height;
|
||||||
crypto::hash hash;
|
crypto::hash hash;
|
||||||
|
@ -705,12 +704,18 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, seed_hash ? 0 : miners, !!seed_hash);
|
rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, seed_hash ? 0 : miners, !!seed_hash);
|
||||||
} else {
|
} else {
|
||||||
const int pow_variant = b.major_version >= 7 ? b.major_version - 6 : 0;
|
const int pow_variant = major_version >= 7 ? major_version - 6 : 0;
|
||||||
crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height);
|
crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash, const int miners)
|
||||||
|
{
|
||||||
|
blobdata bd = get_block_hashing_blob(b);
|
||||||
|
return get_block_longhash(pbc, bd, res, height, b.major_version, seed_hash, miners);
|
||||||
|
}
|
||||||
|
|
||||||
bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners)
|
bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners)
|
||||||
{
|
{
|
||||||
return get_block_longhash(pbc, b, res, height, NULL, miners);
|
return get_block_longhash(pbc, b, res, height, NULL, miners);
|
||||||
|
|
|
@ -142,6 +142,8 @@ namespace cryptonote
|
||||||
);
|
);
|
||||||
|
|
||||||
class Blockchain;
|
class Blockchain;
|
||||||
|
bool get_block_longhash(const Blockchain *pb, const blobdata& bd, crypto::hash& res, const uint64_t height,
|
||||||
|
const int major_version, const crypto::hash *seed_hash, const int miners);
|
||||||
bool get_block_longhash(const Blockchain *pb, const block& b, crypto::hash& res, const uint64_t height, const int miners);
|
bool get_block_longhash(const Blockchain *pb, const block& b, crypto::hash& res, const uint64_t height, const int miners);
|
||||||
bool get_block_longhash(const Blockchain *pb, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash, const int miners);
|
bool get_block_longhash(const Blockchain *pb, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash, const int miners);
|
||||||
void get_altblock_longhash(const block& b, crypto::hash& res, const uint64_t main_height, const uint64_t height,
|
void get_altblock_longhash(const block& b, crypto::hash& res, const uint64_t main_height, const uint64_t height,
|
||||||
|
|
|
@ -1912,6 +1912,43 @@ namespace cryptonote
|
||||||
return true;
|
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)
|
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);
|
RPC_TRACKER(add_aux_pow);
|
||||||
|
|
|
@ -149,6 +149,7 @@ namespace cryptonote
|
||||||
MAP_JON_RPC_WE("get_block_template", on_getblocktemplate, COMMAND_RPC_GETBLOCKTEMPLATE)
|
MAP_JON_RPC_WE("get_block_template", on_getblocktemplate, COMMAND_RPC_GETBLOCKTEMPLATE)
|
||||||
MAP_JON_RPC_WE("getblocktemplate", on_getblocktemplate, COMMAND_RPC_GETBLOCKTEMPLATE)
|
MAP_JON_RPC_WE("getblocktemplate", on_getblocktemplate, COMMAND_RPC_GETBLOCKTEMPLATE)
|
||||||
MAP_JON_RPC_WE("get_miner_data", on_getminerdata, COMMAND_RPC_GETMINERDATA)
|
MAP_JON_RPC_WE("get_miner_data", on_getminerdata, COMMAND_RPC_GETMINERDATA)
|
||||||
|
MAP_JON_RPC_WE_IF("calc_pow", on_calcpow, COMMAND_RPC_CALCPOW, !m_restricted)
|
||||||
MAP_JON_RPC_WE("add_aux_pow", on_add_aux_pow, COMMAND_RPC_ADD_AUX_POW)
|
MAP_JON_RPC_WE("add_aux_pow", on_add_aux_pow, COMMAND_RPC_ADD_AUX_POW)
|
||||||
MAP_JON_RPC_WE("submit_block", on_submitblock, COMMAND_RPC_SUBMITBLOCK)
|
MAP_JON_RPC_WE("submit_block", on_submitblock, COMMAND_RPC_SUBMITBLOCK)
|
||||||
MAP_JON_RPC_WE("submitblock", on_submitblock, COMMAND_RPC_SUBMITBLOCK)
|
MAP_JON_RPC_WE("submitblock", on_submitblock, COMMAND_RPC_SUBMITBLOCK)
|
||||||
|
@ -231,6 +232,7 @@ namespace cryptonote
|
||||||
bool on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
bool on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
bool on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
bool on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
bool on_getminerdata(const COMMAND_RPC_GETMINERDATA::request& req, COMMAND_RPC_GETMINERDATA::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
bool on_getminerdata(const COMMAND_RPC_GETMINERDATA::request& req, COMMAND_RPC_GETMINERDATA::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
|
bool on_calcpow(const COMMAND_RPC_CALCPOW::request& req, COMMAND_RPC_CALCPOW::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
bool 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 = NULL);
|
bool 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 = NULL);
|
||||||
bool on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
bool on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
bool on_generateblocks(const COMMAND_RPC_GENERATEBLOCKS::request& req, COMMAND_RPC_GENERATEBLOCKS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
bool on_generateblocks(const COMMAND_RPC_GENERATEBLOCKS::request& req, COMMAND_RPC_GENERATEBLOCKS::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx = NULL);
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace cryptonote
|
||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define CORE_RPC_VERSION_MAJOR 3
|
#define CORE_RPC_VERSION_MAJOR 3
|
||||||
#define CORE_RPC_VERSION_MINOR 8
|
#define CORE_RPC_VERSION_MINOR 9
|
||||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||||
|
|
||||||
|
@ -990,6 +990,28 @@ namespace cryptonote
|
||||||
typedef epee::misc_utils::struct_init<response_t> response;
|
typedef epee::misc_utils::struct_init<response_t> response;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct COMMAND_RPC_CALCPOW
|
||||||
|
{
|
||||||
|
struct request_t: public rpc_request_base
|
||||||
|
{
|
||||||
|
uint8_t major_version;
|
||||||
|
uint64_t height;
|
||||||
|
blobdata block_blob;
|
||||||
|
std::string seed_hash;
|
||||||
|
|
||||||
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
|
KV_SERIALIZE_PARENT(rpc_request_base)
|
||||||
|
KV_SERIALIZE(major_version)
|
||||||
|
KV_SERIALIZE(height)
|
||||||
|
KV_SERIALIZE(block_blob)
|
||||||
|
KV_SERIALIZE(seed_hash)
|
||||||
|
END_KV_SERIALIZE_MAP()
|
||||||
|
};
|
||||||
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
|
|
||||||
|
typedef std::string response;
|
||||||
|
};
|
||||||
|
|
||||||
struct COMMAND_RPC_ADD_AUX_POW
|
struct COMMAND_RPC_ADD_AUX_POW
|
||||||
{
|
{
|
||||||
struct aux_pow_t
|
struct aux_pow_t
|
||||||
|
|
Loading…
Reference in New Issue