Electroneum
rpc_command_executor.h
Go to the documentation of this file.
1 
9 // Copyrights(c) 2017-2018, The Electroneum Project
10 // Copyrights(c) 2014-2017, The Monero Project
11 //
12 // All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without modification, are
15 // permitted provided that the following conditions are met:
16 //
17 // 1. Redistributions of source code must retain the above copyright notice, this list of
18 // conditions and the following disclaimer.
19 //
20 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
21 // of conditions and the following disclaimer in the documentation and/or other
22 // materials provided with the distribution.
23 //
24 // 3. Neither the name of the copyright holder nor the names of its contributors may be
25 // used to endorse or promote products derived from this software without specific
26 // prior written permission.
27 //
28 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
29 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
31 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
36 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
39 
40 #pragma once
41 
42 #include <boost/optional/optional_fwd.hpp>
43 
44 #include "common/common_fwd.h"
45 #include "common/rpc_client.h"
47 #include "rpc/core_rpc_server.h"
48 
49 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
50 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "daemon"
51 
52 namespace daemonize {
53 
55 private:
58  bool m_is_rpc;
59 
60 public:
62  uint32_t ip
63  , uint16_t port
64  , const boost::optional<tools::login>& user
65  , bool is_rpc = true
66  , cryptonote::core_rpc_server* rpc_server = NULL
67  );
68 
70 
71  bool print_peer_list();
72 
73  bool print_peer_list_stats();
74 
75  bool save_blockchain();
76 
77  bool show_hash_rate();
78 
79  bool hide_hash_rate();
80 
81  bool show_difficulty();
82 
83  bool show_status();
84 
85  bool print_connections();
86 
87  bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index);
88 
89  bool set_log_level(int8_t level);
90 
91  bool set_log_categories(const std::string &categories);
92 
93  bool print_height();
94 
95  bool print_block_by_hash(crypto::hash block_hash);
96 
97  bool print_block_by_height(uint64_t height);
98 
99  bool print_transaction(crypto::hash transaction_hash);
100 
101  bool is_key_image_spent(const crypto::key_image &ki);
102 
104 
106 
108 
109  bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, bool testnet, bool do_background_mining = false, bool ignore_battery = false);
110 
111  bool stop_mining();
112 
113  bool stop_daemon();
114 
115  bool print_status();
116 
117  bool get_limit();
118 
119  bool get_limit_up();
120 
121  bool get_limit_down();
122 
123  bool set_limit(int limit);
124 
125  bool set_limit_up(int limit);
126 
127  bool set_limit_down(int limit);
128 
129  bool out_peers(uint64_t limit);
130 
131  bool start_save_graph();
132 
133  bool stop_save_graph();
134 
135  bool hard_fork_info(uint8_t version);
136 
137  bool print_bans();
138 
139  bool ban(const std::string &ip, time_t seconds);
140 
141  bool unban(const std::string &ip);
142 
143  bool flush_txpool(const std::string &txid);
144 
145  bool output_histogram(uint64_t min_count, uint64_t max_count);
146 
147  bool print_coinbase_tx_sum(uint64_t height, uint64_t count);
148 
149  bool alt_chain_info();
150 
151  bool print_blockchain_dynamic_stats(uint64_t nblocks);
152 
153  bool update(const std::string &command);
154 
155  bool relay_tx(const std::string &txid);
156 
157  bool sync_info();
158 };
159 
160 } // namespace daemonize
bool output_histogram(uint64_t min_count, uint64_t max_count)
Definition: rpc_command_executor.cpp:1426
bool save_blockchain()
Definition: rpc_command_executor.cpp:216
bool m_is_rpc
Definition: rpc_command_executor.h:58
bool update(const std::string &command)
Definition: rpc_command_executor.cpp:1652
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index)
Definition: rpc_command_executor.cpp:509
bool relay_tx(const std::string &txid)
Definition: rpc_command_executor.cpp:1704
~t_rpc_command_executor()
Definition: rpc_command_executor.cpp:146
bool print_peer_list()
Definition: rpc_command_executor.cpp:154
bool unban(const std::string &ip)
Definition: rpc_command_executor.cpp:1361
bool print_connections()
Definition: rpc_command_executor.cpp:447
bool set_log_categories(const std::string &categories)
Definition: rpc_command_executor.cpp:580
bool set_log_level(int8_t level)
Definition: rpc_command_executor.cpp:552
uint64_t height
Definition: blockchain.cpp:87
Definition: command_parser_executor.cpp:36
bool alt_chain_info()
Definition: rpc_command_executor.cpp:1499
bool set_limit_down(int limit)
Definition: rpc_command_executor.cpp:1170
bool print_block_by_hash(crypto::hash block_hash)
Definition: rpc_command_executor.cpp:635
bool print_blockchain_dynamic_stats(uint64_t nblocks)
Definition: rpc_command_executor.cpp:1544
bool hard_fork_info(uint8_t version)
Definition: rpc_command_executor.cpp:1260
bool start_mining(cryptonote::account_public_address address, uint64_t num_threads, bool testnet, bool do_background_mining=false, bool ignore_battery=false)
Definition: rpc_command_executor.cpp:1014
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
Definition: rpc_command_executor.cpp:1464
bool out_peers(uint64_t limit)
Definition: rpc_command_executor.cpp:1177
bool set_limit_up(int limit)
Definition: rpc_command_executor.cpp:1156
bool print_height()
Definition: rpc_command_executor.cpp:608
bool stop_mining()
Definition: rpc_command_executor.cpp:1043
bool print_block_by_height(uint64_t height)
Definition: rpc_command_executor.cpp:666
bool print_bans()
Definition: rpc_command_executor.cpp:1293
bool get_limit_up()
Definition: rpc_command_executor.cpp:1149
bool print_transaction_pool_long()
Definition: rpc_command_executor.cpp:796
bool get_limit()
Definition: rpc_command_executor.cpp:1131
bool start_save_graph()
Definition: rpc_command_executor.cpp:1209
bool stop_daemon()
Definition: rpc_command_executor.cpp:1069
bool sync_info()
Definition: rpc_command_executor.cpp:1732
bool get_limit_down()
Definition: rpc_command_executor.cpp:1163
bool stop_save_graph()
Definition: rpc_command_executor.cpp:1235
bool print_transaction_pool_short()
Definition: rpc_command_executor.cpp:880
Definition: rpc_client.h:44
bool ban(const std::string &ip, time_t seconds)
Definition: rpc_command_executor.cpp:1325
bool set_limit(int limit)
Definition: rpc_command_executor.cpp:1140
t_rpc_command_executor(uint32_t ip, uint16_t port, const boost::optional< tools::login > &user, bool is_rpc=true, cryptonote::core_rpc_server *rpc_server=NULL)
Definition: rpc_command_executor.cpp:119
Definition: rpc_command_executor.h:54
uint8_t version
Definition: blockchain.cpp:86
bool print_peer_list_stats()
Definition: rpc_command_executor.cpp:188
Definition: cryptonote_basic.h:406
cryptonote::core_rpc_server * m_rpc_server
Definition: rpc_command_executor.h:57
POD_CLASS key_image
Definition: crypto.h:86
bool print_transaction_pool_stats()
Definition: rpc_command_executor.cpp:929
bool print_status()
Definition: rpc_command_executor.cpp:1111
bool show_difficulty()
Definition: rpc_command_executor.cpp:298
bool is_key_image_spent(const crypto::key_image &ki)
Definition: rpc_command_executor.cpp:760
Definition: core_rpc_server.h:52
bool hide_hash_rate()
Definition: rpc_command_executor.cpp:270
bool print_transaction(crypto::hash transaction_hash)
Definition: rpc_command_executor.cpp:697
bool flush_txpool(const std::string &txid)
Definition: rpc_command_executor.cpp:1397
POD_CLASS hash
Definition: hash.h:46
bool show_hash_rate()
Definition: rpc_command_executor.cpp:243
tools::t_rpc_client * m_rpc_client
Definition: rpc_command_executor.h:56
bool show_status()
Definition: rpc_command_executor.cpp:367