Monero
daemon_handler.h
Go to the documentation of this file.
1 // Copyright (c) 2017-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
30 
31 #include "byte_slice.h"
32 #include "daemon_messages.h"
33 #include "daemon_rpc_version.h"
34 #include "rpc_handler.h"
37 #include "p2p/net_node.h"
38 
39 namespace
40 {
42 } // anonymous namespace
43 
44 namespace cryptonote
45 {
46 
47 namespace rpc
48 {
49 
50 class DaemonHandler : public RpcHandler
51 {
52  public:
53 
55 
57 
58  void handle(const GetHeight::Request& req, GetHeight::Response& res);
59 
60  void handle(const GetBlocksFast::Request& req, GetBlocksFast::Response& res);
61 
62  void handle(const GetHashesFast::Request& req, GetHashesFast::Response& res);
63 
64  void handle(const GetTransactions::Request& req, GetTransactions::Response& res);
65 
66  void handle(const KeyImagesSpent::Request& req, KeyImagesSpent::Response& res);
67 
68  void handle(const GetTxGlobalOutputIndices::Request& req, GetTxGlobalOutputIndices::Response& res);
69 
70  void handle(const SendRawTx::Request& req, SendRawTx::Response& res);
71 
72  void handle(const SendRawTxHex::Request& req, SendRawTxHex::Response& res);
73 
74  void handle(const StartMining::Request& req, StartMining::Response& res);
75 
76  void handle(const GetInfo::Request& req, GetInfo::Response& res);
77 
78  void handle(const StopMining::Request& req, StopMining::Response& res);
79 
80  void handle(const MiningStatus::Request& req, MiningStatus::Response& res);
81 
82  void handle(const SaveBC::Request& req, SaveBC::Response& res);
83 
84  void handle(const GetBlockHash::Request& req, GetBlockHash::Response& res);
85 
86  void handle(const GetBlockTemplate::Request& req, GetBlockTemplate::Response& res);
87 
88  void handle(const SubmitBlock::Request& req, SubmitBlock::Response& res);
89 
90  void handle(const GetLastBlockHeader::Request& req, GetLastBlockHeader::Response& res);
91 
92  void handle(const GetBlockHeaderByHash::Request& req, GetBlockHeaderByHash::Response& res);
93 
94  void handle(const GetBlockHeaderByHeight::Request& req, GetBlockHeaderByHeight::Response& res);
95 
96  void handle(const GetBlockHeadersByHeight::Request& req, GetBlockHeadersByHeight::Response& res);
97 
98  void handle(const GetBlock::Request& req, GetBlock::Response& res);
99 
100  void handle(const GetPeerList::Request& req, GetPeerList::Response& res);
101 
102  void handle(const SetLogHashRate::Request& req, SetLogHashRate::Response& res);
103 
104  void handle(const SetLogLevel::Request& req, SetLogLevel::Response& res);
105 
106  void handle(const GetTransactionPool::Request& req, GetTransactionPool::Response& res);
107 
108  void handle(const GetConnections::Request& req, GetConnections::Response& res);
109 
110  void handle(const GetBlockHeadersRange::Request& req, GetBlockHeadersRange::Response& res);
111 
112  void handle(const StopDaemon::Request& req, StopDaemon::Response& res);
113 
114  void handle(const StartSaveGraph::Request& req, StartSaveGraph::Response& res);
115 
116  void handle(const StopSaveGraph::Request& req, StopSaveGraph::Response& res);
117 
118  void handle(const HardForkInfo::Request& req, HardForkInfo::Response& res);
119 
120  void handle(const GetBans::Request& req, GetBans::Response& res);
121 
122  void handle(const SetBans::Request& req, SetBans::Response& res);
123 
124  void handle(const FlushTransactionPool::Request& req, FlushTransactionPool::Response& res);
125 
126  void handle(const GetOutputHistogram::Request& req, GetOutputHistogram::Response& res);
127 
128  void handle(const GetOutputKeys::Request& req, GetOutputKeys::Response& res);
129 
130  void handle(const GetRPCVersion::Request& req, GetRPCVersion::Response& res);
131 
132  void handle(const GetFeeEstimate::Request& req, GetFeeEstimate::Response& res);
133 
134  void handle(const GetOutputDistribution::Request& req, GetOutputDistribution::Response& res);
135 
136  epee::byte_slice handle(std::string&& request) override final;
137 
138  private:
139 
141 
142  void handleTxBlob(std::string&& tx_blob, bool relay, SendRawTx::Response& res);
143 
145  t_p2p& m_p2p;
146 };
147 
148 } // namespace rpc
149 
150 } // namespace cryptonote
const char * res
Definition: hmac_keccak.cpp:42
cryptonote::core & m_core
Definition: daemon_handler.h:144
SendRawTx::Response Response
Definition: daemon_messages.h:181
::std::string string
Definition: gtest-port.h:1097
Definition: rpc_handler.h:52
Definition: message_data_structs.h:160
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
bool getBlockHeaderByHash(const crypto::hash &hash_in, cryptonote::rpc::BlockHeaderResponse &response)
Definition: daemon_handler.cpp:895
t_p2p & m_p2p
Definition: daemon_handler.h:145
rpc
Definition: console.py:53
void handle(const GetHeight::Request &req, GetHeight::Response &res)
Definition: daemon_handler.cpp:120
~DaemonHandler()
Definition: daemon_handler.h:56
handles core cryptonote functionality
Definition: cryptonote_core.h:86
Definition: byte_slice.h:68
This is the original cryptonote protocol network-events handler, modified by us.
Definition: p2p.py:1
Definition: daemon_handler.h:50
POD_CLASS hash
Definition: hash.h:49
DaemonHandler(cryptonote::core &c, t_p2p &p2p)
Definition: daemon_handler.cpp:112
void handleTxBlob(std::string &&tx_blob, bool relay, SendRawTx::Response &res)
Definition: daemon_handler.cpp:362
c
Definition: pymoduletest.py:79
Definition: net_node.h:128