Electroneum
cryptonote::rpc::DaemonHandler Class Reference

#include <daemon_handler.h>

Inheritance diagram for cryptonote::rpc::DaemonHandler:
Collaboration diagram for cryptonote::rpc::DaemonHandler:

Public Member Functions

 DaemonHandler (cryptonote::core &c, t_p2p &p2p)
 
 ~DaemonHandler ()
 
void handle (const GetHeight::Request &req, GetHeight::Response &res)
 
void handle (const GetBlocksFast::Request &req, GetBlocksFast::Response &res)
 
void handle (const GetHashesFast::Request &req, GetHashesFast::Response &res)
 
void handle (const GetTransactions::Request &req, GetTransactions::Response &res)
 
void handle (const KeyImagesSpent::Request &req, KeyImagesSpent::Response &res)
 
void handle (const GetTxGlobalOutputIndices::Request &req, GetTxGlobalOutputIndices::Response &res)
 
void handle (const SendRawTx::Request &req, SendRawTx::Response &res)
 
void handle (const SendRawTxHex::Request &req, SendRawTxHex::Response &res)
 
void handle (const StartMining::Request &req, StartMining::Response &res)
 
void handle (const GetInfo::Request &req, GetInfo::Response &res)
 
void handle (const StopMining::Request &req, StopMining::Response &res)
 
void handle (const MiningStatus::Request &req, MiningStatus::Response &res)
 
void handle (const SaveBC::Request &req, SaveBC::Response &res)
 
void handle (const GetBlockHash::Request &req, GetBlockHash::Response &res)
 
void handle (const GetBlockTemplate::Request &req, GetBlockTemplate::Response &res)
 
void handle (const SubmitBlock::Request &req, SubmitBlock::Response &res)
 
void handle (const GetLastBlockHeader::Request &req, GetLastBlockHeader::Response &res)
 
void handle (const GetBlockHeaderByHash::Request &req, GetBlockHeaderByHash::Response &res)
 
void handle (const GetBlockHeaderByHeight::Request &req, GetBlockHeaderByHeight::Response &res)
 
void handle (const GetBlockHeadersByHeight::Request &req, GetBlockHeadersByHeight::Response &res)
 
void handle (const GetBlock::Request &req, GetBlock::Response &res)
 
void handle (const GetPeerList::Request &req, GetPeerList::Response &res)
 
void handle (const SetLogHashRate::Request &req, SetLogHashRate::Response &res)
 
void handle (const SetLogLevel::Request &req, SetLogLevel::Response &res)
 
void handle (const GetTransactionPool::Request &req, GetTransactionPool::Response &res)
 
void handle (const GetConnections::Request &req, GetConnections::Response &res)
 
void handle (const GetBlockHeadersRange::Request &req, GetBlockHeadersRange::Response &res)
 
void handle (const StopDaemon::Request &req, StopDaemon::Response &res)
 
void handle (const StartSaveGraph::Request &req, StartSaveGraph::Response &res)
 
void handle (const StopSaveGraph::Request &req, StopSaveGraph::Response &res)
 
void handle (const HardForkInfo::Request &req, HardForkInfo::Response &res)
 
void handle (const GetBans::Request &req, GetBans::Response &res)
 
void handle (const SetBans::Request &req, SetBans::Response &res)
 
void handle (const FlushTransactionPool::Request &req, FlushTransactionPool::Response &res)
 
void handle (const GetOutputHistogram::Request &req, GetOutputHistogram::Response &res)
 
void handle (const GetOutputKeys::Request &req, GetOutputKeys::Response &res)
 
void handle (const GetRPCVersion::Request &req, GetRPCVersion::Response &res)
 
void handle (const GetFeeEstimate::Request &req, GetFeeEstimate::Response &res)
 
void handle (const GetOutputDistribution::Request &req, GetOutputDistribution::Response &res)
 
std::string handle (const std::string &request)
 
- Public Member Functions inherited from cryptonote::rpc::RpcHandler
 RpcHandler ()
 
virtual ~RpcHandler ()
 

Additional Inherited Members

- Static Public Member Functions inherited from cryptonote::rpc::RpcHandler
static boost::optional< output_distribution_dataget_output_distribution (const std::function< bool(uint64_t, uint64_t, uint64_t, uint64_t &, std::vector< uint64_t > &, uint64_t &)> &f, uint64_t amount, uint64_t from_height, uint64_t to_height, const std::function< crypto::hash(uint64_t)> &get_hash, bool cumulative, uint64_t blockchain_height)
 

Detailed Description

Definition at line 49 of file daemon_handler.h.

Constructor & Destructor Documentation

◆ DaemonHandler()

cryptonote::rpc::DaemonHandler::DaemonHandler ( cryptonote::core c,
t_p2p &  p2p 
)
inline

Definition at line 53 of file daemon_handler.h.

53 : m_core(c), m_p2p(p2p) { }

◆ ~DaemonHandler()

cryptonote::rpc::DaemonHandler::~DaemonHandler ( )
inline

Definition at line 55 of file daemon_handler.h.

55 { }

Member Function Documentation

◆ handle() [1/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetHeight::Request &  req,
GetHeight::Response &  res 
)

Definition at line 45 of file daemon_handler.cpp.

46  {
47  res.height = m_core.get_current_blockchain_height();
48 
49  res.status = Message::STATUS_OK;
50  }
const char * res
Definition: hmac_keccak.cpp:41
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle() [2/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlocksFast::Request &  req,
GetBlocksFast::Response &  res 
)

Definition at line 52 of file daemon_handler.cpp.

53  {
54  std::vector<std::pair<std::pair<blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, blobdata> > > > blocks;
55 
56  if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, blocks, res.current_height, res.start_height, req.prune, true, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
57  {
58  res.status = Message::STATUS_FAILED;
59  res.error_details = "core::find_blockchain_supplement() returned false";
60  return;
61  }
62 
63  res.blocks.resize(blocks.size());
64  res.output_indices.resize(blocks.size());
65 
66  auto it = blocks.begin();
67 
68  uint64_t block_count = 0;
69  while (it != blocks.end())
70  {
71  cryptonote::rpc::block_with_transactions& bwt = res.blocks[block_count];
72 
73  if (!parse_and_validate_block_from_blob(it->first.first, bwt.block))
74  {
75  res.blocks.clear();
76  res.output_indices.clear();
77  res.status = Message::STATUS_FAILED;
78  res.error_details = "failed retrieving a requested block";
79  return;
80  }
81 
82  if (it->second.size() != bwt.block.tx_hashes.size())
83  {
84  res.blocks.clear();
85  res.output_indices.clear();
86  res.status = Message::STATUS_FAILED;
87  res.error_details = "incorrect number of transactions retrieved for block";
88  return;
89  }
90 
91  cryptonote::rpc::block_output_indices& indices = res.output_indices[block_count];
92 
93  // miner tx output indices
94  {
96  if (!m_core.get_tx_outputs_gindexs(get_transaction_hash(bwt.block.miner_tx), tx_indices))
97  {
98  res.status = Message::STATUS_FAILED;
99  res.error_details = "core::get_tx_outputs_gindexs() returned false";
100  return;
101  }
102  indices.push_back(std::move(tx_indices));
103  }
104 
105  auto hash_it = bwt.block.tx_hashes.begin();
106  bwt.transactions.reserve(it->second.size());
107  for (const auto& blob : it->second)
108  {
109  bwt.transactions.emplace_back();
110  if (!parse_and_validate_tx_from_blob(blob.second, bwt.transactions.back()))
111  {
112  res.blocks.clear();
113  res.output_indices.clear();
114  res.status = Message::STATUS_FAILED;
115  res.error_details = "failed retrieving a requested transaction";
116  return;
117  }
118 
120  if (!m_core.get_tx_outputs_gindexs(*hash_it, tx_indices))
121  {
122  res.status = Message::STATUS_FAILED;
123  res.error_details = "core::get_tx_outputs_gindexs() returned false";
124  return;
125  }
126 
127  indices.push_back(std::move(tx_indices));
128  ++hash_it;
129  }
130 
131  it++;
132  block_count++;
133  }
134 
135  res.status = Message::STATUS_OK;
136  }
const char * res
Definition: hmac_keccak.cpp:41
std::vector< crypto::hash > tx_hashes
#define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT
std::vector< tx_output_indices > block_output_indices
std::vector< uint64_t > tx_output_indices
static const char * STATUS_FAILED
Definition: message.h:64
unsigned __int64 uint64_t
Definition: stdint.h:136
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
const T & move(const T &t)
Definition: gtest-port.h:1317
bool get_tx_outputs_gindexs(const crypto::hash &tx_id, std::vector< uint64_t > &indexs) const
gets the global indices for outputs from a given transaction
crypto::hash get_transaction_hash(const transaction &t)
static const char * STATUS_OK
Definition: message.h:62
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp) const
get recent block hashes for a foreign chain
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b, crypto::hash *block_hash)
std::vector< cryptonote::transaction > transactions
Here is the call graph for this function:

◆ handle() [3/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetHashesFast::Request &  req,
GetHashesFast::Response &  res 
)

Definition at line 138 of file daemon_handler.cpp.

139  {
140  res.start_height = req.start_height;
141 
142  auto& chain = m_core.get_blockchain_storage();
143 
144  if (!chain.find_blockchain_supplement(req.known_hashes, res.hashes, res.start_height, res.current_height, false))
145  {
146  res.status = Message::STATUS_FAILED;
147  res.error_details = "Blockchain::find_blockchain_supplement() returned false";
148  return;
149  }
150 
151  res.status = Message::STATUS_OK;
152  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [4/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetTransactions::Request &  req,
GetTransactions::Response &  res 
)

Definition at line 154 of file daemon_handler.cpp.

155  {
156  std::vector<cryptonote::transaction> found_txs_vec;
157  std::vector<crypto::hash> missed_vec;
158 
159  bool r = m_core.get_transactions(req.tx_hashes, found_txs_vec, missed_vec);
160 
161  // TODO: consider fixing core::get_transactions to not hide exceptions
162  if (!r)
163  {
164  res.status = Message::STATUS_FAILED;
165  res.error_details = "core::get_transactions() returned false (exception caught there)";
166  return;
167  }
168 
169  size_t num_found = found_txs_vec.size();
170 
171  std::vector<uint64_t> heights(num_found);
172  std::vector<bool> in_pool(num_found, false);
173  std::vector<crypto::hash> found_hashes(num_found);
174 
175  for (size_t i=0; i < num_found; i++)
176  {
177  found_hashes[i] = get_transaction_hash(found_txs_vec[i]);
178  heights[i] = m_core.get_blockchain_storage().get_db().get_tx_block_height(found_hashes[i]);
179  }
180 
181  // if any missing from blockchain, check in tx pool
182  if (!missed_vec.empty())
183  {
184  std::vector<cryptonote::transaction> pool_txs;
185 
186  m_core.get_pool_transactions(pool_txs);
187 
188  for (const auto& tx : pool_txs)
189  {
191 
192  auto itr = std::find(missed_vec.begin(), missed_vec.end(), h);
193 
194  if (itr != missed_vec.end())
195  {
196  found_hashes.push_back(h);
197  found_txs_vec.push_back(tx);
198  heights.push_back(std::numeric_limits<uint64_t>::max());
199  in_pool.push_back(true);
200  missed_vec.erase(itr);
201  }
202  }
203  }
204 
205  for (size_t i=0; i < found_hashes.size(); i++)
206  {
208  info.height = heights[i];
209  info.in_pool = in_pool[i];
210  info.transaction = std::move(found_txs_vec[i]);
211 
212  res.txs.emplace(found_hashes[i], std::move(info));
213  }
214 
215  res.missed_hashes = std::move(missed_vec);
216  res.status = Message::STATUS_OK;
217  }
const char * res
Definition: hmac_keccak.cpp:41
virtual uint64_t get_tx_block_height(const crypto::hash &h) const =0
fetches the height of a transaction&#39;s block
static const char * STATUS_FAILED
Definition: message.h:64
bool get_pool_transactions(std::vector< transaction > &txs, bool include_unrelayed_txes=true) const
get a list of all transactions in the pool
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:963
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
Blockchain & get_blockchain_storage()
gets the Blockchain instance
const T & move(const T &t)
Definition: gtest-port.h:1317
crypto::hash get_transaction_hash(const transaction &t)
POD_CLASS hash
Definition: hash.h:50
static const char * STATUS_OK
Definition: message.h:62
bool get_transactions(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs) const
Here is the call graph for this function:

◆ handle() [5/40]

void cryptonote::rpc::DaemonHandler::handle ( const KeyImagesSpent::Request &  req,
KeyImagesSpent::Response &  res 
)

Definition at line 219 of file daemon_handler.cpp.

220  {
221  res.spent_status.resize(req.key_images.size(), KeyImagesSpent::STATUS::UNSPENT);
222 
223  std::vector<bool> chain_spent_status;
224  std::vector<bool> pool_spent_status;
225 
226  m_core.are_key_images_spent(req.key_images, chain_spent_status);
227  m_core.are_key_images_spent_in_pool(req.key_images, pool_spent_status);
228 
229  if ((chain_spent_status.size() != req.key_images.size()) || (pool_spent_status.size() != req.key_images.size()))
230  {
231  res.status = Message::STATUS_FAILED;
232  res.error_details = "tx_pool::have_key_images_as_spent() gave vectors of wrong size(s).";
233  return;
234  }
235 
236  for(size_t i=0; i < req.key_images.size(); i++)
237  {
238  if ( chain_spent_status[i] )
239  {
241  }
242  else if ( pool_spent_status[i] )
243  {
244  res.spent_status[i] = KeyImagesSpent::STATUS::SPENT_IN_POOL;
245  }
246  }
247 
248  res.status = Message::STATUS_OK;
249  }
const char * res
Definition: hmac_keccak.cpp:41
bool are_key_images_spent_in_pool(const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const
check if multiple key images are spent in the transaction pool
static const char * STATUS_FAILED
Definition: message.h:64
bool are_key_images_spent(const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const
check if multiple key images are spent
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [6/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetTxGlobalOutputIndices::Request &  req,
GetTxGlobalOutputIndices::Response &  res 
)

Definition at line 251 of file daemon_handler.cpp.

252  {
253  if (!m_core.get_tx_outputs_gindexs(req.tx_hash, res.output_indices))
254  {
255  res.status = Message::STATUS_FAILED;
256  res.error_details = "core::get_tx_outputs_gindexs() returned false";
257  return;
258  }
259 
260  res.status = Message::STATUS_OK;
261 
262  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
bool get_tx_outputs_gindexs(const crypto::hash &tx_id, std::vector< uint64_t > &indexs) const
gets the global indices for outputs from a given transaction
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [7/40]

void cryptonote::rpc::DaemonHandler::handle ( const SendRawTx::Request &  req,
SendRawTx::Response &  res 
)

Definition at line 264 of file daemon_handler.cpp.

265  {
266  handleTxBlob(cryptonote::tx_to_blob(req.tx), req.relay, res);
267  }
const char * res
Definition: hmac_keccak.cpp:41
blobdata tx_to_blob(const transaction &tx)
Here is the call graph for this function:

◆ handle() [8/40]

void cryptonote::rpc::DaemonHandler::handle ( const SendRawTxHex::Request &  req,
SendRawTxHex::Response &  res 
)

Definition at line 269 of file daemon_handler.cpp.

270  {
271  std::string tx_blob;
272  if(!epee::string_tools::parse_hexstr_to_binbuff(req.tx_as_hex, tx_blob))
273  {
274  MERROR("[SendRawTxHex]: Failed to parse tx from hexbuff: " << req.tx_as_hex);
275  res.status = Message::STATUS_FAILED;
276  res.error_details = "Invalid hex";
277  return;
278  }
279  handleTxBlob(tx_blob, req.relay, res);
280  }
const char * res
Definition: hmac_keccak.cpp:41
#define MERROR(x)
Definition: misc_log_ex.h:73
::std::string string
Definition: gtest-port.h:1097
static const char * STATUS_FAILED
Definition: message.h:64
bool parse_hexstr_to_binbuff(const epee::span< const char > s, epee::span< char > &res)
Definition: string_tools.h:92
Here is the call graph for this function:

◆ handle() [9/40]

void cryptonote::rpc::DaemonHandler::handle ( const StartMining::Request &  req,
StartMining::Response &  res 
)

Definition at line 395 of file daemon_handler.cpp.

396  {
398  if(!get_account_address_from_str(info, m_core.get_nettype(), req.miner_address))
399  {
400  res.error_details = "Failed, wrong address";
401  LOG_PRINT_L0(res.error_details);
402  res.status = Message::STATUS_FAILED;
403  return;
404  }
405  if (info.is_subaddress)
406  {
407  res.error_details = "Failed, mining to subaddress isn't supported yet";
408  LOG_PRINT_L0(res.error_details);
409  res.status = Message::STATUS_FAILED;
410  return;
411  }
412 
413  unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4;
414 
415  // if we couldn't detect threads, set it to a ridiculously high number
416  if(concurrency_count == 0)
417  {
418  concurrency_count = 257;
419  }
420 
421  // if there are more threads requested than the hardware supports
422  // then we fail and log that.
423  if(req.threads_count > concurrency_count)
424  {
425  res.error_details = "Failed, too many threads relative to CPU cores.";
426  LOG_PRINT_L0(res.error_details);
427  res.status = Message::STATUS_FAILED;
428  return;
429  }
430 
431  if(!m_core.get_miner().start(info.address, static_cast<size_t>(req.threads_count), req.do_background_mining, req.ignore_battery))
432  {
433  res.error_details = "Failed, mining not started";
434  LOG_PRINT_L0(res.error_details);
435  res.status = Message::STATUS_FAILED;
436  return;
437  }
438  res.status = Message::STATUS_OK;
439  res.error_details = "";
440 
441  }
const char * res
Definition: hmac_keccak.cpp:41
#define LOG_PRINT_L0(x)
Definition: misc_log_ex.h:99
network_type get_nettype() const
get the network type we&#39;re on
static const char * STATUS_FAILED
Definition: message.h:64
bool start(const account_public_address &adr, size_t threads_count, bool do_background=false, bool ignore_battery=false)
Definition: miner.cpp:372
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
miner & get_miner()
gets the miner instance
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [10/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetInfo::Request &  req,
GetInfo::Response &  res 
)

Definition at line 443 of file daemon_handler.cpp.

444  {
445  res.info.height = m_core.get_current_blockchain_height();
446 
447  res.info.target_height = m_core.get_target_blockchain_height();
448 
449  if (res.info.height > res.info.target_height)
450  {
451  res.info.target_height = res.info.height;
452  }
453 
454  auto& chain = m_core.get_blockchain_storage();
455 
456  res.info.wide_difficulty = chain.get_difficulty_for_next_block();
457  res.info.difficulty = (res.info.wide_difficulty & 0xffffffffffffffff).convert_to<uint64_t>();
458 
459  res.info.target = chain.get_difficulty_target();
460 
461  res.info.tx_count = chain.get_total_transactions() - res.info.height; //without coinbase
462 
463  res.info.tx_pool_size = m_core.get_pool_transactions_count();
464 
465  res.info.alt_blocks_count = chain.get_alternative_blocks_count();
466 
467  uint64_t total_conn = m_p2p.get_public_connections_count();
468  res.info.outgoing_connections_count = m_p2p.get_public_outgoing_connections_count();
469  res.info.incoming_connections_count = total_conn - res.info.outgoing_connections_count;
470 
471  res.info.white_peerlist_size = m_p2p.get_public_white_peers_count();
472 
473  res.info.grey_peerlist_size = m_p2p.get_public_gray_peers_count();
474 
475  res.info.mainnet = m_core.get_nettype() == MAINNET;
476  res.info.testnet = m_core.get_nettype() == TESTNET;
477  res.info.stagenet = m_core.get_nettype() == STAGENET;
478  res.info.wide_cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.info.height - 1);
479  res.info.cumulative_difficulty = (res.info.wide_cumulative_difficulty & 0xffffffffffffffff).convert_to<uint64_t>();
480  res.info.block_size_limit = res.info.block_weight_limit = m_core.get_blockchain_storage().get_current_cumulative_block_weight_limit();
481  res.info.block_size_median = res.info.block_weight_median = m_core.get_blockchain_storage().get_current_cumulative_block_weight_median();
482  res.info.start_time = (uint64_t)m_core.get_start_time();
483  res.info.version = ELECTRONEUM_VERSION;
484 
485  res.status = Message::STATUS_OK;
486  res.error_details = "";
487  }
const char * res
Definition: hmac_keccak.cpp:41
uint64_t get_current_cumulative_block_weight_limit() const
gets the block weight limit based on recent blocks
virtual difficulty_type get_block_cumulative_difficulty(const uint64_t &height) const =0
fetch a block&#39;s cumulative difficulty
network_type get_nettype() const
get the network type we&#39;re on
uint64_t get_current_cumulative_block_weight_median() const
gets the block weight median based on recent blocks (same window as for the limit) ...
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
uint64_t get_target_blockchain_height() const
gets the target blockchain height
unsigned __int64 uint64_t
Definition: stdint.h:136
const char *const ELECTRONEUM_VERSION
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:963
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
std::time_t get_start_time() const
gets start_time
Here is the call graph for this function:

◆ handle() [11/40]

void cryptonote::rpc::DaemonHandler::handle ( const StopMining::Request &  req,
StopMining::Response &  res 
)

Definition at line 489 of file daemon_handler.cpp.

490  {
491  if(!m_core.get_miner().stop())
492  {
493  res.error_details = "Failed, mining not stopped";
494  LOG_PRINT_L0(res.error_details);
495  res.status = Message::STATUS_FAILED;
496  return;
497  }
498 
499  res.status = Message::STATUS_OK;
500  res.error_details = "";
501  }
const char * res
Definition: hmac_keccak.cpp:41
#define LOG_PRINT_L0(x)
Definition: misc_log_ex.h:99
static const char * STATUS_FAILED
Definition: message.h:64
miner & get_miner()
gets the miner instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [12/40]

void cryptonote::rpc::DaemonHandler::handle ( const MiningStatus::Request &  req,
MiningStatus::Response &  res 
)

Definition at line 503 of file daemon_handler.cpp.

504  {
505  const cryptonote::miner& lMiner = m_core.get_miner();
506  res.active = lMiner.is_mining();
507  res.is_background_mining_enabled = lMiner.get_is_background_mining_enabled();
508 
509  if ( lMiner.is_mining() ) {
510  res.speed = lMiner.get_speed();
511  res.threads_count = lMiner.get_threads_count();
512  const account_public_address& lMiningAdr = lMiner.get_mining_address();
513  res.address = get_account_address_as_str(m_core.get_nettype(), false, lMiningAdr);
514  }
515 
516  res.status = Message::STATUS_OK;
517  res.error_details = "";
518  }
const char * res
Definition: hmac_keccak.cpp:41
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
network_type get_nettype() const
get the network type we&#39;re on
uint32_t get_threads_count() const
Definition: miner.cpp:368
const account_public_address & get_mining_address() const
Definition: miner.cpp:363
uint64_t get_speed() const
Definition: miner.cpp:428
miner & get_miner()
gets the miner instance
bool get_is_background_mining_enabled() const
Definition: miner.cpp:610
bool is_mining() const
Definition: miner.cpp:358
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [13/40]

void cryptonote::rpc::DaemonHandler::handle ( const SaveBC::Request &  req,
SaveBC::Response &  res 
)

Definition at line 520 of file daemon_handler.cpp.

521  {
523  {
524  res.status = Message::STATUS_FAILED;
525  res.error_details = "Error storing the blockchain";
526  }
527  else
528  {
529  res.status = Message::STATUS_OK;
530  }
531  }
const char * res
Definition: hmac_keccak.cpp:41
bool store_blockchain()
stores the blockchain
Definition: blockchain.cpp:630
static const char * STATUS_FAILED
Definition: message.h:64
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [14/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockHash::Request &  req,
GetBlockHash::Response &  res 
)

Definition at line 533 of file daemon_handler.cpp.

534  {
535  if (m_core.get_current_blockchain_height() <= req.height)
536  {
537  res.hash = crypto::null_hash;
538  res.status = Message::STATUS_FAILED;
539  res.error_details = "height given is higher than current chain height";
540  return;
541  }
542 
543  res.hash = m_core.get_block_id_by_height(req.height);
544 
545  res.status = Message::STATUS_OK;
546  }
const char * res
Definition: hmac_keccak.cpp:41
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block&#39;s hash given a height
static const char * STATUS_FAILED
Definition: message.h:64
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [15/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockTemplate::Request &  req,
GetBlockTemplate::Response &  res 
)

Definition at line 548 of file daemon_handler.cpp.

549  {
550  res.status = Message::STATUS_FAILED;
551  res.error_details = "RPC method not yet implemented.";
552  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [16/40]

void cryptonote::rpc::DaemonHandler::handle ( const SubmitBlock::Request &  req,
SubmitBlock::Response &  res 
)

Definition at line 554 of file daemon_handler.cpp.

555  {
556  res.status = Message::STATUS_FAILED;
557  res.error_details = "RPC method not yet implemented.";
558  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [17/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetLastBlockHeader::Request &  req,
GetLastBlockHeader::Response &  res 
)

Definition at line 560 of file daemon_handler.cpp.

561  {
562  const crypto::hash block_hash = m_core.get_tail_id();
563 
564  if (!getBlockHeaderByHash(block_hash, res.header))
565  {
566  res.status = Message::STATUS_FAILED;
567  res.error_details = "Requested block does not exist";
568  return;
569  }
570 
571  res.status = Message::STATUS_OK;
572  }
const char * res
Definition: hmac_keccak.cpp:41
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
static const char * STATUS_FAILED
Definition: message.h:64
POD_CLASS hash
Definition: hash.h:50
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [18/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockHeaderByHash::Request &  req,
GetBlockHeaderByHash::Response &  res 
)

Definition at line 574 of file daemon_handler.cpp.

575  {
576  if (!getBlockHeaderByHash(req.hash, res.header))
577  {
578  res.status = Message::STATUS_FAILED;
579  res.error_details = "Requested block does not exist";
580  return;
581  }
582 
583  res.status = Message::STATUS_OK;
584  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
static const char * STATUS_OK
Definition: message.h:62

◆ handle() [19/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockHeaderByHeight::Request &  req,
GetBlockHeaderByHeight::Response &  res 
)

Definition at line 586 of file daemon_handler.cpp.

587  {
588  const crypto::hash block_hash = m_core.get_block_id_by_height(req.height);
589 
590  if (!getBlockHeaderByHash(block_hash, res.header))
591  {
592  res.status = Message::STATUS_FAILED;
593  res.error_details = "Requested block does not exist";
594  return;
595  }
596 
597  res.status = Message::STATUS_OK;
598  }
const char * res
Definition: hmac_keccak.cpp:41
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block&#39;s hash given a height
static const char * STATUS_FAILED
Definition: message.h:64
POD_CLASS hash
Definition: hash.h:50
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [20/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockHeadersByHeight::Request &  req,
GetBlockHeadersByHeight::Response &  res 
)

Definition at line 600 of file daemon_handler.cpp.

601  {
602  res.headers.resize(req.heights.size());
603 
604  for (size_t i=0; i < req.heights.size(); i++)
605  {
606  const crypto::hash block_hash = m_core.get_block_id_by_height(req.heights[i]);
607 
608  if (!getBlockHeaderByHash(block_hash, res.headers[i]))
609  {
610  res.status = Message::STATUS_FAILED;
611  res.error_details = "A requested block does not exist";
612  return;
613  }
614  }
615 
616  res.status = Message::STATUS_OK;
617  }
const char * res
Definition: hmac_keccak.cpp:41
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block&#39;s hash given a height
static const char * STATUS_FAILED
Definition: message.h:64
POD_CLASS hash
Definition: hash.h:50
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [21/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlock::Request &  req,
GetBlock::Response &  res 
)

Definition at line 619 of file daemon_handler.cpp.

620  {
621  res.status = Message::STATUS_FAILED;
622  res.error_details = "RPC method not yet implemented.";
623  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [22/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetPeerList::Request &  req,
GetPeerList::Response &  res 
)

Definition at line 625 of file daemon_handler.cpp.

626  {
627  res.status = Message::STATUS_FAILED;
628  res.error_details = "RPC method not yet implemented.";
629  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [23/40]

void cryptonote::rpc::DaemonHandler::handle ( const SetLogHashRate::Request &  req,
SetLogHashRate::Response &  res 
)

Definition at line 631 of file daemon_handler.cpp.

632  {
633  res.status = Message::STATUS_FAILED;
634  res.error_details = "RPC method not yet implemented.";
635  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [24/40]

void cryptonote::rpc::DaemonHandler::handle ( const SetLogLevel::Request &  req,
SetLogLevel::Response &  res 
)

Definition at line 637 of file daemon_handler.cpp.

638  {
639  if (req.level < 0 || req.level > 4)
640  {
641  res.status = Message::STATUS_FAILED;
642  res.error_details = "Error: log level not valid";
643  }
644  else
645  {
646  res.status = Message::STATUS_OK;
647  mlog_set_log_level(req.level);
648  }
649  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
static const char * STATUS_OK
Definition: message.h:62
void mlog_set_log_level(int level)
Definition: mlog.cpp:282
Here is the call graph for this function:

◆ handle() [25/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetTransactionPool::Request &  req,
GetTransactionPool::Response &  res 
)

Definition at line 651 of file daemon_handler.cpp.

652  {
653  bool r = m_core.get_pool_for_rpc(res.transactions, res.key_images);
654 
655  if (!r) res.status = Message::STATUS_FAILED;
656  else res.status = Message::STATUS_OK;
657  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
static const char * STATUS_OK
Definition: message.h:62
bool get_pool_for_rpc(std::vector< cryptonote::rpc::tx_in_pool > &tx_infos, cryptonote::rpc::key_images_with_tx_hashes &key_image_infos) const
get information about all transactions and key images in the pool
Here is the call graph for this function:

◆ handle() [26/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetConnections::Request &  req,
GetConnections::Response &  res 
)

Definition at line 659 of file daemon_handler.cpp.

660  {
661  res.status = Message::STATUS_FAILED;
662  res.error_details = "RPC method not yet implemented.";
663  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [27/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBlockHeadersRange::Request &  req,
GetBlockHeadersRange::Response &  res 
)

Definition at line 665 of file daemon_handler.cpp.

666  {
667  res.status = Message::STATUS_FAILED;
668  res.error_details = "RPC method not yet implemented.";
669  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [28/40]

void cryptonote::rpc::DaemonHandler::handle ( const StopDaemon::Request &  req,
StopDaemon::Response &  res 
)

Definition at line 671 of file daemon_handler.cpp.

672  {
673  res.status = Message::STATUS_FAILED;
674  res.error_details = "RPC method not yet implemented.";
675  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [29/40]

void cryptonote::rpc::DaemonHandler::handle ( const StartSaveGraph::Request &  req,
StartSaveGraph::Response &  res 
)

Definition at line 677 of file daemon_handler.cpp.

678  {
679  res.status = Message::STATUS_FAILED;
680  res.error_details = "RPC method not yet implemented.";
681  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [30/40]

void cryptonote::rpc::DaemonHandler::handle ( const StopSaveGraph::Request &  req,
StopSaveGraph::Response &  res 
)

Definition at line 683 of file daemon_handler.cpp.

684  {
685  res.status = Message::STATUS_FAILED;
686  res.error_details = "RPC method not yet implemented.";
687  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [31/40]

void cryptonote::rpc::DaemonHandler::handle ( const HardForkInfo::Request &  req,
HardForkInfo::Response &  res 
)

Definition at line 689 of file daemon_handler.cpp.

690  {
691  const Blockchain &blockchain = m_core.get_blockchain_storage();
692  uint8_t version = req.version > 0 ? req.version : blockchain.get_ideal_hard_fork_version();
693  res.info.version = blockchain.get_current_hard_fork_version();
694  res.info.enabled = blockchain.get_hard_fork_voting_info(version, res.info.window, res.info.votes, res.info.threshold, res.info.earliest_height, res.info.voting);
695  res.info.state = blockchain.get_hard_fork_state();
696  res.status = Message::STATUS_OK;
697  }
const char * res
Definition: hmac_keccak.cpp:41
unsigned char uint8_t
Definition: stdint.h:124
version
Supported socks variants.
Definition: socks.h:57
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [32/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetBans::Request &  req,
GetBans::Response &  res 
)

Definition at line 699 of file daemon_handler.cpp.

700  {
701  res.status = Message::STATUS_FAILED;
702  res.error_details = "RPC method not yet implemented.";
703  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [33/40]

void cryptonote::rpc::DaemonHandler::handle ( const SetBans::Request &  req,
SetBans::Response &  res 
)

Definition at line 705 of file daemon_handler.cpp.

706  {
707  res.status = Message::STATUS_FAILED;
708  res.error_details = "RPC method not yet implemented.";
709  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [34/40]

void cryptonote::rpc::DaemonHandler::handle ( const FlushTransactionPool::Request &  req,
FlushTransactionPool::Response &  res 
)

Definition at line 711 of file daemon_handler.cpp.

712  {
713  res.status = Message::STATUS_FAILED;
714  res.error_details = "RPC method not yet implemented.";
715  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64

◆ handle() [35/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetOutputHistogram::Request &  req,
GetOutputHistogram::Response &  res 
)

Definition at line 717 of file daemon_handler.cpp.

718  {
719  std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t> > histogram;
720  try
721  {
722  histogram = m_core.get_blockchain_storage().get_output_histogram(req.amounts, req.unlocked, req.recent_cutoff);
723  }
724  catch (const std::exception &e)
725  {
726  res.status = Message::STATUS_FAILED;
727  res.error_details = e.what();
728  return;
729  }
730 
731  res.histogram.clear();
732  res.histogram.reserve(histogram.size());
733  for (const auto &i: histogram)
734  {
735  if (std::get<0>(i.second) >= req.min_count && (std::get<0>(i.second) <= req.max_count || req.max_count == 0))
736  res.histogram.emplace_back(output_amount_count{i.first, std::get<0>(i.second), std::get<1>(i.second), std::get<2>(i.second)});
737  }
738 
739  res.status = Message::STATUS_OK;
740  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_FAILED
Definition: message.h:64
std::map< uint64_t, std::tuple< uint64_t, uint64_t, uint64_t > > get_output_histogram(const std::vector< uint64_t > &amounts, bool unlocked, uint64_t recent_cutoff, uint64_t min_count=0) const
return a histogram of outputs on the blockchain
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [36/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetOutputKeys::Request &  req,
GetOutputKeys::Response &  res 
)

Definition at line 742 of file daemon_handler.cpp.

743  {
744  try
745  {
746  for (const auto& i : req.outputs)
747  {
749  rct::key mask;
750  bool unlocked;
751  m_core.get_blockchain_storage().get_output_key_mask_unlocked(i.amount, i.index, key, mask, unlocked);
752  res.keys.emplace_back(output_key_mask_unlocked{key, mask, unlocked});
753  }
754  }
755  catch (const std::exception& e)
756  {
757  res.status = Message::STATUS_FAILED;
758  res.error_details = e.what();
759  return;
760  }
761 
762  res.status = Message::STATUS_OK;
763  }
const char * res
Definition: hmac_keccak.cpp:41
void get_output_key_mask_unlocked(const uint64_t &amount, const uint64_t &index, crypto::public_key &key, rct::key &mask, bool &unlocked) const
gets an output&#39;s key and unlocked state
const char * key
Definition: hmac_keccak.cpp:39
static const char * STATUS_FAILED
Definition: message.h:64
POD_CLASS public_key
Definition: crypto.h:76
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [37/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetRPCVersion::Request &  req,
GetRPCVersion::Response &  res 
)

Definition at line 765 of file daemon_handler.cpp.

766  {
767  res.version = DAEMON_RPC_VERSION_ZMQ;
768  res.status = Message::STATUS_OK;
769  }
const char * res
Definition: hmac_keccak.cpp:41
static const char * STATUS_OK
Definition: message.h:62

◆ handle() [38/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetFeeEstimate::Request &  req,
GetFeeEstimate::Response &  res 
)

Definition at line 771 of file daemon_handler.cpp.

772  {
773  res.hard_fork_version = m_core.get_blockchain_storage().get_current_hard_fork_version();
774  res.estimated_base_fee = m_core.get_blockchain_storage().get_dynamic_base_fee_estimate(req.num_grace_blocks);
775 
776  if (res.hard_fork_version < HF_VERSION_PER_BYTE_FEE)
777  {
778  res.size_scale = 1024; // per KiB fee
779  res.fee_mask = 1;
780  }
781  else
782  {
783  res.size_scale = 1; // per byte fee
785  }
786  res.status = Message::STATUS_OK;
787  }
const char * res
Definition: hmac_keccak.cpp:41
uint8_t get_current_hard_fork_version() const
gets the current hardfork version in use/voted for
Definition: blockchain.h:825
static uint64_t get_fee_quantization_mask()
get fee quantization mask
uint64_t get_dynamic_base_fee_estimate(uint64_t grace_blocks) const
get dynamic per kB or byte fee estimate for the next few blocks
Blockchain & get_blockchain_storage()
gets the Blockchain instance
static const char * STATUS_OK
Definition: message.h:62
#define HF_VERSION_PER_BYTE_FEE
Here is the call graph for this function:

◆ handle() [39/40]

void cryptonote::rpc::DaemonHandler::handle ( const GetOutputDistribution::Request &  req,
GetOutputDistribution::Response &  res 
)

Definition at line 789 of file daemon_handler.cpp.

790  {
791  try
792  {
793  res.distributions.reserve(req.amounts.size());
794 
795  const uint64_t req_to_height = req.to_height ? req.to_height : (m_core.get_current_blockchain_height() - 1);
796  for (std::uint64_t amount : req.amounts)
797  {
798  auto data = rpc::RpcHandler::get_output_distribution([this](uint64_t amount, uint64_t from, uint64_t to, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) { return m_core.get_output_distribution(amount, from, to, start_height, distribution, base); }, amount, req.from_height, req_to_height, [this](uint64_t height) { return m_core.get_blockchain_storage().get_db().get_block_hash_from_height(height); }, req.cumulative, m_core.get_current_blockchain_height());
799  if (!data)
800  {
801  res.distributions.clear();
802  res.status = Message::STATUS_FAILED;
803  res.error_details = "Failed to get output distribution";
804  return;
805  }
806  res.distributions.push_back(output_distribution{std::move(*data), amount, req.cumulative});
807  }
808  res.status = Message::STATUS_OK;
809  }
810  catch (const std::exception& e)
811  {
812  res.distributions.clear();
813  res.status = Message::STATUS_FAILED;
814  res.error_details = e.what();
815  }
816  }
const char * res
Definition: hmac_keccak.cpp:41
virtual crypto::hash get_block_hash_from_height(const uint64_t &height) const =0
fetch a block&#39;s hash
uint64_t height
Definition: blockchain.cpp:91
static const char * STATUS_FAILED
Definition: message.h:64
bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, uint64_t &start_height, std::vector< uint64_t > &distribution, uint64_t &base) const
gets per block distribution of outputs of a given amount
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
unsigned __int64 uint64_t
Definition: stdint.h:136
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:963
Blockchain & get_blockchain_storage()
gets the Blockchain instance
const T & move(const T &t)
Definition: gtest-port.h:1317
static boost::optional< output_distribution_data > get_output_distribution(const std::function< bool(uint64_t, uint64_t, uint64_t, uint64_t &, std::vector< uint64_t > &, uint64_t &)> &f, uint64_t amount, uint64_t from_height, uint64_t to_height, const std::function< crypto::hash(uint64_t)> &get_hash, bool cumulative, uint64_t blockchain_height)
Definition: rpc_handler.cpp:29
static const char * STATUS_OK
Definition: message.h:62
Here is the call graph for this function:

◆ handle() [40/40]

std::string cryptonote::rpc::DaemonHandler::handle ( const std::string &  request)
virtual

Implements cryptonote::rpc::RpcHandler.

Definition at line 854 of file daemon_handler.cpp.

855  {
856  MDEBUG("Handling RPC request: " << request);
857 
858  Message* resp_message = NULL;
859 
860  try
861  {
862  FullMessage req_full(request, true);
863 
864  rapidjson::Value& req_json = req_full.getMessage();
865 
866  const std::string request_type = req_full.getRequestType();
867 
868  // create correct Message subclass and call handle() on it
869  REQ_RESP_TYPES_MACRO(request_type, GetHeight, req_json, resp_message, handle);
870  REQ_RESP_TYPES_MACRO(request_type, GetBlocksFast, req_json, resp_message, handle);
871  REQ_RESP_TYPES_MACRO(request_type, GetHashesFast, req_json, resp_message, handle);
872  REQ_RESP_TYPES_MACRO(request_type, GetTransactions, req_json, resp_message, handle);
873  REQ_RESP_TYPES_MACRO(request_type, KeyImagesSpent, req_json, resp_message, handle);
874  REQ_RESP_TYPES_MACRO(request_type, GetTxGlobalOutputIndices, req_json, resp_message, handle);
875  REQ_RESP_TYPES_MACRO(request_type, SendRawTx, req_json, resp_message, handle);
876  REQ_RESP_TYPES_MACRO(request_type, SendRawTxHex, req_json, resp_message, handle);
877  REQ_RESP_TYPES_MACRO(request_type, GetInfo, req_json, resp_message, handle);
878  REQ_RESP_TYPES_MACRO(request_type, StartMining, req_json, resp_message, handle);
879  REQ_RESP_TYPES_MACRO(request_type, StopMining, req_json, resp_message, handle);
880  REQ_RESP_TYPES_MACRO(request_type, MiningStatus, req_json, resp_message, handle);
881  REQ_RESP_TYPES_MACRO(request_type, SaveBC, req_json, resp_message, handle);
882  REQ_RESP_TYPES_MACRO(request_type, GetBlockHash, req_json, resp_message, handle);
883  REQ_RESP_TYPES_MACRO(request_type, GetLastBlockHeader, req_json, resp_message, handle);
884  REQ_RESP_TYPES_MACRO(request_type, GetBlockHeaderByHash, req_json, resp_message, handle);
885  REQ_RESP_TYPES_MACRO(request_type, GetBlockHeaderByHeight, req_json, resp_message, handle);
886  REQ_RESP_TYPES_MACRO(request_type, GetBlockHeadersByHeight, req_json, resp_message, handle);
887  REQ_RESP_TYPES_MACRO(request_type, GetPeerList, req_json, resp_message, handle);
888  REQ_RESP_TYPES_MACRO(request_type, SetLogLevel, req_json, resp_message, handle);
889  REQ_RESP_TYPES_MACRO(request_type, GetTransactionPool, req_json, resp_message, handle);
890  REQ_RESP_TYPES_MACRO(request_type, HardForkInfo, req_json, resp_message, handle);
891  REQ_RESP_TYPES_MACRO(request_type, GetOutputHistogram, req_json, resp_message, handle);
892  REQ_RESP_TYPES_MACRO(request_type, GetOutputKeys, req_json, resp_message, handle);
893  REQ_RESP_TYPES_MACRO(request_type, GetRPCVersion, req_json, resp_message, handle);
894  REQ_RESP_TYPES_MACRO(request_type, GetFeeEstimate, req_json, resp_message, handle);
895  REQ_RESP_TYPES_MACRO(request_type, GetOutputDistribution, req_json, resp_message, handle);
896 
897  // if none of the request types matches
898  if (resp_message == NULL)
899  {
900  return BAD_REQUEST(request_type, req_full.getID());
901  }
902 
903  FullMessage resp_full = FullMessage::responseMessage(resp_message, req_full.getID());
904 
905  const std::string response = resp_full.getJson();
906  delete resp_message;
907  resp_message = NULL;
908 
909  MDEBUG("Returning RPC response: " << response);
910 
911  return response;
912  }
913  catch (const std::exception& e)
914  {
915  if (resp_message)
916  {
917  delete resp_message;
918  }
919 
920  return BAD_JSON(e.what());
921  }
922  }
::std::string string
Definition: gtest-port.h:1097
epee::misc_utils::struct_init< response_t > response
std::string BAD_REQUEST(const std::string &request)
Definition: message.cpp:259
#define MDEBUG(x)
Definition: misc_log_ex.h:76
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2116
void handle(const GetHeight::Request &req, GetHeight::Response &res)
#define REQ_RESP_TYPES_MACRO(runtime_str, type, reqjson, resp_message_ptr, handler)
Definition: message.h:39
static FullMessage responseMessage(Message *message)
Definition: message.cpp:226
std::string BAD_JSON(const std::string &error_details)
Definition: message.cpp:281
Here is the call graph for this function:

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