30 #include <boost/algorithm/string.hpp> 36 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 37 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "daemon" 41 namespace p = std::placeholders;
46 ,
const boost::optional<tools::login>& login
51 : m_parser(
ip,
port, login, ssl_options, is_rpc, rpc_server)
57 , std::bind(&t_command_server::help,
this, p::_1)
59 ,
"Show the help section or the documentation about a <command>." 64 ,
"Print the local blockchain height." 69 ,
"print_pl [white] [gray] [<limit>]" 70 ,
"Print the current peer list." 75 ,
"Print the peer list statistics." 80 ,
"Print the current connections." 85 ,
"Print network statistics." 90 ,
"print_bc <begin_height> [<end_height>]" 91 ,
"Print the blockchain info in a given blocks range." 96 ,
"print_block <block_hash> | <block_height>" 97 ,
"Print a given block." 102 ,
"print_tx <transaction_hash> [+hex] [+json]" 103 ,
"Print a given transaction." 108 ,
"is_key_image_spent <key_image>" 109 ,
"Print whether a given key image is in the spent key images set." 112 "is_public_output_spent" 114 ,
"is_public_output_spent <tx hash> <relative output index> <amount without decimal period, eg 0.01 should be 1>" 115 ,
"Print whether a given public output has been spent in the pool or on the blockchain." 120 ,
"start_mining <addr> [<threads>|auto] [do_background_mining] [ignore_battery]" 121 ,
"Start mining for specified address. Defaults to 1 thread and no background mining. Use \"auto\" to autodetect optimal number of threads." 131 ,
"Show current mining status." 136 ,
"Print the transaction pool using a long format." 141 ,
"Print transaction pool using a short format." 146 ,
"Print the transaction pool's statistics." 151 ,
"Start showing the current hash rate." 156 ,
"Stop showing the hash rate." 161 ,
"Save the blockchain." 166 ,
"set_log <level>|<{+,-,}categories>" 167 ,
"Change the current log level/categories where <level> is a number 0-4." 172 ,
"Show the current difficulty." 177 ,
"Show the current status." 192 ,
"Print the current daemon status." 198 ,
"Get or set the download and upload limit." 203 ,
"limit_up [<kB/s>]" 204 ,
"Get or set the upload limit." 209 ,
"limit_down [<kB/s>]" 210 ,
"Get or set the download limit." 215 ,
"out_peers <max_number>" 216 ,
"Set the <max_number> of out peers." 221 ,
"in_peers <max_number>" 222 ,
"Set the <max_number> of in peers." 227 ,
"Start save data for dr electroneum" 232 ,
"Stop save data for dr electroneum" 237 ,
"Print the hard fork voting information." 242 ,
"Show the currently banned IPs." 247 ,
"ban <IP> [<seconds>]" 248 ,
"Ban a given <IP> for a given amount of <seconds>. Seconds = (-1) will result in a perm ban" 254 ,
"Unban a given <IP>." 259 ,
"flush_txpool [<txid>]" 260 ,
"Flush a transaction from the tx pool by its <txid>, or the whole tx pool." 265 ,
"output_histogram [@<amount>] <min_count> [<max_count>]" 266 ,
"Print the output histogram of outputs." 269 "print_coinbase_tx_sum" 271 ,
"print_coinbase_tx_sum <start_height> [<block_count>]" 272 ,
"Print the sum of coinbase transactions." 277 ,
"alt_chain_info [blockhash]" 278 ,
"Print the information about alternative chains." 283 ,
"bc_dyn_stats <last_block_count>" 284 ,
"Print the information about current blockchain dynamic state." 289 ,
"update (check|download)" 290 ,
"Check if an update is available, optionally downloads it if there is. Updating is not yet implemented." 296 ,
"Relay a given transaction by its <txid>." 301 ,
"Print information about the blockchain sync state." 306 ,
"pop_blocks <nblocks>" 307 ,
"Remove blocks from end of blockchain" 312 ,
"Print version information." 317 ,
"Prune the blockchain." 320 "check_blockchain_pruning" 322 ,
"Check the blockchain pruning." 327 ,
"Set validator private key to be used when signing mined blocks. <validator_key>" 330 "generate_ed25519_keypair" 332 ,
"Generate ED25519-Donna keypair." 337 ,
"Sign a message using ED25519-Donna private key. Usage: <private_key> <message>" 351 help(std::vector<std::string>());
358 if (m_is_rpc)
return false;
360 m_command_lookup.
start_handling(
"", get_commands_str(), exit_handler);
367 if (m_is_rpc)
return;
372 bool t_command_server::help(
const std::vector<std::string>& args)
376 std::cout << get_commands_str() << std::endl;
380 std::cout << get_command_usage(args) << std::endl;
387 std::stringstream ss;
389 ss <<
"Commands: " << std::endl;
391 boost::replace_all(usage,
"\n",
"\n ");
392 usage.insert(0,
" ");
393 ss << usage << std::endl;
397 std::string t_command_server::get_command_usage(
const std::vector<std::string> &args)
399 std::pair<std::string, std::string> documentation = m_command_lookup.
get_documentation(args);
400 std::stringstream ss;
401 if(documentation.first.empty())
403 ss <<
"Unknown command: " << args.front() << std::endl;
407 std::string usage = documentation.second.empty() ? args.front() : documentation.first;
408 std::string description = documentation.second.empty() ? documentation.first : documentation.second;
409 usage.insert(0,
" ");
410 ss <<
"Command usage: " << std::endl << usage << std::endl << std::endl;
411 boost::replace_all(description,
"\n",
"\n ");
412 description.insert(0,
" ");
413 ss <<
"Command description: " << std::endl << description << std::endl;
const char *const ELECTRONEUM_RELEASE_NAME
bool start_mining(const std::vector< std::string > &args)
bool stop_save_graph(const std::vector< std::string > &args)
bool show_status(const std::vector< std::string > &args)
bool print_transaction_pool_long(const std::vector< std::string > &args)
bool show_bans(const std::vector< std::string > &args)
bool flush_txpool(const std::vector< std::string > &args)
bool print_connections(const std::vector< std::string > &args)
bool hide_hash_rate(const std::vector< std::string > &args)
t_command_server(uint32_t ip, uint16_t port, const boost::optional< tools::login > &login, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
bool print_transaction_pool_stats(const std::vector< std::string > &args)
bool print_transaction_pool_short(const std::vector< std::string > &args)
void set_handler(const std::string &cmd, const callback &hndlr, const std::string &usage="", const std::string &description="")
bool unban(const std::vector< std::string > &args)
bool print_block(const std::vector< std::string > &args)
bool set_limit_up(const std::vector< std::string > &args)
bool print_transaction(const std::vector< std::string > &args)
bool sign_message(const std::vector< std::string > &args)
bool process_command_str(const std::string &cmd)
bool print_net_stats(const std::vector< std::string > &args)
bool stop_daemon(const std::vector< std::string > &args)
bool stop_mining(const std::vector< std::string > &args)
bool version(const std::vector< std::string > &args)
const char *const ELECTRONEUM_VERSION_FULL
bool hard_fork_info(const std::vector< std::string > &args)
bool relay_tx(const std::vector< std::string > &args)
bool set_validator_key(const std::vector< std::string > &args)
std::pair< std::string, std::string > get_documentation(const std::vector< std::string > &cmd)
bool ban(const std::vector< std::string > &args)
bool process_command_str(const std::string &cmd)
bool print_coinbase_tx_sum(const std::vector< std::string > &args)
bool print_status(const std::vector< std::string > &args)
bool output_histogram(const std::vector< std::string > &args)
bool set_log_level(const std::vector< std::string > &args)
bool generate_ed25519_keypair(const std::vector< std::string > &args)
bool print_peer_list_stats(const std::vector< std::string > &args)
bool set_limit_down(const std::vector< std::string > &args)
bool is_public_output_spent(const std::vector< std::string > &args)
bool start_handling(std::function< void(void)> exit_handler=NULL)
boost::endian::big_uint32_t ip
boost::endian::big_uint16_t port
bool show_difficulty(const std::vector< std::string > &args)
bool start_handling(std::function< std::string(void)> prompt, const std::string &usage_string="", std::function< void(void)> exit_handler=NULL)
bool update(const std::vector< std::string > &args)
bool alt_chain_info(const std::vector< std::string > &args)
bool print_blockchain_info(const std::vector< std::string > &args)
bool in_peers(const std::vector< std::string > &args)
bool show_hash_rate(const std::vector< std::string > &args)
bool pop_blocks(const std::vector< std::string > &args)
bool print_peer_list(const std::vector< std::string > &args)
bool process_command_vec(const std::vector< std::string > &cmd)
bool check_blockchain_pruning(const std::vector< std::string > &args)
bool prune_blockchain(const std::vector< std::string > &args)
bool process_command_vec(const std::vector< std::string > &cmd)
bool set_limit(const std::vector< std::string > &args)
bool mining_status(const std::vector< std::string > &args)
bool sync_info(const std::vector< std::string > &args)
bool start_save_graph(const std::vector< std::string > &args)
bool print_blockchain_dynamic_stats(const std::vector< std::string > &args)
bool out_peers(const std::vector< std::string > &args)
bool save_blockchain(const std::vector< std::string > &args)
bool is_key_image_spent(const std::vector< std::string > &args)
bool print_height(const std::vector< std::string > &args)