mirror of
https://github.com/monero-project/monero.git
synced 2025-08-16 21:00:27 -04:00
RPC and ZeroMQ APIs to support p2pool
Adds the following: - "get_miner_data" to RPC API - "json-miner-data" to ZeroMQ subscriber contexts Both provide the necessary data to create a custom block template. They are used by p2pool. Data provided: - major fork version - current height - previous block id - RandomX seed hash - network difficulty - median block weight - coins mined by the network so far - mineable mempool transactions
This commit is contained in:
parent
2d3ce2d64a
commit
dfee15eee1
20 changed files with 404 additions and 25 deletions
|
@ -1861,6 +1861,43 @@ namespace cryptonote
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_getminerdata(const COMMAND_RPC_GETMINERDATA::request& req, COMMAND_RPC_GETMINERDATA::response& res, epee::json_rpc::error& error_resp, const connection_context *ctx)
|
||||
{
|
||||
if(!check_core_ready())
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY;
|
||||
error_resp.message = "Core is busy";
|
||||
return false;
|
||||
}
|
||||
|
||||
crypto::hash prev_id, seed_hash;
|
||||
difficulty_type difficulty;
|
||||
|
||||
std::vector<tx_block_template_backlog_entry> tx_backlog;
|
||||
if (!m_core.get_miner_data(res.major_version, res.height, prev_id, seed_hash, difficulty, res.median_weight, res.already_generated_coins, tx_backlog))
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
error_resp.message = "Internal error: failed to get miner data";
|
||||
LOG_ERROR("Failed to get miner data");
|
||||
return false;
|
||||
}
|
||||
|
||||
res.tx_backlog.clear();
|
||||
res.tx_backlog.reserve(tx_backlog.size());
|
||||
|
||||
for (const auto& entry : tx_backlog)
|
||||
{
|
||||
res.tx_backlog.emplace_back(COMMAND_RPC_GETMINERDATA::response::tx_backlog_entry{string_tools::pod_to_hex(entry.id), entry.weight, entry.fee});
|
||||
}
|
||||
|
||||
res.prev_id = string_tools::pod_to_hex(prev_id);
|
||||
res.seed_hash = string_tools::pod_to_hex(seed_hash);
|
||||
res.difficulty = cryptonote::hex(difficulty);
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
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