mirror of
https://github.com/monero-project/monero.git
synced 2025-11-21 08:21:43 -05:00
rpc: add new RPCs to get and set limits
This commit is contained in:
parent
72b5f37f58
commit
2e59f6ea50
6 changed files with 219 additions and 53 deletions
|
|
@ -334,17 +334,18 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
|||
if(args.size()==0) {
|
||||
return m_executor.get_limit();
|
||||
}
|
||||
int limit;
|
||||
int64_t limit;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
limit = std::stoll(args[0]);
|
||||
}
|
||||
catch(std::invalid_argument& ex) {
|
||||
catch(const std::invalid_argument& ex) {
|
||||
std::cout << "failed to parse argument" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (limit==-1) limit=128;
|
||||
limit *= 1024;
|
||||
if (limit > 0)
|
||||
limit *= 1024;
|
||||
|
||||
return m_executor.set_limit(limit);
|
||||
return m_executor.set_limit(limit, limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& args)
|
||||
|
|
@ -353,17 +354,18 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg
|
|||
if(args.size()==0) {
|
||||
return m_executor.get_limit_up();
|
||||
}
|
||||
int limit;
|
||||
int64_t limit;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
limit = std::stoll(args[0]);
|
||||
}
|
||||
catch(std::invalid_argument& ex) {
|
||||
catch(const std::invalid_argument& ex) {
|
||||
std::cout << "failed to parse argument" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (limit==-1) limit=128;
|
||||
limit *= 1024;
|
||||
if (limit > 0)
|
||||
limit *= 1024;
|
||||
|
||||
return m_executor.set_limit_up(limit);
|
||||
return m_executor.set_limit(0, limit);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& args)
|
||||
|
|
@ -372,17 +374,18 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a
|
|||
if(args.size()==0) {
|
||||
return m_executor.get_limit_down();
|
||||
}
|
||||
int limit;
|
||||
int64_t limit;
|
||||
try {
|
||||
limit = std::stoi(args[0]);
|
||||
limit = std::stoll(args[0]);
|
||||
}
|
||||
catch(std::invalid_argument& ex) {
|
||||
catch(const std::invalid_argument& ex) {
|
||||
std::cout << "failed to parse argument" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (limit==-1) limit=128;
|
||||
limit *= 1024;
|
||||
if (limit > 0)
|
||||
limit *= 1024;
|
||||
|
||||
return m_executor.set_limit_down(limit);
|
||||
return m_executor.set_limit(limit, 0);
|
||||
}
|
||||
|
||||
bool t_command_parser_executor::out_peers(const std::vector<std::string>& args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue