mirror of
https://github.com/monero-project/monero.git
synced 2025-08-05 06:04:17 -04:00
Merge pull request #3163
628b78ae
Fix in_peers/out_peers RPC operations (Erik de Castro Lopo)ece9bcf5
rpc_client: Fix error handling (Erik de Castro Lopo)8f30350d
Fix method name in invoke_http_json_rpc (Erik de Castro Lopo)32c0f908
Allow the number of incoming connections to be limited (Erik de Castro Lopo)d609a2c1
Rename delete_connections to delete_out_connections (Erik de Castro Lopo)b927c0fc
Rename connections_count to max_out_connection_count (Erik de Castro Lopo)
This commit is contained in:
commit
381faf06c7
15 changed files with 231 additions and 66 deletions
|
@ -428,6 +428,23 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args)
|
|||
return m_executor.out_peers(limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::in_peers(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty()) return false;
|
||||
|
||||
unsigned int limit;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
}
|
||||
|
||||
catch(const std::exception& ex) {
|
||||
_erro("stoi exception");
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_executor.in_peers(limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::start_save_graph(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!args.empty()) return false;
|
||||
|
|
|
@ -108,7 +108,9 @@ public:
|
|||
bool set_limit_down(const std::vector<std::string>& args);
|
||||
|
||||
bool out_peers(const std::vector<std::string>& args);
|
||||
|
||||
|
||||
bool in_peers(const std::vector<std::string>& args);
|
||||
|
||||
bool start_save_graph(const std::vector<std::string>& args);
|
||||
|
||||
bool stop_save_graph(const std::vector<std::string>& args);
|
||||
|
|
|
@ -196,6 +196,12 @@ t_command_server::t_command_server(
|
|||
, "out_peers <max_number>"
|
||||
, "Set the <max_number> of out peers."
|
||||
);
|
||||
m_command_lookup.set_handler(
|
||||
"in_peers"
|
||||
, std::bind(&t_command_parser_executor::in_peers, &m_parser, p::_1)
|
||||
, "in_peers <max_number>"
|
||||
, "Set the <max_number> of in peers."
|
||||
);
|
||||
m_command_lookup.set_handler(
|
||||
"start_save_graph"
|
||||
, std::bind(&t_command_parser_executor::start_save_graph, &m_parser, p::_1)
|
||||
|
|
|
@ -1262,7 +1262,7 @@ bool t_rpc_command_executor::out_peers(uint64_t limit)
|
|||
|
||||
if (m_is_rpc)
|
||||
{
|
||||
if (!m_rpc_client->json_rpc_request(req, res, "out_peers", fail_message.c_str()))
|
||||
if (!m_rpc_client->rpc_request(req, res, "/out_peers", fail_message.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -1281,6 +1281,38 @@ bool t_rpc_command_executor::out_peers(uint64_t limit)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::in_peers(uint64_t limit)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_IN_PEERS::request req;
|
||||
cryptonote::COMMAND_RPC_IN_PEERS::response res;
|
||||
|
||||
epee::json_rpc::error error_resp;
|
||||
|
||||
req.in_peers = limit;
|
||||
|
||||
std::string fail_message = "Unsuccessful";
|
||||
|
||||
if (m_is_rpc)
|
||||
{
|
||||
if (!m_rpc_client->rpc_request(req, res, "/in_peers", fail_message.c_str()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_rpc_server->on_in_peers(req, res) || res.status != CORE_RPC_STATUS_OK)
|
||||
{
|
||||
tools::fail_msg_writer() << make_error(fail_message, res.status);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Max number of in peers set to " << limit << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::start_save_graph()
|
||||
{
|
||||
cryptonote::COMMAND_RPC_START_SAVE_GRAPH::request req;
|
||||
|
|
|
@ -122,7 +122,9 @@ public:
|
|||
bool set_limit(int64_t limit_down, int64_t limit_up);
|
||||
|
||||
bool out_peers(uint64_t limit);
|
||||
|
||||
|
||||
bool in_peers(uint64_t limit);
|
||||
|
||||
bool start_save_graph();
|
||||
|
||||
bool stop_save_graph();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue