Electroneum
Loading...
Searching...
No Matches
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 is_public_output_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{}

Member Function Documentation

◆ alt_chain_info()

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

Definition at line 721 of file command_parser_executor.cpp.

722{
723 if(args.size() > 1)
724 {
725 std::cout << "usage: alt_chain_info [block_hash]" << std::endl;
726 return false;
727 }
728
729 return m_executor.alt_chain_info(args.size() == 1 ? args[0] : "");
730}
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 613 of file command_parser_executor.cpp.

614{
615 if (args.size() != 1 && args.size() != 2) return false;
616 std::string ip = args[0];
617 time_t seconds = P2P_IP_BLOCKTIME;
618 if (args.size() > 1)
619 {
620 try
621 {
622 if(args[1] == "-1"){
623 seconds = std::numeric_limits<time_t>::max();
624 }
625 else{
626 seconds = std::stoi(args[1]);
627 }
628 }
629 catch (const std::exception &e)
630 {
631 return false;
632 }
633 if (seconds == 0)
634 {
635 return false;
636 }
637 }
638 return m_executor.ban(ip, seconds);
639}
#define P2P_IP_BLOCKTIME
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 832 of file command_parser_executor.cpp.

833{
834 return m_executor.check_blockchain_pruning();
835}
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 648 of file command_parser_executor.cpp.

649{
650 if (args.size() > 1) return false;
651
652 std::string txid;
653 if (args.size() == 1)
654 {
656 if (!parse_hash256(args[0], hash))
657 {
658 std::cout << "failed to parse tx id" << std::endl;
659 return true;
660 }
661 txid = args[0];
662 }
663 return m_executor.flush_txpool(txid);
664}
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 852 of file command_parser_executor.cpp.

853{
854 if(args.size() != 0) return false;
855
856 return m_executor.generate_ed25519_keypair();
857}
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 585 of file command_parser_executor.cpp.

586{
587 int version;
588 if (args.size() == 0) {
589 version = 0;
590 }
591 else if (args.size() == 1) {
592 try {
593 version = std::stoi(args[0]);
594 }
595 catch(const std::exception& ex) {
596 return false;
597 }
599 return false;
600 }
601 else {
602 return false;
603 }
604 return m_executor.hard_fork_info(version);
605}
uint8_t version
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 caller graph for this function:

◆ in_peers()

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

Definition at line 556 of file command_parser_executor.cpp.

557{
558 if (args.empty()) return false;
559
560 unsigned int limit;
561 try {
562 limit = std::stoi(args[0]);
563 }
564
565 catch(const std::exception& ex) {
566 _erro("stoi exception");
567 return false;
568 }
569
570 return m_executor.in_peers(limit);
571}
#define _erro(x)
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}
void * memcpy(void *a, const void *b, size_t c)
POD_CLASS key_image
Definition crypto.h:105
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_public_output_spent()

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

Definition at line 289 of file command_parser_executor.cpp.

289 {
290 // Check if the number of arguments is exactly 3
291 if (args.size() != 3) {
292 std::cout << "expected: is_public_output_spent <tx hash> <relative output index> <amount without decimal period, eg 0.01 should be 1>" << std::endl;
293 return true;
294 }
295
296 const std::string &tx_hash_str = args[0];
297 const std::string &relative_output_index_str = args[1];
298 const std::string &amount_str = args[2];
299
300 // Parse the transaction hash
301 crypto::hash tx_hash;
302 if (!parse_hash256(tx_hash_str, tx_hash)) {
303 std::cout << "Invalid transaction hash: " << tx_hash_str << std::endl;
304 return true;
305 }
306
307 // Parse the relative output index
308 uint64_t relative_output_index;
309 if (!epee::string_tools::get_xtype_from_string(relative_output_index, relative_output_index_str)) {
310 std::cout << "Invalid relative output index: " << relative_output_index_str << std::endl;
311 return true;
312 }
313
314 // Parse the amount
315 uint64_t amount;
316 if (!epee::string_tools::get_xtype_from_string(amount, amount_str)) {
317 std::cout << "Invalid amount: " << amount_str << std::endl;
318 return true;
319 }
320
321 cryptonote::txin_to_key_public txin;
322 txin.tx_hash = tx_hash;
323 txin.relative_offset = relative_output_index;
324 txin.amount = amount;
325
326 // Assuming m_executor.is_public_output_spent needs these parsed values
327 m_executor.is_public_output_spent(txin);
328
329 return true;
330}
PUSH_WARNINGS bool get_xtype_from_string(OUT XType &val, const std::string &str_id)
unsigned __int64 uint64_t
Definition stdint.h:136
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 466 of file command_parser_executor.cpp.

467{
468 return m_executor.mining_status();
469}
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 539 of file command_parser_executor.cpp.

540{
541 if (args.empty()) return false;
542
543 unsigned int limit;
544 try {
545 limit = std::stoi(args[0]);
546 }
547
548 catch(const std::exception& ex) {
549 _erro("stoi exception");
550 return false;
551 }
552
553 return m_executor.out_peers(limit);
554}
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 666 of file command_parser_executor.cpp.

667{
668 std::vector<uint64_t> amounts;
669 uint64_t min_count = 3;
670 uint64_t max_count = 0;
671 size_t n_raw = 0;
672
673 for (size_t n = 0; n < args.size(); ++n)
674 {
675 if (args[n][0] == '@')
676 {
677 amounts.push_back(boost::lexical_cast<uint64_t>(args[n].c_str() + 1));
678 }
679 else if (n_raw == 0)
680 {
681 min_count = boost::lexical_cast<uint64_t>(args[n]);
682 n_raw++;
683 }
684 else if (n_raw == 1)
685 {
686 max_count = boost::lexical_cast<uint64_t>(args[n]);
687 n_raw++;
688 }
689 else
690 {
691 std::cout << "Invalid syntax: more than two non-amount parameters" << std::endl;
692 return true;
693 }
694 }
695 return m_executor.output_histogram(amounts, min_count, max_count);
696}
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 783 of file command_parser_executor.cpp.

784{
785 if (args.size() != 1)
786 {
787 std::cout << "Exactly one parameter is needed" << std::endl;
788 return false;
789 }
790
791 try
792 {
793 uint64_t nblocks = boost::lexical_cast<uint64_t>(args[0]);
794 if (nblocks < 1)
795 {
796 std::cout << "number of blocks must be greater than 0" << std::endl;
797 return false;
798 }
799 return m_executor.pop_blocks(nblocks);
800 }
801 catch (const boost::bad_lexical_cast&)
802 {
803 std::cout << "number of blocks must be a number greater than 0" << std::endl;
804 }
805 return false;
806}
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
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 732 of file command_parser_executor.cpp.

733{
734 if(args.size() != 1)
735 {
736 std::cout << "Exactly one parameter is needed" << std::endl;
737 return false;
738 }
739
740 uint64_t nblocks = 0;
741 if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]) || nblocks == 0)
742 {
743 std::cout << "wrong number of blocks" << std::endl;
744 return false;
745 }
746
747 return m_executor.print_blockchain_dynamic_stats(nblocks);
748}
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}
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 698 of file command_parser_executor.cpp.

699{
700 if(!args.size())
701 {
702 std::cout << "need block height parameter" << std::endl;
703 return false;
704 }
705 uint64_t height = 0;
706 uint64_t count = 0;
708 {
709 std::cout << "wrong starter block height parameter" << std::endl;
710 return false;
711 }
712 if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
713 {
714 std::cout << "wrong count parameter" << std::endl;
715 return false;
716 }
717
718 return m_executor.print_coinbase_tx_sum(height, count);
719}
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 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 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 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}
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 caller graph for this function:

◆ print_status()

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

Definition at line 478 of file command_parser_executor.cpp.

479{
480 if (!args.empty()) return false;
481
482 return m_executor.print_status();
483}
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}
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 332 of file command_parser_executor.cpp.

333{
334 if (!args.empty()) return false;
335
336 return m_executor.print_transaction_pool_long();
337}
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 339 of file command_parser_executor.cpp.

340{
341 if (!args.empty()) return false;
342
343 return m_executor.print_transaction_pool_short();
344}
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 346 of file command_parser_executor.cpp.

347{
348 if (!args.empty()) return false;
349
350 return m_executor.print_transaction_pool_stats();
351}
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 814 of file command_parser_executor.cpp.

815{
816 if (args.size() > 1) return false;
817
818 if (args.empty() || args[0] != "confirm")
819 {
820 std::cout << "Warning: pruning from within electroneumd will not shrink the database file size." << std::endl;
821 std::cout << "Instead, parts of the file will be marked as free, so the file will not grow" << std::endl;
822 std::cout << "until that newly free space is used up. If you want a smaller file size now," << std::endl;
823 std::cout << "exit electroneumd and run electroneum-blockchain-prune (you will temporarily need more" << std::endl;
824 std::cout << "disk space for the database conversion though). If you are OK with the database" << std::endl;
825 std::cout << "file keeping the same size, re-run this command with the \"confirm\" parameter." << std::endl;
826 return true;
827 }
828
829 return m_executor.prune_blockchain();
830}
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 761 of file command_parser_executor.cpp.

762{
763 if (args.size() != 1) return false;
764
765 std::string txid;
767 if (!parse_hash256(args[0], hash))
768 {
769 std::cout << "failed to parse tx id" << std::endl;
770 return true;
771 }
772 txid = args[0];
773 return m_executor.relay_tx(txid);
774}
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 caller graph for this function:

◆ set_limit()

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

Definition at line 485 of file command_parser_executor.cpp.

486{
487 if(args.size()>1) return false;
488 if(args.size()==0) {
489 return m_executor.get_limit();
490 }
491 int64_t limit;
492 try {
493 limit = std::stoll(args[0]);
494 }
495 catch(const std::exception& ex) {
496 std::cout << "failed to parse argument" << std::endl;
497 return false;
498 }
499
500 return m_executor.set_limit(limit, limit);
501}
signed __int64 int64_t
Definition stdint.h:135
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 521 of file command_parser_executor.cpp.

522{
523 if(args.size()>1) return false;
524 if(args.size()==0) {
525 return m_executor.get_limit_down();
526 }
527 int64_t limit;
528 try {
529 limit = std::stoll(args[0]);
530 }
531 catch(const std::exception& ex) {
532 std::cout << "failed to parse argument" << std::endl;
533 return false;
534 }
535
536 return m_executor.set_limit(limit, 0);
537}
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 503 of file command_parser_executor.cpp.

504{
505 if(args.size()>1) return false;
506 if(args.size()==0) {
507 return m_executor.get_limit_up();
508 }
509 int64_t limit;
510 try {
511 limit = std::stoll(args[0]);
512 }
513 catch(const std::exception& ex) {
514 std::cout << "failed to parse argument" << std::endl;
515 return false;
516 }
517
518 return m_executor.set_limit(0, limit);
519}
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}
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 837 of file command_parser_executor.cpp.

838{
839 if(args.size() != 1) return false;
840
841 std::string key(args[0]);
842
843 bool is_validator_key_valid = std::count_if(key.begin(), key.end(), [](int c) {return !std::isxdigit(c);}) == 0;
844 if(!is_validator_key_valid || key.size() != 64) {
845 std::cout << "Failed to parse validator key (wrong format)." << std::endl;
846 return true;
847 }
848
849 return m_executor.set_validator_key(key);
850}
const char * key
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 607 of file command_parser_executor.cpp.

608{
609 if (!args.empty()) return false;
610 return m_executor.print_bans();
611}
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 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 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 caller graph for this function:

◆ sign_message()

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

Definition at line 859 of file command_parser_executor.cpp.

860{
861 if(args.size() != 2) return false;
862
863 std::string key(args[0]);
864 return m_executor.sign_message(key, args[1]);
865}
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 353 of file command_parser_executor.cpp.

354{
355 if(!args.size())
356 {
357 std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>|auto]" << std::endl;
358 return true;
359 }
360
361 cryptonote::address_parse_info info;
364 {
366 {
368 {
369 bool dnssec_valid;
370 std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
371 [](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid){return addresses[0];});
373 {
375 {
377 {
378 std::cout << "target account address has wrong format" << std::endl;
379 return true;
380 }
381 else
382 {
383 nettype = cryptonote::STAGENET;
384 }
385 }
386 else
387 {
388 nettype = cryptonote::TESTNET;
389 }
390 }
391 }
392 else
393 {
394 nettype = cryptonote::STAGENET;
395 }
396 }
397 else
398 {
399 nettype = cryptonote::TESTNET;
400 }
401 }
402 if (info.is_subaddress)
403 {
404 tools::fail_msg_writer() << "subaddress for mining reward is not yet supported!" << std::endl;
405 return true;
406 }
407 if(nettype != cryptonote::MAINNET)
408 std::cout << "Mining to a " << (nettype == cryptonote::TESTNET ? "testnet" : "stagenet") << " address, make sure this is intentional!" << std::endl;
409 uint64_t threads_count = 1;
410 bool do_background_mining = false;
411 bool ignore_battery = false;
412 if(args.size() > 4)
413 {
414 return false;
415 }
416
417 if(args.size() == 4)
418 {
419 if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
420 {
421 ignore_battery = true;
422 }
423 else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
424 {
425 return false;
426 }
427 }
428
429 if(args.size() >= 3)
430 {
431 if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
432 {
433 do_background_mining = true;
434 }
435 else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
436 {
437 return false;
438 }
439 }
440
441 if(args.size() >= 2)
442 {
443 if (args[1] == "auto" || args[1] == "autodetect")
444 {
445 threads_count = 0;
446 }
447 else
448 {
449 bool ok = epee::string_tools::get_xtype_from_string(threads_count, args[1]);
450 threads_count = (ok && 0 < threads_count) ? threads_count : 1;
451 }
452 }
453
454 m_executor.start_mining(info.address, threads_count, nettype, do_background_mining, ignore_battery);
455
456 return true;
457}
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)
scoped_message_writer fail_msg_writer()
CXA_THROW_INFO_T * info
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 573 of file command_parser_executor.cpp.

574{
575 if (!args.empty()) return false;
576 return m_executor.start_save_graph();
577}
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 471 of file command_parser_executor.cpp.

472{
473 if (!args.empty()) return false;
474
475 return m_executor.stop_daemon();
476}
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 459 of file command_parser_executor.cpp.

460{
461 if (!args.empty()) return false;
462
463 return m_executor.stop_mining();
464}
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 579 of file command_parser_executor.cpp.

580{
581 if (!args.empty()) return false;
582 return m_executor.stop_save_graph();
583}
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 776 of file command_parser_executor.cpp.

777{
778 if (args.size() != 0) return false;
779
780 return m_executor.sync_info();
781}
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 641 of file command_parser_executor.cpp.

642{
643 if (args.size() != 1) return false;
644 std::string ip = args[0];
645 return m_executor.unban(ip);
646}
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 750 of file command_parser_executor.cpp.

751{
752 if(args.size() != 1)
753 {
754 std::cout << "Exactly one parameter is needed: check, download, or update" << std::endl;
755 return false;
756 }
757
758 return m_executor.update(args.front());
759}
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 808 of file command_parser_executor.cpp.

809{
810 std::cout << "Electroneum '" << ELECTRONEUM_RELEASE_NAME << "' (v" << ELECTRONEUM_VERSION_FULL << ")" << std::endl;
811 return true;
812}
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: