mirror of https://github.com/oxen-io/oxen-core.git
GET_SERVICE_NODE_REGISTRATION_CMD_RAW
This commit is contained in:
parent
cf8ecd2d17
commit
aa0427dbdb
|
@ -1210,12 +1210,12 @@ bool rpc_command_executor::output_histogram(const std::vector<uint64_t> &amounts
|
|||
if (!invoke<GET_OUTPUT_HISTOGRAM>(std::move(req), res, "Failed to retrieve output histogram"))
|
||||
return false;
|
||||
|
||||
//std::sort(res.histogram.begin(), res.histogram.end(),
|
||||
//[](const auto& e1, const auto& e2)->bool { return e1.total_instances < e2.total_instances; });
|
||||
//for (const auto &e: res.histogram)
|
||||
//{
|
||||
//tools::msg_writer() << e.total_instances << " " << cryptonote::print_money(e.amount);
|
||||
//}
|
||||
std::sort(res.histogram.begin(), res.histogram.end(),
|
||||
[](const auto& e1, const auto& e2)->bool { return e1.total_instances < e2.total_instances; });
|
||||
for (const auto &e: res.histogram)
|
||||
{
|
||||
tools::msg_writer() << e.total_instances << " " << cryptonote::print_money(e.amount);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2437,18 +2437,12 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
|
|||
scoped_log_cats.reset();
|
||||
|
||||
{
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request req{};
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response res{};
|
||||
|
||||
req.args = args;
|
||||
req.make_friendly = true;
|
||||
req.staking_requirement = staking_requirement;
|
||||
|
||||
if (!invoke<GET_SERVICE_NODE_REGISTRATION_CMD_RAW>(std::move(req), res, "Failed to validate registration arguments; "
|
||||
"check the addresses and registration parameters and that the Daemon is running with the '--service-node' flag"))
|
||||
auto maybe_registration = try_running([this, staking_requirement, &args] { return invoke<GET_SERVICE_NODE_REGISTRATION_CMD_RAW>(json{{"staking_requirement", staking_requirement}, {"args", args}, {"make_friendly", true}}); }, "Failed to validate registration arguments; check the addresses and registration parameters and that the Daemon is running with the '--service-node' flag");
|
||||
if (!maybe_registration)
|
||||
return false;
|
||||
auto& registration = *maybe_registration;
|
||||
|
||||
tools::success_msg_writer() << res.registration_cmd;
|
||||
tools::success_msg_writer() << registration["registration_cmd"];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2391,21 +2391,27 @@ namespace cryptonote::rpc {
|
|||
flush_cache.response["status"] = STATUS_OK;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response core_rpc_server::invoke(GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request&& req, rpc_context context)
|
||||
void core_rpc_server::invoke(GET_SERVICE_NODE_REGISTRATION_CMD_RAW& get_service_node_registration_cmd_raw, rpc_context context)
|
||||
{
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response res{};
|
||||
|
||||
PERF_TIMER(on_get_service_node_registration_cmd_raw);
|
||||
|
||||
if (!m_core.service_node())
|
||||
throw rpc_error{ERROR_WRONG_PARAM, "Daemon has not been started in service node mode, please relaunch with --service-node flag."};
|
||||
|
||||
uint8_t hf_version = get_network_version(nettype(), m_core.get_current_blockchain_height());
|
||||
if (!service_nodes::make_registration_cmd(m_core.get_nettype(), hf_version, req.staking_requirement, req.args, m_core.get_service_keys(), res.registration_cmd, req.make_friendly))
|
||||
std::string registration_cmd;
|
||||
if (!service_nodes::make_registration_cmd(m_core.get_nettype(),
|
||||
hf_version,
|
||||
get_service_node_registration_cmd_raw.request.staking_requirement,
|
||||
get_service_node_registration_cmd_raw.request.args,
|
||||
m_core.get_service_keys(),
|
||||
registration_cmd,
|
||||
get_service_node_registration_cmd_raw.request.make_friendly))
|
||||
throw rpc_error{ERROR_INTERNAL, "Failed to make registration command"};
|
||||
|
||||
res.status = STATUS_OK;
|
||||
return res;
|
||||
get_service_node_registration_cmd_raw.response["registration_cmd"] = registration_cmd;
|
||||
get_service_node_registration_cmd_raw.response["status"] = STATUS_OK;
|
||||
return;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD::response core_rpc_server::invoke(GET_SERVICE_NODE_REGISTRATION_CMD::request&& req, rpc_context context)
|
||||
|
@ -2438,12 +2444,16 @@ namespace cryptonote::rpc {
|
|||
args.push_back(std::to_string(num_portions));
|
||||
}
|
||||
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request req_old{};
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW req_old{};
|
||||
|
||||
req_old.staking_requirement = req.staking_requirement;
|
||||
req_old.args = std::move(args);
|
||||
req_old.make_friendly = false;
|
||||
return invoke(std::move(req_old), context);
|
||||
req_old.request.staking_requirement = req.staking_requirement;
|
||||
req_old.request.args = std::move(args);
|
||||
req_old.request.make_friendly = false;
|
||||
|
||||
invoke(req_old, context);
|
||||
res.status = req_old.response["status"];
|
||||
res.registration_cmd = req_old.response["registration_cmd"];
|
||||
return res;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
void core_rpc_server::invoke(GET_SERVICE_NODE_BLACKLISTED_KEY_IMAGES& get_service_node_blacklisted_key_images, rpc_context context)
|
||||
|
|
|
@ -250,6 +250,7 @@ namespace cryptonote::rpc {
|
|||
void invoke(GET_BLOCK_HEADERS_RANGE& get_block_headers_range, rpc_context context);
|
||||
void invoke(GET_BLOCK_HEADER_BY_HEIGHT& get_block_header_by_height, rpc_context context);
|
||||
void invoke(GET_BLOCK& get_block, rpc_context context);
|
||||
void invoke(GET_SERVICE_NODE_REGISTRATION_CMD_RAW& get_service_node_registration_cmd_raw, rpc_context context);
|
||||
|
||||
// Deprecated Monero NIH binary endpoints:
|
||||
GET_ALT_BLOCKS_HASHES_BIN::response invoke(GET_ALT_BLOCKS_HASHES_BIN::request&& req, rpc_context context);
|
||||
|
@ -267,7 +268,6 @@ namespace cryptonote::rpc {
|
|||
GET_OUTPUT_HISTOGRAM::response invoke(GET_OUTPUT_HISTOGRAM::request&& req, rpc_context context);
|
||||
GET_ALTERNATE_CHAINS::response invoke(GET_ALTERNATE_CHAINS::request&& req, rpc_context context);
|
||||
GET_QUORUM_STATE::response invoke(GET_QUORUM_STATE::request&& req, rpc_context context);
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response invoke(GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request&& req, rpc_context context);
|
||||
GET_SERVICE_NODE_REGISTRATION_CMD::response invoke(GET_SERVICE_NODE_REGISTRATION_CMD::request&& req, rpc_context context);
|
||||
ONS_NAMES_TO_OWNERS::response invoke(ONS_NAMES_TO_OWNERS::request&& req, rpc_context context);
|
||||
ONS_OWNERS_TO_NAMES::response invoke(ONS_OWNERS_TO_NAMES::request&& req, rpc_context context);
|
||||
|
|
|
@ -102,6 +102,7 @@ KV_SERIALIZE_MAP_CODE_BEGIN(block_header_response)
|
|||
KV_SERIALIZE(service_node_winner)
|
||||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_OUTPUT_HISTOGRAM::request)
|
||||
KV_SERIALIZE(amounts);
|
||||
KV_SERIALIZE(min_count);
|
||||
|
@ -111,7 +112,6 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_OUTPUT_HISTOGRAM::request)
|
|||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_OUTPUT_HISTOGRAM::entry)
|
||||
KV_SERIALIZE(amount);
|
||||
KV_SERIALIZE(total_instances);
|
||||
|
@ -244,19 +244,6 @@ KV_SERIALIZE_MAP_CODE_BEGIN(GET_QUORUM_STATE::response)
|
|||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_SERVICE_NODE_REGISTRATION_CMD_RAW::request)
|
||||
KV_SERIALIZE(args)
|
||||
KV_SERIALIZE(make_friendly)
|
||||
KV_SERIALIZE(staking_requirement)
|
||||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response)
|
||||
KV_SERIALIZE(status)
|
||||
KV_SERIALIZE(registration_cmd)
|
||||
KV_SERIALIZE_MAP_CODE_END()
|
||||
|
||||
|
||||
KV_SERIALIZE_MAP_CODE_BEGIN(GET_SERVICE_NODE_REGISTRATION_CMD::contribution_t)
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE(amount)
|
||||
|
|
|
@ -1625,27 +1625,30 @@ namespace cryptonote::rpc {
|
|||
};
|
||||
};
|
||||
|
||||
OXEN_RPC_DOC_INTROSPECT
|
||||
/// Returns the command that should be run to prepare a service node, includes correct parameters
|
||||
/// and service node ids formatted ready for cut and paste into daemon console.
|
||||
///
|
||||
/// Inputs:
|
||||
///
|
||||
/// - \p check Instead of running check if the blockchain has already been pruned.
|
||||
/// - \p args (Developer) The list of arguments used in raw registration, i.e. portions
|
||||
/// - \p make_friendly Provide information about how to use the command in the result.
|
||||
/// - \p staking_requirement The staking requirement to become a Service Node the registration command will be generated upon
|
||||
///
|
||||
/// Output values available from a restricted/admin RPC endpoint:
|
||||
///
|
||||
/// - \p status General RPC status string. `"OK"` means everything looks good.
|
||||
/// - \p registration_cmd The command to execute in the wallet CLI to register the queried daemon as a Service Node.
|
||||
struct GET_SERVICE_NODE_REGISTRATION_CMD_RAW : RPC_COMMAND
|
||||
{
|
||||
static constexpr auto names() { return NAMES("get_service_node_registration_cmd_raw"); }
|
||||
|
||||
struct request
|
||||
struct request_parameters
|
||||
{
|
||||
std::vector<std::string> args; // (Developer) The arguments used in raw registration, i.e. portions
|
||||
bool make_friendly; // Provide information about how to use the command in the result.
|
||||
uint64_t staking_requirement; // The staking requirement to become a Service Node the registration command will be generated upon
|
||||
|
||||
KV_MAP_SERIALIZABLE
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string status; // Generic RPC error code. "OK" is the success value.
|
||||
std::string registration_cmd; // The command to execute in the wallet CLI to register the queried daemon as a Service Node.
|
||||
|
||||
KV_MAP_SERIALIZABLE
|
||||
};
|
||||
} request;
|
||||
};
|
||||
|
||||
OXEN_RPC_DOC_INTROSPECT
|
||||
|
@ -1670,7 +1673,13 @@ namespace cryptonote::rpc {
|
|||
KV_MAP_SERIALIZABLE
|
||||
};
|
||||
|
||||
using response = GET_SERVICE_NODE_REGISTRATION_CMD_RAW::response;
|
||||
struct response
|
||||
{
|
||||
std::string status; // Generic RPC error code. "OK" is the success value.
|
||||
std::string registration_cmd; // The command to execute in the wallet CLI to register the queried daemon as a Service Node.
|
||||
|
||||
KV_MAP_SERIALIZABLE
|
||||
};
|
||||
};
|
||||
|
||||
/// Get the service public keys of the queried daemon, encoded in hex. All three keys are used
|
||||
|
|
Loading…
Reference in New Issue