diff options
Diffstat (limited to 'src/daemon/daemon_commands_handler.h')
-rw-r--r-- | src/daemon/daemon_commands_handler.h | 204 |
1 files changed, 41 insertions, 163 deletions
diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 7baca596d..215cf26de 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -1,7 +1,35 @@ -// Copyright (c) 2012-2013 The Cryptonote developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - +// Copyright (c) 2014-2015, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers + + +/* This isn't a header file, may want to refactor this... */ #pragma once #include <boost/lexical_cast.hpp> @@ -44,10 +72,14 @@ public: m_cmd_binder.set_handler("save", boost::bind(&daemon_cmmands_handler::save, this, _1), "Save blockchain"); m_cmd_binder.set_handler("set_log", boost::bind(&daemon_cmmands_handler::set_log, this, _1), "set_log <level> - Change current log detalization level, <level> is a number 0-4"); m_cmd_binder.set_handler("diff", boost::bind(&daemon_cmmands_handler::diff, this, _1), "Show difficulty"); - m_cmd_binder.set_handler("limit-up", boost::bind(&daemon_cmmands_handler::limit_up, this, _1), "Set upload limit"); - m_cmd_binder.set_handler("limit-down", boost::bind(&daemon_cmmands_handler::limit_down, this, _1), "Set download limit"); - m_cmd_binder.set_handler("limit", boost::bind(&daemon_cmmands_handler::limit, this, _1), "Set download and upload limit"); m_cmd_binder.set_handler("out_peers", boost::bind(&daemon_cmmands_handler::out_peers_limit, this, _1), "Set max limit of out peers"); + m_cmd_binder.set_handler("limit_up", boost::bind(&daemon_cmmands_handler::limit_up, this, _1), "Set upload limit [kB/s]"); + m_cmd_binder.set_handler("limit_down", boost::bind(&daemon_cmmands_handler::limit_down, this, _1), "Set download limit [kB/s]"); + m_cmd_binder.set_handler("limit", boost::bind(&daemon_cmmands_handler::limit, this, _1), "Set download and upload limit [kB/s]"); + m_cmd_binder.set_handler("fast_exit", boost::bind(&daemon_cmmands_handler::fast_exit, this, _1), "Exit"); + m_cmd_binder.set_handler("test_drop_download", boost::bind(&daemon_cmmands_handler::test_drop_download, this, _1), "For network testing, drop downloaded blocks instead checking/adding them to blockchain. Can fake-download blocks very fast."); + m_cmd_binder.set_handler("start_save_graph", boost::bind(&daemon_cmmands_handler::start_save_graph, this, _1), ""); + m_cmd_binder.set_handler("stop_save_graph", boost::bind(&daemon_cmmands_handler::stop_save_graph, this, _1), ""); } bool start_handling() @@ -328,6 +360,8 @@ private: PUSH_WARNINGS DISABLE_GCC_WARNING(maybe-uninitialized) log_space::log_singletone::get_set_log_detalisation_level(true, l); + int otshell_utils_log_level = 100 - (l * 25); + gCurrentLogger.setDebugLevel(otshell_utils_log_level); POP_WARNINGS return true; @@ -492,160 +526,4 @@ POP_WARNINGS m_srv.get_payload_object().get_core().get_miner().stop(); return true; } - //-------------------------------------------------------------------------------- - bool out_peers_limit(const std::vector<std::string>& args) { - if(args.size()!=1) { - std::cout << "Usage: out_peers <number_of_peers>" << ENDL; - return true; - } - - unsigned int limit; - try { - limit = std::stoi(args[0]); - } - - catch(std::invalid_argument& ex) { - _erro("stoi exception"); - return false; - } - - if (m_srv.m_config.m_net_config.connections_count > limit) - { - m_srv.m_config.m_net_config.connections_count = limit; - epee::net_utils::data_logger::get_instance().add_data("peers_limit", m_srv.m_config.m_net_config.connections_count); - if (m_srv.m_current_number_of_out_peers > limit) - { - int count = m_srv.m_current_number_of_out_peers - limit; - m_srv.delete_connections(count); - } - } - else - { - m_srv.m_config.m_net_config.connections_count = limit; - epee::net_utils::data_logger::get_instance().add_data("peers_limit", m_srv.m_config.m_net_config.connections_count); - } - - return true; - } - //-------------------------------------------------------------------------------- - bool limit_up(const std::vector<std::string>& args) - { - if(args.size()!=1) { - std::cout << "Usage: limit_up <speed>" << ENDL; - return false; - } - - int limit; - try { - limit = std::stoi(args[0]); - } - catch(std::invalid_argument& ex) { - return false; - } - - if (limit==-1) { - limit=128; - //this->islimitup=false; - } - - limit *= 1024; - - - //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit ); - epee::net_utils::connection_basic::set_rate_up_limit( limit ); - std::cout << "Set limit-up to " << limit/1024 << " kB/s" << std::endl; - - return true; - } - - //-------------------------------------------------------------------------------- - bool limit_down(const std::vector<std::string>& args) - { - - if(args.size()!=1) { - std::cout << "Usage: limit_down <speed>" << ENDL; - return true; - } - - int limit; - try { - limit = std::stoi(args[0]); - } - - catch(std::invalid_argument& ex) { - return false; - } - - if (limit==-1) { - limit=128; - //this->islimitup=false; - } - - limit *= 1024; - - - //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit ); - epee::net_utils::connection_basic::set_rate_down_limit( limit ); - std::cout << "Set limit-down to " << limit/1024 << " kB/s" << std::endl; - - return true; - } - - //-------------------------------------------------------------------------------- - bool limit(const std::vector<std::string>& args) - { - if(args.size()!=1) { - std::cout << "Usage: limit_down <speed>" << ENDL; - return true; - } - - int limit; - try { - limit = std::stoi(args[0]); - } - catch(std::invalid_argument& ex) { - return false; - } - - if (limit==-1) { - limit=128; - //this->islimitup=false; - } - - limit *= 1024; - - - //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit ); - epee::net_utils::connection_basic::set_rate_down_limit( limit ); - epee::net_utils::connection_basic::set_rate_up_limit( limit ); - std::cout << "Set limit-down to " << limit/1024 << " kB/s" << std::endl; - std::cout << "Set limit-up to " << limit/1024 << " kB/s" << std::endl; - - return true; - } - //-------------------------------------------------------------------------------- - bool fast_exit(const std::vector<std::string>& args) - { - m_srv.get_payload_object().get_core().set_fast_exit(); - m_srv.send_stop_signal(); - return true; - } - //-------------------------------------------------------------------------------- - bool test_drop_download(const std::vector<std::string>& args) - { - m_srv.get_payload_object().get_core().test_drop_download(); - return true; - } - //-------------------------------------------------------------------------------- - bool start_save_graph(const std::vector<std::string>& args) - { - m_srv.set_save_graph(true); - return true; - } - //-------------------------------------------------------------------------------- - bool stop_save_graph(const std::vector<std::string>& args) - { - m_srv.set_save_graph(false); - return true; - } }; |