mirror of
https://github.com/monero-project/monero.git
synced 2026-08-03 01:15:55 -07:00
Merge pull request #5582
fcfcc3a rpc: in/out peers can now return the setting's value (moneromooo-monero)
This commit is contained in:
@@ -494,11 +494,14 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a
|
||||
|
||||
bool t_command_parser_executor::out_peers(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty()) return false;
|
||||
|
||||
unsigned int limit;
|
||||
bool set = false;
|
||||
uint32_t limit = 0;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
if (!args.empty())
|
||||
{
|
||||
limit = std::stoi(args[0]);
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
|
||||
catch(const std::exception& ex) {
|
||||
@@ -506,16 +509,19 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args)
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_executor.out_peers(limit);
|
||||
return m_executor.out_peers(set, limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::in_peers(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty()) return false;
|
||||
|
||||
unsigned int limit;
|
||||
bool set = false;
|
||||
uint32_t limit = 0;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
if (!args.empty())
|
||||
{
|
||||
limit = std::stoi(args[0]);
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
|
||||
catch(const std::exception& ex) {
|
||||
@@ -523,7 +529,7 @@ bool t_command_parser_executor::in_peers(const std::vector<std::string>& args)
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_executor.in_peers(limit);
|
||||
return m_executor.in_peers(set, limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::hard_fork_info(const std::vector<std::string>& args)
|
||||
|
||||
@@ -1466,13 +1466,14 @@ bool t_rpc_command_executor::get_limit_down()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::out_peers(uint64_t limit)
|
||||
bool t_rpc_command_executor::out_peers(bool set, uint32_t limit)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_OUT_PEERS::request req;
|
||||
cryptonote::COMMAND_RPC_OUT_PEERS::response res;
|
||||
|
||||
epee::json_rpc::error error_resp;
|
||||
|
||||
req.set = set;
|
||||
req.out_peers = limit;
|
||||
|
||||
std::string fail_message = "Unsuccessful";
|
||||
@@ -1493,18 +1494,20 @@ bool t_rpc_command_executor::out_peers(uint64_t limit)
|
||||
}
|
||||
}
|
||||
|
||||
tools::msg_writer() << "Max number of out peers set to " << limit << std::endl;
|
||||
const std::string s = res.out_peers == (uint32_t)-1 ? "unlimited" : std::to_string(res.out_peers);
|
||||
tools::msg_writer() << "Max number of out peers set to " << s << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool t_rpc_command_executor::in_peers(uint64_t limit)
|
||||
bool t_rpc_command_executor::in_peers(bool set, uint32_t limit)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_IN_PEERS::request req;
|
||||
cryptonote::COMMAND_RPC_IN_PEERS::response res;
|
||||
|
||||
epee::json_rpc::error error_resp;
|
||||
|
||||
req.set = set;
|
||||
req.in_peers = limit;
|
||||
|
||||
std::string fail_message = "Unsuccessful";
|
||||
@@ -1525,7 +1528,8 @@ bool t_rpc_command_executor::in_peers(uint64_t limit)
|
||||
}
|
||||
}
|
||||
|
||||
tools::msg_writer() << "Max number of in peers set to " << limit << std::endl;
|
||||
const std::string s = res.in_peers == (uint32_t)-1 ? "unlimited" : std::to_string(res.in_peers);
|
||||
tools::msg_writer() << "Max number of in peers set to " << s << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ public:
|
||||
|
||||
bool set_limit(int64_t limit_down, int64_t limit_up);
|
||||
|
||||
bool out_peers(uint64_t limit);
|
||||
bool out_peers(bool set, uint32_t limit);
|
||||
|
||||
bool in_peers(uint64_t limit);
|
||||
bool in_peers(bool set, uint32_t limit);
|
||||
|
||||
bool hard_fork_info(uint8_t version);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user