Monero
rpc_command_executor.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2014-2018, The Monero Project
10 //
11 // All rights reserved.
12 //
13 // Redistribution and use in source and binary forms, with or without modification, are
14 // permitted provided that the following conditions are met:
15 //
16 // 1. Redistributions of source code must retain the above copyright notice, this list of
17 // conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
20 // of conditions and the following disclaimer in the documentation and/or other
21 // materials provided with the distribution.
22 //
23 // 3. Neither the name of the copyright holder nor the names of its contributors may be
24 // used to endorse or promote products derived from this software without specific
25 // prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
30 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
35 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
38 
39 #pragma once
40 
41 #include <boost/optional/optional_fwd.hpp>
42 
43 #include "common/common_fwd.h"
44 #include "common/rpc_client.h"
46 #include "rpc/core_rpc_server.h"
47 
48 #undef MONERO_DEFAULT_LOG_CATEGORY
49 #define MONERO_DEFAULT_LOG_CATEGORY "daemon"
50 
51 namespace daemonize {
52 
54 private:
57  bool m_is_rpc;
58 
59 public:
61  uint32_t ip
62  , uint16_t port
63  , const boost::optional<tools::login>& user
64  , bool is_rpc = true
65  , cryptonote::core_rpc_server* rpc_server = NULL
66  );
67 
69 
70  bool print_peer_list();
71 
72  bool print_peer_list_stats();
73 
74  bool save_blockchain();
75 
76  bool show_hash_rate();
77 
78  bool hide_hash_rate();
79 
80  bool show_difficulty();
81 
82  bool show_status();
83 
84  bool print_connections();
85 
86  bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index);
87 
88  bool set_log_level(int8_t level);
89 
90  bool set_log_categories(const std::string &categories);
91 
92  bool print_height();
93 
94  bool print_block_by_hash(crypto::hash block_hash);
95 
96  bool print_block_by_height(uint64_t height);
97 
98  bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json);
99 
100  bool is_key_image_spent(const crypto::key_image &ki);
101 
103 
105 
107 
108  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);
109 
110  bool stop_mining();
111 
112  bool stop_daemon();
113 
114  bool print_status();
115 
116  bool get_limit();
117 
118  bool get_limit_up();
119 
120  bool get_limit_down();
121 
122  bool set_limit(int64_t limit_down, int64_t limit_up);
123 
124  bool out_peers(uint64_t limit);
125 
126  bool in_peers(uint64_t limit);
127 
128  bool start_save_graph();
129 
130  bool stop_save_graph();
131 
132  bool hard_fork_info(uint8_t version);
133 
134  bool print_bans();
135 
136  bool ban(const std::string &ip, time_t seconds);
137 
138  bool unban(const std::string &ip);
139 
140  bool flush_txpool(const std::string &txid);
141 
142  bool output_histogram(const std::vector<uint64_t> &amounts, uint64_t min_count, uint64_t max_count);
143 
144  bool print_coinbase_tx_sum(uint64_t height, uint64_t count);
145 
146  bool alt_chain_info(const std::string &tip);
147 
148  bool print_blockchain_dynamic_stats(uint64_t nblocks);
149 
150  bool update(const std::string &command);
151 
152  bool relay_tx(const std::string &txid);
153 
154  bool sync_info();
155 };
156 
157 } // namespace daemonize
bool output_histogram(const std::vector< uint64_t > &amounts, uint64_t min_count, uint64_t max_count)
Definition: rpc_command_executor.cpp:1563
bool save_blockchain()
Definition: rpc_command_executor.cpp:219
bool m_is_rpc
Definition: rpc_command_executor.h:57
bool update(const std::string &command)
Definition: rpc_command_executor.cpp:1811
bool print_blockchain_info(uint64_t start_block_index, uint64_t end_block_index)
Definition: rpc_command_executor.cpp:529
bool relay_tx(const std::string &txid)
Definition: rpc_command_executor.cpp:1858
~t_rpc_command_executor()
Definition: rpc_command_executor.cpp:149
bool print_peer_list()
Definition: rpc_command_executor.cpp:157
bool unban(const std::string &ip)
Definition: rpc_command_executor.cpp:1497
bool print_connections()
Definition: rpc_command_executor.cpp:467
bool set_log_categories(const std::string &categories)
Definition: rpc_command_executor.cpp:601
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)
Definition: rpc_command_executor.cpp:1049
bool set_log_level(int8_t level)
Definition: rpc_command_executor.cpp:573
uint64_t height
Definition: blockchain.cpp:88
Definition: command_parser_executor.cpp:37
bool set_limit(int64_t limit_down, int64_t limit_up)
Definition: rpc_command_executor.cpp:1194
bool print_block_by_hash(crypto::hash block_hash)
Definition: rpc_command_executor.cpp:656
bool in_peers(uint64_t limit)
Definition: rpc_command_executor.cpp:1311
bool print_blockchain_dynamic_stats(uint64_t nblocks)
Definition: rpc_command_executor.cpp:1702
bool hard_fork_info(uint8_t version)
Definition: rpc_command_executor.cpp:1396
bool print_coinbase_tx_sum(uint64_t height, uint64_t count)
Definition: rpc_command_executor.cpp:1602
bool out_peers(uint64_t limit)
Definition: rpc_command_executor.cpp:1279
bool print_height()
Definition: rpc_command_executor.cpp:629
bool stop_mining()
Definition: rpc_command_executor.cpp:1078
bool print_block_by_height(uint64_t height)
Definition: rpc_command_executor.cpp:688
bool print_bans()
Definition: rpc_command_executor.cpp:1429
bool get_limit_up()
Definition: rpc_command_executor.cpp:1225
bool print_transaction_pool_long()
Definition: rpc_command_executor.cpp:827
bool get_limit()
Definition: rpc_command_executor.cpp:1166
bool start_save_graph()
Definition: rpc_command_executor.cpp:1343
bool stop_daemon()
Definition: rpc_command_executor.cpp:1104
bool sync_info()
Definition: rpc_command_executor.cpp:1887
bool get_limit_down()
Definition: rpc_command_executor.cpp:1252
bool stop_save_graph()
Definition: rpc_command_executor.cpp:1370
bool print_transaction_pool_short()
Definition: rpc_command_executor.cpp:913
Definition: rpc_client.h:43
bool ban(const std::string &ip, time_t seconds)
Definition: rpc_command_executor.cpp:1461
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:122
Definition: rpc_command_executor.h:53
uint8_t version
Definition: blockchain.cpp:87
bool print_peer_list_stats()
Definition: rpc_command_executor.cpp:191
network_type
Definition: cryptonote_config.h:204
Definition: cryptonote_basic.h:400
cryptonote::core_rpc_server * m_rpc_server
Definition: rpc_command_executor.h:56
POD_CLASS key_image
Definition: crypto.h:89
bool print_transaction_pool_stats()
Definition: rpc_command_executor.cpp:964
bool print_status()
Definition: rpc_command_executor.cpp:1146
bool show_difficulty()
Definition: rpc_command_executor.cpp:301
bool is_key_image_spent(const crypto::key_image &ki)
Definition: rpc_command_executor.cpp:791
Definition: core_rpc_server.h:52
bool hide_hash_rate()
Definition: rpc_command_executor.cpp:273
bool flush_txpool(const std::string &txid)
Definition: rpc_command_executor.cpp:1533
POD_CLASS hash
Definition: hash.h:49
bool show_hash_rate()
Definition: rpc_command_executor.cpp:246
bool alt_chain_info(const std::string &tip)
Definition: rpc_command_executor.cpp:1637
tools::t_rpc_client * m_rpc_client
Definition: rpc_command_executor.h:55
bool show_status()
Definition: rpc_command_executor.cpp:373
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json)
Definition: rpc_command_executor.cpp:720