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:
SChernykh
2021-08-26 10:20:20 +02:00
parent 2d3ce2d64a
commit dfee15eee1
20 changed files with 404 additions and 25 deletions

View File

@@ -34,6 +34,7 @@
#include <type_traits>
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_core/cryptonote_tx_utils.h"
// drop macro from windows.h
#ifdef GetObject
@@ -1411,6 +1412,27 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::rpc::output_distribu
GET_FROM_JSON_OBJECT(val, dist.data.base, base);
}
void toJsonValue(rapidjson::Writer<epee::byte_stream>& dest, const cryptonote::tx_block_template_backlog_entry& entry)
{
dest.StartObject();
INSERT_INTO_JSON_OBJECT(dest, id, entry.id);
INSERT_INTO_JSON_OBJECT(dest, weight, entry.weight);
INSERT_INTO_JSON_OBJECT(dest, fee, entry.fee);
dest.EndObject();
}
void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_block_template_backlog_entry& entry)
{
if (!val.IsObject())
{
throw WRONG_TYPE("json object");
}
GET_FROM_JSON_OBJECT(val, entry.id, id);
GET_FROM_JSON_OBJECT(val, entry.weight, weight);
GET_FROM_JSON_OBJECT(val, entry.fee, fee);
}
} // namespace json
} // namespace cryptonote