aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-10-02 23:15:22 +0400
committerRiccardo Spagni <ric@spagni.net>2017-10-02 23:15:22 +0400
commit3bf20a77f2fd183f89abf595dd43de7c098d6d28 (patch)
tree4c3af706259fb6c1c68242c8b1f7ecb64484a900 /src/rpc/core_rpc_server.cpp
parentMerge pull request #2467 (diff)
parentrpc: add new RPCs to get and set limits (diff)
downloadmonero-3bf20a77f2fd183f89abf595dd43de7c098d6d28.tar.xz
Merge pull request #2470
2e59f6ea rpc: add new RPCs to get and set limits (MaxXor)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index e814dcc1e..9730cdf46 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -1533,6 +1533,53 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_get_limit(const COMMAND_RPC_GET_LIMIT::request& req, COMMAND_RPC_GET_LIMIT::response& res)
+ {
+ res.limit_down = epee::net_utils::connection_basic::get_rate_down_limit();
+ res.limit_up = epee::net_utils::connection_basic::get_rate_up_limit();
+ res.status = CORE_RPC_STATUS_OK;
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_set_limit(const COMMAND_RPC_SET_LIMIT::request& req, COMMAND_RPC_SET_LIMIT::response& res)
+ {
+ // -1 = reset to default
+ // 0 = do not modify
+
+ if (req.limit_down > 0)
+ {
+ epee::net_utils::connection_basic::set_rate_down_limit(req.limit_down);
+ }
+ else if (req.limit_down < 0)
+ {
+ if (req.limit_down != -1)
+ {
+ res.status = CORE_RPC_ERROR_CODE_WRONG_PARAM;
+ return false;
+ }
+ epee::net_utils::connection_basic::set_rate_down_limit(nodetool::default_limit_down * 1024);
+ }
+
+ if (req.limit_up > 0)
+ {
+ epee::net_utils::connection_basic::set_rate_up_limit(req.limit_up);
+ }
+ else if (req.limit_up < 0)
+ {
+ if (req.limit_up != -1)
+ {
+ res.status = CORE_RPC_ERROR_CODE_WRONG_PARAM;
+ return false;
+ }
+ epee::net_utils::connection_basic::set_rate_up_limit(nodetool::default_limit_up * 1024);
+ }
+
+ res.limit_down = epee::net_utils::connection_basic::get_rate_down_limit();
+ res.limit_up = epee::net_utils::connection_basic::get_rate_up_limit();
+ res.status = CORE_RPC_STATUS_OK;
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
{
// TODO