diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-10-15 18:38:12 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-10-15 18:38:12 +0200 |
commit | 3eac7ab94f3483857e0edea4ce06c81dba2a6b06 (patch) | |
tree | 4d911ebfd2e03be388e8302aa7b5e61fa03fc2c7 /src/rpc/core_rpc_server.cpp | |
parent | Merge pull request #2586 (diff) | |
parent | rpc: out_peers now works again (diff) | |
download | monero-3eac7ab94f3483857e0edea4ce06c81dba2a6b06.tar.xz |
Merge pull request #2587
cba34494 rpc: out_peers now works again (moneromooo-monero)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index da02e15a1..9095aacae 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1596,21 +1596,13 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res) { - // TODO - /*if (m_p2p.get_outgoing_connections_count() > req.out_peers) - { - m_p2p.m_config.m_net_config.connections_count = req.out_peers; - if (m_p2p.get_outgoing_connections_count() > req.out_peers) - { - int count = m_p2p.get_outgoing_connections_count() - req.out_peers; - m_p2p.delete_connections(count); - } - } - - else - m_p2p.m_config.m_net_config.connections_count = req.out_peers; - */ - return true; + size_t n_connections = m_p2p.get_outgoing_connections_count(); + size_t n_delete = (n_connections > req.out_peers) ? n_connections - req.out_peers : 0; + m_p2p.m_config.m_net_config.connections_count = req.out_peers; + if (n_delete) + m_p2p.delete_connections(n_delete); + res.status = CORE_RPC_STATUS_OK; + return true; } //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res) |