Electroneum
daemonize::t_command_parser_executor Class Referencefinal

#include <command_parser_executor.h>

Public Member Functions

 t_command_parser_executor (uint32_t ip, uint16_t port, const boost::optional< tools::login > &login, const epee::net_utils::ssl_options_t &ssl_options, bool is_rpc, cryptonote::core_rpc_server *rpc_server=NULL)
 
bool print_peer_list (const std::vector< std::string > &args)
 
bool print_peer_list_stats (const std::vector< std::string > &args)
 
bool save_blockchain (const std::vector< std::string > &args)
 
bool show_hash_rate (const std::vector< std::string > &args)
 
bool hide_hash_rate (const std::vector< std::string > &args)
 
bool show_difficulty (const std::vector< std::string > &args)
 
bool show_status (const std::vector< std::string > &args)
 
bool print_connections (const std::vector< std::string > &args)
 
bool print_blockchain_info (const std::vector< std::string > &args)
 
bool set_log_level (const std::vector< std::string > &args)
 
bool set_log_categories (const std::vector< std::string > &args)
 
bool print_height (const std::vector< std::string > &args)
 
bool print_block (const std::vector< std::string > &args)
 
bool print_transaction (const std::vector< std::string > &args)
 
bool is_key_image_spent (const std::vector< std::string > &args)
 
bool print_transaction_pool_long (const std::vector< std::string > &args)
 
bool print_transaction_pool_short (const std::vector< std::string > &args)
 
bool print_transaction_pool_stats (const std::vector< std::string > &args)
 
bool start_mining (const std::vector< std::string > &args)
 
bool stop_mining (const std::vector< std::string > &args)
 
bool mining_status (const std::vector< std::string > &args)
 
bool stop_daemon (const std::vector< std::string > &args)
 
bool print_status (const std::vector< std::string > &args)
 
bool set_limit (const std::vector< std::string > &args)
 
bool set_limit_up (const std::vector< std::string > &args)
 
bool set_limit_down (const std::vector< std::string > &args)
 
bool out_peers (const std::vector< std::string > &args)
 
bool in_peers (const std::vector< std::string > &args)
 
bool start_save_graph (const std::vector< std::string > &args)
 
bool stop_save_graph (const std::vector< std::string > &args)
 
bool hard_fork_info (const std::vector< std::string > &args)
 
bool show_bans (const std::vector< std::string > &args)
 
bool ban (const std::vector< std::string > &args)
 
bool unban (const std::vector< std::string > &args)
 
bool flush_txpool (const std::vector< std::string > &args)
 
bool output_histogram (const std::vector< std::string > &args)
 
bool print_coinbase_tx_sum (const std::vector< std::string > &args)
 
bool alt_chain_info (const std::vector< std::string > &args)
 
bool print_blockchain_dynamic_stats (const std::vector< std::string > &args)
 
bool update (const std::vector< std::string > &args)
 
bool relay_tx (const std::vector< std::string > &args)
 
bool sync_info (const std::vector< std::string > &args)
 
bool pop_blocks (const std::vector< std::string > &args)
 
bool version (const std::vector< std::string > &args)
 
bool prune_blockchain (const std::vector< std::string > &args)
 
bool check_blockchain_pruning (const std::vector< std::string > &args)
 
bool print_net_stats (const std::vector< std::string > &args)
 
bool set_validator_key (const std::vector< std::string > &args)
 
bool generate_ed25519_keypair (const std::vector< std::string > &args)
 
bool sign_message (const std::vector< std::string > &args)
 

Detailed Description

Definition at line 49 of file command_parser_executor.h.

Constructor & Destructor Documentation

◆ t_command_parser_executor()

daemonize::t_command_parser_executor::t_command_parser_executor ( uint32_t  ip,
uint16_t  port,
const boost::optional< tools::login > &  login,
const epee::net_utils::ssl_options_t ssl_options,
bool  is_rpc,
cryptonote::core_rpc_server rpc_server = NULL 
)

Definition at line 40 of file command_parser_executor.cpp.

48  : m_executor(ip, port, login, ssl_options, is_rpc, rpc_server)
49 {}
boost::endian::big_uint16_t port
Definition: socks.cpp:60
boost::endian::big_uint32_t ip
Definition: socks.cpp:61

Member Function Documentation

◆ alt_chain_info()

bool daemonize::t_command_parser_executor::alt_chain_info ( const std::vector< std::string > &  args)

Definition at line 678 of file command_parser_executor.cpp.

679 {
680  if(args.size() > 1)
681  {
682  std::cout << "usage: alt_chain_info [block_hash]" << std::endl;
683  return false;
684  }
685 
686  return m_executor.alt_chain_info(args.size() == 1 ? args[0] : "");
687 }
bool alt_chain_info(const std::string &tip)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ban()

bool daemonize::t_command_parser_executor::ban ( const std::vector< std::string > &  args)

Definition at line 570 of file command_parser_executor.cpp.

571 {
572  if (args.size() != 1 && args.size() != 2) return false;
573  std::string ip = args[0];
574  time_t seconds = P2P_IP_BLOCKTIME;
575  if (args.size() > 1)
576  {
577  try
578  {
579  if(args[1] == "-1"){
580  seconds = std::numeric_limits<time_t>::max();
581  }
582  else{
583  seconds = std::stoi(args[1]);
584  }
585  }
586  catch (const std::exception &e)
587  {
588  return false;
589  }
590  if (seconds == 0)
591  {
592  return false;
593  }
594  }
595  return m_executor.ban(ip, seconds);
596 }
bool ban(const std::string &ip, time_t seconds)
#define P2P_IP_BLOCKTIME
::std::string string
Definition: gtest-port.h:1097
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_blockchain_pruning()

bool daemonize::t_command_parser_executor::check_blockchain_pruning ( const std::vector< std::string > &  args)

Definition at line 789 of file command_parser_executor.cpp.

790 {
791  return m_executor.check_blockchain_pruning();
792 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush_txpool()

bool daemonize::t_command_parser_executor::flush_txpool ( const std::vector< std::string > &  args)

Definition at line 605 of file command_parser_executor.cpp.

606 {
607  if (args.size() > 1) return false;
608 
609  std::string txid;
610  if (args.size() == 1)
611  {
613  if (!parse_hash256(args[0], hash))
614  {
615  std::cout << "failed to parse tx id" << std::endl;
616  return true;
617  }
618  txid = args[0];
619  }
620  return m_executor.flush_txpool(txid);
621 }
bool flush_txpool(const std::string &txid)
bool parse_hash256(const std::string &str_hash, crypto::hash &hash)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_ed25519_keypair()

bool daemonize::t_command_parser_executor::generate_ed25519_keypair ( const std::vector< std::string > &  args)

Definition at line 809 of file command_parser_executor.cpp.

810 {
811  if(args.size() != 0) return false;
812 
813  return m_executor.generate_ed25519_keypair();
814 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hard_fork_info()

bool daemonize::t_command_parser_executor::hard_fork_info ( const std::vector< std::string > &  args)

Definition at line 542 of file command_parser_executor.cpp.

543 {
544  int version;
545  if (args.size() == 0) {
546  version = 0;
547  }
548  else if (args.size() == 1) {
549  try {
550  version = std::stoi(args[0]);
551  }
552  catch(const std::exception& ex) {
553  return false;
554  }
555  if (version <= 0 || version > 255)
556  return false;
557  }
558  else {
559  return false;
560  }
561  return m_executor.hard_fork_info(version);
562 }
bool version(const std::vector< std::string > &args)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hide_hash_rate()

bool daemonize::t_command_parser_executor::hide_hash_rate ( const std::vector< std::string > &  args)

Definition at line 104 of file command_parser_executor.cpp.

105 {
106  if (!args.empty()) return false;
107 
108  return m_executor.hide_hash_rate();
109 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_peers()

bool daemonize::t_command_parser_executor::in_peers ( const std::vector< std::string > &  args)

Definition at line 513 of file command_parser_executor.cpp.

514 {
515  if (args.empty()) return false;
516 
517  unsigned int limit;
518  try {
519  limit = std::stoi(args[0]);
520  }
521 
522  catch(const std::exception& ex) {
523  _erro("stoi exception");
524  return false;
525  }
526 
527  return m_executor.in_peers(limit);
528 }
#define _erro(x)
Definition: misc_log_ex.h:113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_key_image_spent()

bool daemonize::t_command_parser_executor::is_key_image_spent ( const std::vector< std::string > &  args)

Definition at line 269 of file command_parser_executor.cpp.

270 {
271  if (args.empty())
272  {
273  std::cout << "expected: is_key_image_spent <key_image>" << std::endl;
274  return true;
275  }
276 
277  const std::string& str = args.front();
280  if (parse_hash256(str, hash))
281  {
282  memcpy(&ki, &hash, sizeof(ki));
283  m_executor.is_key_image_spent(ki);
284  }
285 
286  return true;
287 }
bool is_key_image_spent(const crypto::key_image &ki)
void * memcpy(void *a, const void *b, size_t c)
POD_CLASS key_image
Definition: crypto.h:102
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mining_status()

bool daemonize::t_command_parser_executor::mining_status ( const std::vector< std::string > &  args)

Definition at line 423 of file command_parser_executor.cpp.

424 {
425  return m_executor.mining_status();
426 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ out_peers()

bool daemonize::t_command_parser_executor::out_peers ( const std::vector< std::string > &  args)

Definition at line 496 of file command_parser_executor.cpp.

497 {
498  if (args.empty()) return false;
499 
500  unsigned int limit;
501  try {
502  limit = std::stoi(args[0]);
503  }
504 
505  catch(const std::exception& ex) {
506  _erro("stoi exception");
507  return false;
508  }
509 
510  return m_executor.out_peers(limit);
511 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_histogram()

bool daemonize::t_command_parser_executor::output_histogram ( const std::vector< std::string > &  args)

Definition at line 623 of file command_parser_executor.cpp.

624 {
625  std::vector<uint64_t> amounts;
626  uint64_t min_count = 3;
627  uint64_t max_count = 0;
628  size_t n_raw = 0;
629 
630  for (size_t n = 0; n < args.size(); ++n)
631  {
632  if (args[n][0] == '@')
633  {
634  amounts.push_back(boost::lexical_cast<uint64_t>(args[n].c_str() + 1));
635  }
636  else if (n_raw == 0)
637  {
638  min_count = boost::lexical_cast<uint64_t>(args[n]);
639  n_raw++;
640  }
641  else if (n_raw == 1)
642  {
643  max_count = boost::lexical_cast<uint64_t>(args[n]);
644  n_raw++;
645  }
646  else
647  {
648  std::cout << "Invalid syntax: more than two non-amount parameters" << std::endl;
649  return true;
650  }
651  }
652  return m_executor.output_histogram(amounts, min_count, max_count);
653 }
bool output_histogram(const std::vector< uint64_t > &amounts, uint64_t min_count, uint64_t max_count)
unsigned __int64 uint64_t
Definition: stdint.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pop_blocks()

bool daemonize::t_command_parser_executor::pop_blocks ( const std::vector< std::string > &  args)

Definition at line 740 of file command_parser_executor.cpp.

741 {
742  if (args.size() != 1)
743  {
744  std::cout << "Exactly one parameter is needed" << std::endl;
745  return false;
746  }
747 
748  try
749  {
750  uint64_t nblocks = boost::lexical_cast<uint64_t>(args[0]);
751  if (nblocks < 1)
752  {
753  std::cout << "number of blocks must be greater than 0" << std::endl;
754  return false;
755  }
756  return m_executor.pop_blocks(nblocks);
757  }
758  catch (const boost::bad_lexical_cast&)
759  {
760  std::cout << "number of blocks must be a number greater than 0" << std::endl;
761  }
762  return false;
763 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_block()

bool daemonize::t_command_parser_executor::print_block ( const std::vector< std::string > &  args)

Definition at line 198 of file command_parser_executor.cpp.

199 {
200  bool include_hex = false;
201 
202  // Assumes that optional flags come after mandatory argument <transaction_hash>
203  for (unsigned int i = 1; i < args.size(); ++i) {
204  if (args[i] == "+hex")
205  include_hex = true;
206  else
207  {
208  std::cout << "unexpected argument: " << args[i] << std::endl;
209  return true;
210  }
211  }
212  if (args.empty())
213  {
214  std::cout << "expected: print_block (<block_hash> | <block_height>) [+hex]" << std::endl;
215  return false;
216  }
217 
218  const std::string& arg = args.front();
219  try
220  {
221  uint64_t height = boost::lexical_cast<uint64_t>(arg);
222  return m_executor.print_block_by_height(height, include_hex);
223  }
224  catch (const boost::bad_lexical_cast&)
225  {
226  crypto::hash block_hash;
227  if (parse_hash256(arg, block_hash))
228  {
229  return m_executor.print_block_by_hash(block_hash, include_hex);
230  }
231  }
232 
233  return false;
234 }
uint64_t height
Definition: blockchain.cpp:91
bool print_block_by_height(uint64_t height, bool include_hex)
bool print_block_by_hash(crypto::hash block_hash, bool include_hex)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_blockchain_dynamic_stats()

bool daemonize::t_command_parser_executor::print_blockchain_dynamic_stats ( const std::vector< std::string > &  args)

Definition at line 689 of file command_parser_executor.cpp.

690 {
691  if(args.size() != 1)
692  {
693  std::cout << "Exactly one parameter is needed" << std::endl;
694  return false;
695  }
696 
697  uint64_t nblocks = 0;
698  if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]) || nblocks == 0)
699  {
700  std::cout << "wrong number of blocks" << std::endl;
701  return false;
702  }
703 
704  return m_executor.print_blockchain_dynamic_stats(nblocks);
705 }
bool print_blockchain_dynamic_stats(uint64_t nblocks)
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
Definition: string_tools.h:125
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_blockchain_info()

bool daemonize::t_command_parser_executor::print_blockchain_info ( const std::vector< std::string > &  args)

Definition at line 139 of file command_parser_executor.cpp.

140 {
141  if(!args.size())
142  {
143  std::cout << "need block index parameter" << std::endl;
144  return false;
145  }
146  uint64_t start_index = 0;
147  uint64_t end_index = 0;
148  if(!epee::string_tools::get_xtype_from_string(start_index, args[0]))
149  {
150  std::cout << "wrong starter block index parameter" << std::endl;
151  return false;
152  }
153  if(args.size() >1 && !epee::string_tools::get_xtype_from_string(end_index, args[1]))
154  {
155  std::cout << "wrong end block index parameter" << std::endl;
156  return false;
157  }
158 
159  return m_executor.print_blockchain_info(start_index, end_index);
160 }
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_coinbase_tx_sum()

bool daemonize::t_command_parser_executor::print_coinbase_tx_sum ( const std::vector< std::string > &  args)

Definition at line 655 of file command_parser_executor.cpp.

656 {
657  if(!args.size())
658  {
659  std::cout << "need block height parameter" << std::endl;
660  return false;
661  }
662  uint64_t height = 0;
663  uint64_t count = 0;
665  {
666  std::cout << "wrong starter block height parameter" << std::endl;
667  return false;
668  }
669  if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
670  {
671  std::cout << "wrong count parameter" << std::endl;
672  return false;
673  }
674 
675  return m_executor.print_coinbase_tx_sum(height, count);
676 }
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
mdb_size_t count(MDB_cursor *cur)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_connections()

bool daemonize::t_command_parser_executor::print_connections ( const std::vector< std::string > &  args)

Definition at line 125 of file command_parser_executor.cpp.

126 {
127  if (!args.empty()) return false;
128 
129  return m_executor.print_connections();
130 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_height()

bool daemonize::t_command_parser_executor::print_height ( const std::vector< std::string > &  args)

Definition at line 191 of file command_parser_executor.cpp.

192 {
193  if (!args.empty()) return false;
194 
195  return m_executor.print_height();
196 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_net_stats()

bool daemonize::t_command_parser_executor::print_net_stats ( const std::vector< std::string > &  args)

Definition at line 132 of file command_parser_executor.cpp.

133 {
134  if (!args.empty()) return false;
135 
136  return m_executor.print_net_stats();
137 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_peer_list()

bool daemonize::t_command_parser_executor::print_peer_list ( const std::vector< std::string > &  args)

Definition at line 51 of file command_parser_executor.cpp.

52 {
53  if (args.size() > 3)
54  {
55  std::cout << "use: print_pl [white] [gray] [<limit>]" << std::endl;
56  return true;
57  }
58 
59  bool white = false;
60  bool gray = false;
61  size_t limit = 0;
62  for (size_t i = 0; i < args.size(); ++i)
63  {
64  if (args[i] == "white")
65  {
66  white = true;
67  }
68  else if (args[i] == "gray")
69  {
70  gray = true;
71  }
72  else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
73  {
74  std::cout << "unexpected argument: " << args[i] << std::endl;
75  return true;
76  }
77  }
78 
79  const bool print_both = !white && !gray;
80  return m_executor.print_peer_list(white | print_both, gray | print_both, limit);
81 }
bool print_peer_list(bool white=true, bool gray=true, size_t limit=0)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_peer_list_stats()

bool daemonize::t_command_parser_executor::print_peer_list_stats ( const std::vector< std::string > &  args)

Definition at line 83 of file command_parser_executor.cpp.

84 {
85  if (!args.empty()) return false;
86 
87  return m_executor.print_peer_list_stats();
88 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_status()

bool daemonize::t_command_parser_executor::print_status ( const std::vector< std::string > &  args)

Definition at line 435 of file command_parser_executor.cpp.

436 {
437  if (!args.empty()) return false;
438 
439  return m_executor.print_status();
440 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_transaction()

bool daemonize::t_command_parser_executor::print_transaction ( const std::vector< std::string > &  args)

Definition at line 236 of file command_parser_executor.cpp.

237 {
238  bool include_hex = false;
239  bool include_json = false;
240 
241  // Assumes that optional flags come after mandatory argument <transaction_hash>
242  for (unsigned int i = 1; i < args.size(); ++i) {
243  if (args[i] == "+hex")
244  include_hex = true;
245  else if (args[i] == "+json")
246  include_json = true;
247  else
248  {
249  std::cout << "unexpected argument: " << args[i] << std::endl;
250  return true;
251  }
252  }
253  if (args.empty())
254  {
255  std::cout << "expected: print_tx <transaction_hash> [+hex] [+json]" << std::endl;
256  return true;
257  }
258 
259  const std::string& str_hash = args.front();
260  crypto::hash tx_hash;
261  if (parse_hash256(str_hash, tx_hash))
262  {
263  m_executor.print_transaction(tx_hash, include_hex, include_json);
264  }
265 
266  return true;
267 }
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_transaction_pool_long()

bool daemonize::t_command_parser_executor::print_transaction_pool_long ( const std::vector< std::string > &  args)

Definition at line 289 of file command_parser_executor.cpp.

290 {
291  if (!args.empty()) return false;
292 
293  return m_executor.print_transaction_pool_long();
294 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_transaction_pool_short()

bool daemonize::t_command_parser_executor::print_transaction_pool_short ( const std::vector< std::string > &  args)

Definition at line 296 of file command_parser_executor.cpp.

297 {
298  if (!args.empty()) return false;
299 
300  return m_executor.print_transaction_pool_short();
301 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_transaction_pool_stats()

bool daemonize::t_command_parser_executor::print_transaction_pool_stats ( const std::vector< std::string > &  args)

Definition at line 303 of file command_parser_executor.cpp.

304 {
305  if (!args.empty()) return false;
306 
307  return m_executor.print_transaction_pool_stats();
308 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prune_blockchain()

bool daemonize::t_command_parser_executor::prune_blockchain ( const std::vector< std::string > &  args)

Definition at line 771 of file command_parser_executor.cpp.

772 {
773  if (args.size() > 1) return false;
774 
775  if (args.empty() || args[0] != "confirm")
776  {
777  std::cout << "Warning: pruning from within electroneumd will not shrink the database file size." << std::endl;
778  std::cout << "Instead, parts of the file will be marked as free, so the file will not grow" << std::endl;
779  std::cout << "until that newly free space is used up. If you want a smaller file size now," << std::endl;
780  std::cout << "exit electroneumd and run electroneum-blockchain-prune (you will temporarily need more" << std::endl;
781  std::cout << "disk space for the database conversion though). If you are OK with the database" << std::endl;
782  std::cout << "file keeping the same size, re-run this command with the \"confirm\" parameter." << std::endl;
783  return true;
784  }
785 
786  return m_executor.prune_blockchain();
787 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relay_tx()

bool daemonize::t_command_parser_executor::relay_tx ( const std::vector< std::string > &  args)

Definition at line 718 of file command_parser_executor.cpp.

719 {
720  if (args.size() != 1) return false;
721 
722  std::string txid;
724  if (!parse_hash256(args[0], hash))
725  {
726  std::cout << "failed to parse tx id" << std::endl;
727  return true;
728  }
729  txid = args[0];
730  return m_executor.relay_tx(txid);
731 }
bool relay_tx(const std::string &txid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_blockchain()

bool daemonize::t_command_parser_executor::save_blockchain ( const std::vector< std::string > &  args)

Definition at line 90 of file command_parser_executor.cpp.

91 {
92  if (!args.empty()) return false;
93 
94  return m_executor.save_blockchain();
95 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_limit()

bool daemonize::t_command_parser_executor::set_limit ( const std::vector< std::string > &  args)

Definition at line 442 of file command_parser_executor.cpp.

443 {
444  if(args.size()>1) return false;
445  if(args.size()==0) {
446  return m_executor.get_limit();
447  }
448  int64_t limit;
449  try {
450  limit = std::stoll(args[0]);
451  }
452  catch(const std::exception& ex) {
453  std::cout << "failed to parse argument" << std::endl;
454  return false;
455  }
456 
457  return m_executor.set_limit(limit, limit);
458 }
bool set_limit(int64_t limit_down, int64_t limit_up)
signed __int64 int64_t
Definition: stdint.h:135
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_limit_down()

bool daemonize::t_command_parser_executor::set_limit_down ( const std::vector< std::string > &  args)

Definition at line 478 of file command_parser_executor.cpp.

479 {
480  if(args.size()>1) return false;
481  if(args.size()==0) {
482  return m_executor.get_limit_down();
483  }
484  int64_t limit;
485  try {
486  limit = std::stoll(args[0]);
487  }
488  catch(const std::exception& ex) {
489  std::cout << "failed to parse argument" << std::endl;
490  return false;
491  }
492 
493  return m_executor.set_limit(limit, 0);
494 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_limit_up()

bool daemonize::t_command_parser_executor::set_limit_up ( const std::vector< std::string > &  args)

Definition at line 460 of file command_parser_executor.cpp.

461 {
462  if(args.size()>1) return false;
463  if(args.size()==0) {
464  return m_executor.get_limit_up();
465  }
466  int64_t limit;
467  try {
468  limit = std::stoll(args[0]);
469  }
470  catch(const std::exception& ex) {
471  std::cout << "failed to parse argument" << std::endl;
472  return false;
473  }
474 
475  return m_executor.set_limit(0, limit);
476 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_log_categories()

bool daemonize::t_command_parser_executor::set_log_categories ( const std::vector< std::string > &  args)

◆ set_log_level()

bool daemonize::t_command_parser_executor::set_log_level ( const std::vector< std::string > &  args)

Definition at line 162 of file command_parser_executor.cpp.

163 {
164  if(args.size() > 1)
165  {
166  std::cout << "use: set_log [<log_level_number_0-4> | <categories>]" << std::endl;
167  return true;
168  }
169 
170  if (args.empty())
171  {
172  return m_executor.set_log_categories("+");
173  }
174 
175  uint16_t l = 0;
177  {
178  if(4 < l)
179  {
180  std::cout << "wrong number range, use: set_log <log_level_number_0-4>" << std::endl;
181  return true;
182  }
183  return m_executor.set_log_level(l);
184  }
185  else
186  {
187  return m_executor.set_log_categories(args.front());
188  }
189 }
bool set_log_categories(const std::string &categories)
unsigned short uint16_t
Definition: stdint.h:125
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_validator_key()

bool daemonize::t_command_parser_executor::set_validator_key ( const std::vector< std::string > &  args)

Definition at line 794 of file command_parser_executor.cpp.

795 {
796  if(args.size() != 1) return false;
797 
798  std::string key(args[0]);
799 
800  bool is_validator_key_valid = std::count_if(key.begin(), key.end(), [](int c) {return !std::isxdigit(c);}) == 0;
801  if(!is_validator_key_valid || key.size() != 64) {
802  std::cout << "Failed to parse validator key (wrong format)." << std::endl;
803  return true;
804  }
805 
806  return m_executor.set_validator_key(key);
807 }
bool set_validator_key(const std::string &key)
const char * key
Definition: hmac_keccak.cpp:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_bans()

bool daemonize::t_command_parser_executor::show_bans ( const std::vector< std::string > &  args)

Definition at line 564 of file command_parser_executor.cpp.

565 {
566  if (!args.empty()) return false;
567  return m_executor.print_bans();
568 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_difficulty()

bool daemonize::t_command_parser_executor::show_difficulty ( const std::vector< std::string > &  args)

Definition at line 111 of file command_parser_executor.cpp.

112 {
113  if (!args.empty()) return false;
114 
115  return m_executor.show_difficulty();
116 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_hash_rate()

bool daemonize::t_command_parser_executor::show_hash_rate ( const std::vector< std::string > &  args)

Definition at line 97 of file command_parser_executor.cpp.

98 {
99  if (!args.empty()) return false;
100 
101  return m_executor.show_hash_rate();
102 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_status()

bool daemonize::t_command_parser_executor::show_status ( const std::vector< std::string > &  args)

Definition at line 118 of file command_parser_executor.cpp.

119 {
120  if (!args.empty()) return false;
121 
122  return m_executor.show_status();
123 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign_message()

bool daemonize::t_command_parser_executor::sign_message ( const std::vector< std::string > &  args)

Definition at line 816 of file command_parser_executor.cpp.

817 {
818  if(args.size() != 2) return false;
819 
820  std::string key(args[0]);
821  return m_executor.sign_message(key, args[1]);
822 }
bool sign_message(const std::string privateKey, const std::string message)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_mining()

bool daemonize::t_command_parser_executor::start_mining ( const std::vector< std::string > &  args)

Definition at line 310 of file command_parser_executor.cpp.

311 {
312  if(!args.size())
313  {
314  std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>|auto]" << std::endl;
315  return true;
316  }
317 
321  {
323  {
325  {
326  bool dnssec_valid;
327  std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
328  [](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
330  {
332  {
334  {
335  std::cout << "target account address has wrong format" << std::endl;
336  return true;
337  }
338  else
339  {
340  nettype = cryptonote::STAGENET;
341  }
342  }
343  else
344  {
345  nettype = cryptonote::TESTNET;
346  }
347  }
348  }
349  else
350  {
351  nettype = cryptonote::STAGENET;
352  }
353  }
354  else
355  {
356  nettype = cryptonote::TESTNET;
357  }
358  }
359  if (info.is_subaddress)
360  {
361  tools::fail_msg_writer() << "subaddress for mining reward is not yet supported!" << std::endl;
362  return true;
363  }
364  if(nettype != cryptonote::MAINNET)
365  std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << " address, make sure this is intentional!" << std::endl;
366  uint64_t threads_count = 1;
367  bool do_background_mining = false;
368  bool ignore_battery = false;
369  if(args.size() > 4)
370  {
371  return false;
372  }
373 
374  if(args.size() == 4)
375  {
376  if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
377  {
378  ignore_battery = true;
379  }
380  else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
381  {
382  return false;
383  }
384  }
385 
386  if(args.size() >= 3)
387  {
388  if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
389  {
390  do_background_mining = true;
391  }
392  else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
393  {
394  return false;
395  }
396  }
397 
398  if(args.size() >= 2)
399  {
400  if (args[1] == "auto" || args[1] == "autodetect")
401  {
402  threads_count = 0;
403  }
404  else
405  {
406  bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]);
407  threads_count = (ok && 0 < threads_count) ? threads_count : 1;
408  }
409  }
410 
411  m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery);
412 
413  return true;
414 }
bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining=false, bool ignore_battery=false)
bool is_no(const std::string &str)
bool is_yes(const std::string &str)
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
std::string get_account_address_as_str_from_url(const std::string &url, bool &dnssec_valid, std::function< std::string(const std::string &, const std::vector< std::string > &, bool)> dns_confirm)
Definition: dns_utils.cpp:479
scoped_message_writer fail_msg_writer()
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_save_graph()

bool daemonize::t_command_parser_executor::start_save_graph ( const std::vector< std::string > &  args)

Definition at line 530 of file command_parser_executor.cpp.

531 {
532  if (!args.empty()) return false;
533  return m_executor.start_save_graph();
534 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_daemon()

bool daemonize::t_command_parser_executor::stop_daemon ( const std::vector< std::string > &  args)

Definition at line 428 of file command_parser_executor.cpp.

429 {
430  if (!args.empty()) return false;
431 
432  return m_executor.stop_daemon();
433 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_mining()

bool daemonize::t_command_parser_executor::stop_mining ( const std::vector< std::string > &  args)

Definition at line 416 of file command_parser_executor.cpp.

417 {
418  if (!args.empty()) return false;
419 
420  return m_executor.stop_mining();
421 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_save_graph()

bool daemonize::t_command_parser_executor::stop_save_graph ( const std::vector< std::string > &  args)

Definition at line 536 of file command_parser_executor.cpp.

537 {
538  if (!args.empty()) return false;
539  return m_executor.stop_save_graph();
540 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_info()

bool daemonize::t_command_parser_executor::sync_info ( const std::vector< std::string > &  args)

Definition at line 733 of file command_parser_executor.cpp.

734 {
735  if (args.size() != 0) return false;
736 
737  return m_executor.sync_info();
738 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unban()

bool daemonize::t_command_parser_executor::unban ( const std::vector< std::string > &  args)

Definition at line 598 of file command_parser_executor.cpp.

599 {
600  if (args.size() != 1) return false;
601  std::string ip = args[0];
602  return m_executor.unban(ip);
603 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

bool daemonize::t_command_parser_executor::update ( const std::vector< std::string > &  args)

Definition at line 707 of file command_parser_executor.cpp.

708 {
709  if(args.size() != 1)
710  {
711  std::cout << "Exactly one parameter is needed: check, download, or update" << std::endl;
712  return false;
713  }
714 
715  return m_executor.update(args.front());
716 }
bool update(const std::string &command)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ version()

bool daemonize::t_command_parser_executor::version ( const std::vector< std::string > &  args)

Definition at line 765 of file command_parser_executor.cpp.

766 {
767  std::cout << "Electroneum '" << ELECTRONEUM_RELEASE_NAME << "' (v" << ELECTRONEUM_VERSION_FULL << ")" << std::endl;
768  return true;
769 }
const char *const ELECTRONEUM_RELEASE_NAME
const char *const ELECTRONEUM_VERSION_FULL
Here is the caller graph for this function:

The documentation for this class was generated from the following files: