From 412da636225f32ba62bdba7e3ed0281dcea08b05 Mon Sep 17 00:00:00 2001 From: Dion Ahmetaj Date: Mon, 10 Oct 2016 15:45:51 -0400 Subject: [PATCH 1/4] added print_coinbase_tx_sum option --- src/cryptonote_core/cryptonote_core.cpp | 14 ++++ src/cryptonote_core/cryptonote_core.h | 9 ++- src/daemon/command_parser_executor.cpp | 42 +++++++++--- src/daemon/command_parser_executor.h | 20 +++--- src/daemon/command_server.cpp | 17 +++-- src/daemon/rpc_command_executor.cpp | 67 ++++++++++++++----- src/daemon/rpc_command_executor.h | 20 +++--- src/rpc/core_rpc_server.cpp | 26 +++++--- src/rpc/core_rpc_server.h | 36 ++++++----- src/rpc/core_rpc_server_commands_defs.h | 86 ++++++++++++++++--------- 10 files changed, 227 insertions(+), 110 deletions(-) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 149fb09df..b8bceb51c 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -616,6 +616,20 @@ namespace cryptonote return true; } //----------------------------------------------------------------------------------------------- + uint64_t core::get_coinbase_tx_sum(const uint64_t start_height, const uint64_t end_height) + { + std::list blocks; + uint64_t coinbase_tx_sum = 0; + uint64_t current_index = start_height; + this->get_blocks(start_height, end_height - start_height, blocks); + BOOST_FOREACH(auto& b, blocks) + { + coinbase_tx_sum += get_outs_money_amount(b.miner_tx); + } + + return coinbase_tx_sum; + } + //----------------------------------------------------------------------------------------------- bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const { std::unordered_set ki; diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 6727d6b04..af7d30a95 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -141,7 +141,7 @@ namespace cryptonote * @note see Blockchain::cleanup_handle_incoming_blocks */ bool cleanup_handle_incoming_blocks(bool force_sync = false); - + /** * @brief check the size of a block against the current maximum * @@ -600,6 +600,13 @@ namespace cryptonote */ size_t get_block_sync_size() const { return block_sync_size; } + /** + * @brief get the sum of coinbase tx amounts between blocks + * + * @return the number of blocks to sync in one go + */ + uint64_t get_coinbase_tx_sum(const uint64_t start_height, const uint64_t end_height); + private: /** diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 6ea862b56..94bab17dd 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -137,7 +137,7 @@ bool t_command_parser_executor::set_log_level(const std::vector& ar return m_executor.set_log_level(l); } -bool t_command_parser_executor::print_height(const std::vector& args) +bool t_command_parser_executor::print_height(const std::vector& args) { if (!args.empty()) return false; @@ -339,17 +339,17 @@ bool t_command_parser_executor::set_limit_down(const std::vector& a bool t_command_parser_executor::out_peers(const std::vector& args) { if (args.empty()) return false; - + unsigned int limit; try { limit = std::stoi(args[0]); } - + catch(std::invalid_argument& ex) { _erro("stoi exception"); return false; } - + return m_executor.out_peers(limit); } @@ -452,5 +452,27 @@ bool t_command_parser_executor::output_histogram(const std::vector& return m_executor.output_histogram(min_count, max_count); } +bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector& args) +{ + if(!args.size()) + { + std::cout << "need block index parameter" << std::endl; + return false; + } + uint64_t start_index = 0; + uint64_t end_index = 0; + if(!epee::string_tools::get_xtype_from_string(start_index, args[0])) + { + std::cout << "wrong starter block index parameter" << std::endl; + return false; + } + if(args.size() >1 && !epee::string_tools::get_xtype_from_string(end_index, args[1])) + { + std::cout << "wrong end block index parameter" << std::endl; + return false; + } + + return m_executor.print_coinbase_tx_sum(start_index, end_index); +} } // namespace daemonize diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 7819bd261..d3fa78230 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -7,23 +7,23 @@ */ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -99,11 +99,11 @@ public: bool set_limit_down(const std::vector& args); bool out_peers(const std::vector& args); - + bool start_save_graph(const std::vector& args); - + bool stop_save_graph(const std::vector& args); - + bool hard_fork_info(const std::vector& args); bool show_bans(const std::vector& args); @@ -115,6 +115,8 @@ public: bool flush_txpool(const std::vector& args); bool output_histogram(const std::vector& args); + + bool print_coinbase_tx_sum(const std::vector& args); }; } // namespace daemonize diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index cb54d1966..5cae09816 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -215,6 +215,11 @@ t_command_server::t_command_server( , std::bind(&t_command_parser_executor::output_histogram, &m_parser, p::_1) , "Print output histogram (amount, instances)" ); + m_command_lookup.set_handler( + "print_coinbase_tx_sum" + , std::bind(&t_command_parser_executor::print_coinbase_tx_sum, &m_parser, p::_1) + , "Print sum of coinbase transactions (start index, end index)" + ); } bool t_command_server::process_command_str(const std::string& cmd) diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index e7229f7f9..f80c90a2d 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -409,7 +409,7 @@ bool t_rpc_command_executor::print_connections() { << std::setw(20) << "Livetime(sec)" << std::setw(12) << "Down (kB/s)" << std::setw(14) << "Down(now)" - << std::setw(10) << "Up (kB/s)" + << std::setw(10) << "Up (kB/s)" << std::setw(13) << "Up(now)" << std::endl; @@ -418,7 +418,7 @@ bool t_rpc_command_executor::print_connections() { std::string address = info.incoming ? "INC " : "OUT "; address += info.ip + ":" + info.port; //std::string in_out = info.incoming ? "INC " : "OUT "; - tools::msg_writer() + tools::msg_writer() //<< std::setw(30) << std::left << in_out << std::setw(30) << std::left << address << std::setw(20) << info.peer_id @@ -429,11 +429,11 @@ bool t_rpc_command_executor::print_connections() { << std::setw(14) << info.current_download << std::setw(10) << info.avg_upload << std::setw(13) << info.current_upload - + << std::left << (info.localhost ? "[LOCALHOST]" : "") << std::left << (info.local_ip ? "[LAN]" : ""); //tools::msg_writer() << boost::format("%-25s peer_id: %-25s %s") % address % info.peer_id % in_out; - + } return true; @@ -989,11 +989,11 @@ bool t_rpc_command_executor::out_peers(uint64_t limit) { cryptonote::COMMAND_RPC_OUT_PEERS::request req; cryptonote::COMMAND_RPC_OUT_PEERS::response res; - + epee::json_rpc::error error_resp; req.out_peers = limit; - + std::string fail_message = "Unsuccessful"; if (m_is_rpc) @@ -1022,7 +1022,7 @@ bool t_rpc_command_executor::start_save_graph() cryptonote::COMMAND_RPC_START_SAVE_GRAPH::request req; cryptonote::COMMAND_RPC_START_SAVE_GRAPH::response res; std::string fail_message = "Unsuccessful"; - + if (m_is_rpc) { if (!m_rpc_client->rpc_request(req, res, "/start_save_graph", fail_message.c_str())) @@ -1030,7 +1030,7 @@ bool t_rpc_command_executor::start_save_graph() return true; } } - + else { if (!m_rpc_server->on_start_save_graph(req, res) || res.status != CORE_RPC_STATUS_OK) @@ -1039,7 +1039,7 @@ bool t_rpc_command_executor::start_save_graph() return true; } } - + return true; } @@ -1048,7 +1048,7 @@ bool t_rpc_command_executor::stop_save_graph() cryptonote::COMMAND_RPC_STOP_SAVE_GRAPH::request req; cryptonote::COMMAND_RPC_STOP_SAVE_GRAPH::response res; std::string fail_message = "Unsuccessful"; - + if (m_is_rpc) { if (!m_rpc_client->rpc_request(req, res, "/stop_save_graph", fail_message.c_str())) @@ -1056,7 +1056,7 @@ bool t_rpc_command_executor::stop_save_graph() return true; } } - + else { if (!m_rpc_server->on_stop_save_graph(req, res) || res.status != CORE_RPC_STATUS_OK) @@ -1270,5 +1270,38 @@ bool t_rpc_command_executor::output_histogram(uint64_t min_count, uint64_t max_c return true; } +bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t start_block_index, uint64_t end_block_index) +{ + cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::request req; + cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::response res; + epee::json_rpc::error error_resp; + + req.start_height = start_block_index; + req.end_height = end_block_index; + + std::string fail_message = "Unsuccessful"; + + if (m_is_rpc) + { + if (!m_rpc_client->json_rpc_request(req, res, "get_coinbase_tx_sum", fail_message.c_str())) + { + return true; + } + } + else + { + if (!m_rpc_server->on_get_coinbase_tx_sum(req, res, error_resp)) + { + tools::fail_msg_writer() << fail_message.c_str(); + return true; + } + } + + tools::msg_writer() << "Sum of coinbase transactions between block indexes " + << start_block_index << " and " << end_block_index << " (inclusive) is " + << cryptonote::print_money(res.amount); + return true; +} + }// namespace daemonize diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index 5eed44353..5ded7c3f8 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -7,23 +7,23 @@ */ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -117,11 +117,11 @@ public: bool set_limit_down(int limit); bool out_peers(uint64_t limit); - + bool start_save_graph(); - + bool stop_save_graph(); - + bool hard_fork_info(uint8_t version); bool print_bans(); @@ -133,6 +133,8 @@ public: bool flush_txpool(const std::string &txid); bool output_histogram(uint64_t min_count, uint64_t max_count); + + bool print_coinbase_tx_sum(uint64_t start_block_index, uint64_t end_block_index); }; } // namespace daemonize diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 700019250..0c6e20625 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,7 +25,7 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include @@ -565,7 +565,7 @@ namespace cryptonote const miner& lMiner = m_core.get_miner(); res.active = lMiner.is_mining(); - + if ( lMiner.is_mining() ) { res.speed = lMiner.get_speed(); res.threads_count = lMiner.get_threads_count(); @@ -790,7 +790,7 @@ namespace cryptonote error_resp.message = "Wrong block blob"; return false; } - + // Fixing of high orphan issue for most pools // Thanks Boolberry! block b = AUTO_VAL_INIT(b); @@ -1266,6 +1266,12 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp) + { + res.amount = m_core.get_coinbase_tx_sum(req.start_height, req.end_height); + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res) { // TODO @@ -1278,7 +1284,7 @@ namespace cryptonote m_p2p.delete_connections(count); } } - + else m_p2p.m_config.m_net_config.connections_count = req.out_peers; */ diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 68da59f6b..1110c8e53 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,10 +25,10 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -#pragma once +#pragma once #include #include @@ -77,9 +77,9 @@ namespace cryptonote MAP_URI_AUTO_JON2("/getheight", on_get_height, COMMAND_RPC_GET_HEIGHT) MAP_URI_AUTO_BIN2("/getblocks.bin", on_get_blocks, COMMAND_RPC_GET_BLOCKS_FAST) MAP_URI_AUTO_BIN2("/gethashes.bin", on_get_hashes, COMMAND_RPC_GET_HASHES_FAST) - MAP_URI_AUTO_BIN2("/get_o_indexes.bin", on_get_indexes, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES) - MAP_URI_AUTO_BIN2("/getrandom_outs.bin", on_get_random_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS) - MAP_URI_AUTO_BIN2("/get_outs.bin", on_get_outs, COMMAND_RPC_GET_OUTPUTS) + MAP_URI_AUTO_BIN2("/get_o_indexes.bin", on_get_indexes, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES) + MAP_URI_AUTO_BIN2("/getrandom_outs.bin", on_get_random_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS) + MAP_URI_AUTO_BIN2("/get_outs.bin", on_get_outs, COMMAND_RPC_GET_OUTPUTS) MAP_URI_AUTO_BIN2("/getrandom_rctouts.bin", on_get_random_rct_outs, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS) MAP_URI_AUTO_JON2("/gettransactions", on_get_transactions, COMMAND_RPC_GET_TRANSACTIONS) MAP_URI_AUTO_JON2("/is_key_image_spent", on_is_key_image_spent, COMMAND_RPC_IS_KEY_IMAGE_SPENT) @@ -115,6 +115,7 @@ namespace cryptonote MAP_JON_RPC_WE_IF("flush_txpool", on_flush_txpool, COMMAND_RPC_FLUSH_TRANSACTION_POOL, !m_restricted) MAP_JON_RPC_WE("get_output_histogram", on_get_output_histogram, COMMAND_RPC_GET_OUTPUT_HISTOGRAM) MAP_JON_RPC_WE("get_version", on_get_version, COMMAND_RPC_GET_VERSION) + MAP_JON_RPC_WE("get_coinbase_tx_sum", on_get_coinbase_tx_sum, COMMAND_RPC_GET_COINBASE_TX_SUM) END_JSON_RPC_MAP() END_URI_MAP2() @@ -128,10 +129,10 @@ namespace cryptonote bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res); bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res); bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); - bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); - bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); + bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); + bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); bool on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res); - bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); + bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); bool on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res); bool on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res); bool on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res); @@ -141,7 +142,7 @@ namespace cryptonote bool on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res); bool on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res); bool on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res); - + //json_rpc bool on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res); bool on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp); @@ -160,6 +161,7 @@ namespace cryptonote bool on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp); bool on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp); bool on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp); + bool on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp); //----------------------- private: @@ -169,11 +171,11 @@ private: ); bool check_core_busy(); bool check_core_ready(); - + //utils uint64_t get_block_reward(const block& blk); bool fill_block_header_response(const block& blk, bool orphan_status, uint64_t height, const crypto::hash& hash, block_header_response& response); - + core& m_core; nodetool::node_server >& m_p2p; std::string m_port; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index dd2116e51..a7603685c 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,7 +25,7 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once @@ -484,7 +484,7 @@ namespace cryptonote }; }; - + //----------------------------------------------- struct COMMAND_RPC_STOP_MINING { @@ -555,7 +555,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + // struct COMMAND_RPC_GETBLOCKCOUNT { @@ -620,7 +620,7 @@ namespace cryptonote struct COMMAND_RPC_SUBMITBLOCK { typedef std::vector request; - + struct response { std::string status; @@ -630,7 +630,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + struct block_header_response { uint8_t major_version; @@ -644,7 +644,7 @@ namespace cryptonote std::string hash; difficulty_type difficulty; uint64_t reward; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(major_version) KV_SERIALIZE(minor_version) @@ -672,7 +672,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -680,7 +680,7 @@ namespace cryptonote }; }; - + struct COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH { struct request @@ -696,7 +696,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -720,7 +720,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -749,7 +749,7 @@ namespace cryptonote std::vector tx_hashes; std::string blob; std::string json; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(tx_hashes) @@ -915,7 +915,7 @@ namespace cryptonote { std::string status; std::list connections; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(connections) @@ -966,7 +966,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_FAST_EXIT { struct request @@ -974,17 +974,17 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_OUT_PEERS { struct request @@ -994,17 +994,17 @@ namespace cryptonote KV_SERIALIZE(out_peers) END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_START_SAVE_GRAPH { struct request @@ -1012,17 +1012,17 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_STOP_SAVE_GRAPH { struct request @@ -1030,11 +1030,11 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() @@ -1226,5 +1226,29 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; -} + struct COMMAND_RPC_GET_COINBASE_TX_SUM + { + struct request + { + uint64_t start_height; + uint64_t end_height; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(start_height); + KV_SERIALIZE(end_height); + END_KV_SERIALIZE_MAP() + }; + + struct response + { + std::string status; + uint64_t amount; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(status) + KV_SERIALIZE(amount) + END_KV_SERIALIZE_MAP() + }; + }; +} From e95d3f359b2d87f32abed5dee23c90469144dadf Mon Sep 17 00:00:00 2001 From: Dion Ahmetaj Date: Mon, 10 Oct 2016 16:41:24 -0400 Subject: [PATCH 2/4] attempted to remove whitespace spam --- .gitignore | 1 + src/cryptonote_core/cryptonote_core.h | 2 +- src/daemon/command_parser_executor.cpp | 20 ++++----- src/daemon/command_parser_executor.h | 16 +++---- src/daemon/command_server.cpp | 12 ++--- src/daemon/rpc_command_executor.cpp | 34 +++++++------- src/daemon/rpc_command_executor.h | 18 ++++---- src/rpc/core_rpc_server.cpp | 20 ++++----- src/rpc/core_rpc_server.h | 34 +++++++------- src/rpc/core_rpc_server_commands_defs.h | 60 ++++++++++++------------- 10 files changed, 109 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index 622bbdb3a..a27982af1 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,4 @@ local.properties .texlipse .idea/ +/testnet \ No newline at end of file diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index af7d30a95..662e7f108 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -141,7 +141,7 @@ namespace cryptonote * @note see Blockchain::cleanup_handle_incoming_blocks */ bool cleanup_handle_incoming_blocks(bool force_sync = false); - + /** * @brief check the size of a block against the current maximum * diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 94bab17dd..0d810bc32 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -137,7 +137,7 @@ bool t_command_parser_executor::set_log_level(const std::vector& ar return m_executor.set_log_level(l); } -bool t_command_parser_executor::print_height(const std::vector& args) +bool t_command_parser_executor::print_height(const std::vector& args) { if (!args.empty()) return false; @@ -339,17 +339,17 @@ bool t_command_parser_executor::set_limit_down(const std::vector& a bool t_command_parser_executor::out_peers(const std::vector& args) { if (args.empty()) return false; - + unsigned int limit; try { limit = std::stoi(args[0]); } - + catch(std::invalid_argument& ex) { _erro("stoi exception"); return false; } - + return m_executor.out_peers(limit); } diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index d3fa78230..316c9e8a9 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -7,23 +7,23 @@ */ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -99,9 +99,9 @@ public: bool set_limit_down(const std::vector& args); bool out_peers(const std::vector& args); - + bool start_save_graph(const std::vector& args); - + bool stop_save_graph(const std::vector& args); bool hard_fork_info(const std::vector& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 5cae09816..2f3643779 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index f80c90a2d..80d330e92 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -409,7 +409,7 @@ bool t_rpc_command_executor::print_connections() { << std::setw(20) << "Livetime(sec)" << std::setw(12) << "Down (kB/s)" << std::setw(14) << "Down(now)" - << std::setw(10) << "Up (kB/s)" + << std::setw(10) << "Up (kB/s)" << std::setw(13) << "Up(now)" << std::endl; @@ -418,7 +418,7 @@ bool t_rpc_command_executor::print_connections() { std::string address = info.incoming ? "INC " : "OUT "; address += info.ip + ":" + info.port; //std::string in_out = info.incoming ? "INC " : "OUT "; - tools::msg_writer() + tools::msg_writer() //<< std::setw(30) << std::left << in_out << std::setw(30) << std::left << address << std::setw(20) << info.peer_id @@ -429,11 +429,11 @@ bool t_rpc_command_executor::print_connections() { << std::setw(14) << info.current_download << std::setw(10) << info.avg_upload << std::setw(13) << info.current_upload - + << std::left << (info.localhost ? "[LOCALHOST]" : "") << std::left << (info.local_ip ? "[LAN]" : ""); //tools::msg_writer() << boost::format("%-25s peer_id: %-25s %s") % address % info.peer_id % in_out; - + } return true; @@ -989,11 +989,11 @@ bool t_rpc_command_executor::out_peers(uint64_t limit) { cryptonote::COMMAND_RPC_OUT_PEERS::request req; cryptonote::COMMAND_RPC_OUT_PEERS::response res; - + epee::json_rpc::error error_resp; req.out_peers = limit; - + std::string fail_message = "Unsuccessful"; if (m_is_rpc) @@ -1022,7 +1022,7 @@ bool t_rpc_command_executor::start_save_graph() cryptonote::COMMAND_RPC_START_SAVE_GRAPH::request req; cryptonote::COMMAND_RPC_START_SAVE_GRAPH::response res; std::string fail_message = "Unsuccessful"; - + if (m_is_rpc) { if (!m_rpc_client->rpc_request(req, res, "/start_save_graph", fail_message.c_str())) @@ -1030,7 +1030,7 @@ bool t_rpc_command_executor::start_save_graph() return true; } } - + else { if (!m_rpc_server->on_start_save_graph(req, res) || res.status != CORE_RPC_STATUS_OK) @@ -1039,7 +1039,7 @@ bool t_rpc_command_executor::start_save_graph() return true; } } - + return true; } @@ -1048,7 +1048,7 @@ bool t_rpc_command_executor::stop_save_graph() cryptonote::COMMAND_RPC_STOP_SAVE_GRAPH::request req; cryptonote::COMMAND_RPC_STOP_SAVE_GRAPH::response res; std::string fail_message = "Unsuccessful"; - + if (m_is_rpc) { if (!m_rpc_client->rpc_request(req, res, "/stop_save_graph", fail_message.c_str())) @@ -1056,7 +1056,7 @@ bool t_rpc_command_executor::stop_save_graph() return true; } } - + else { if (!m_rpc_server->on_stop_save_graph(req, res) || res.status != CORE_RPC_STATUS_OK) diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index 5ded7c3f8..aa2b89ac2 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -7,23 +7,23 @@ */ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -117,11 +117,11 @@ public: bool set_limit_down(int limit); bool out_peers(uint64_t limit); - + bool start_save_graph(); - + bool stop_save_graph(); - + bool hard_fork_info(uint8_t version); bool print_bans(); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 0c6e20625..a1744c89c 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,7 +25,7 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include @@ -565,7 +565,7 @@ namespace cryptonote const miner& lMiner = m_core.get_miner(); res.active = lMiner.is_mining(); - + if ( lMiner.is_mining() ) { res.speed = lMiner.get_speed(); res.threads_count = lMiner.get_threads_count(); @@ -790,7 +790,7 @@ namespace cryptonote error_resp.message = "Wrong block blob"; return false; } - + // Fixing of high orphan issue for most pools // Thanks Boolberry! block b = AUTO_VAL_INIT(b); @@ -1284,7 +1284,7 @@ namespace cryptonote m_p2p.delete_connections(count); } } - + else m_p2p.m_config.m_net_config.connections_count = req.out_peers; */ diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 1110c8e53..8ccdc0dd3 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,10 +25,10 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -#pragma once +#pragma once #include #include @@ -77,9 +77,9 @@ namespace cryptonote MAP_URI_AUTO_JON2("/getheight", on_get_height, COMMAND_RPC_GET_HEIGHT) MAP_URI_AUTO_BIN2("/getblocks.bin", on_get_blocks, COMMAND_RPC_GET_BLOCKS_FAST) MAP_URI_AUTO_BIN2("/gethashes.bin", on_get_hashes, COMMAND_RPC_GET_HASHES_FAST) - MAP_URI_AUTO_BIN2("/get_o_indexes.bin", on_get_indexes, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES) - MAP_URI_AUTO_BIN2("/getrandom_outs.bin", on_get_random_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS) - MAP_URI_AUTO_BIN2("/get_outs.bin", on_get_outs, COMMAND_RPC_GET_OUTPUTS) + MAP_URI_AUTO_BIN2("/get_o_indexes.bin", on_get_indexes, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES) + MAP_URI_AUTO_BIN2("/getrandom_outs.bin", on_get_random_outs, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS) + MAP_URI_AUTO_BIN2("/get_outs.bin", on_get_outs, COMMAND_RPC_GET_OUTPUTS) MAP_URI_AUTO_BIN2("/getrandom_rctouts.bin", on_get_random_rct_outs, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS) MAP_URI_AUTO_JON2("/gettransactions", on_get_transactions, COMMAND_RPC_GET_TRANSACTIONS) MAP_URI_AUTO_JON2("/is_key_image_spent", on_is_key_image_spent, COMMAND_RPC_IS_KEY_IMAGE_SPENT) @@ -128,11 +128,11 @@ namespace cryptonote bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res); bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res); bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res); - bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); + bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); - bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); + bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); bool on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res); - bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); + bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); bool on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res); bool on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res); bool on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res); @@ -142,7 +142,7 @@ namespace cryptonote bool on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res); bool on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res); bool on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res); - + //json_rpc bool on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res); bool on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp); @@ -171,11 +171,11 @@ private: ); bool check_core_busy(); bool check_core_ready(); - + //utils uint64_t get_block_reward(const block& blk); bool fill_block_header_response(const block& blk, bool orphan_status, uint64_t height, const crypto::hash& hash, block_header_response& response); - + core& m_core; nodetool::node_server >& m_p2p; std::string m_port; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index a7603685c..4f79b3ed8 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1,21 +1,21 @@ // Copyright (c) 2014-2016, The Monero Project -// +// // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: -// +// // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. -// +// // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. -// +// // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL @@ -25,7 +25,7 @@ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// +// // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once @@ -484,7 +484,7 @@ namespace cryptonote }; }; - + //----------------------------------------------- struct COMMAND_RPC_STOP_MINING { @@ -555,7 +555,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + // struct COMMAND_RPC_GETBLOCKCOUNT { @@ -620,7 +620,7 @@ namespace cryptonote struct COMMAND_RPC_SUBMITBLOCK { typedef std::vector request; - + struct response { std::string status; @@ -630,7 +630,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + struct block_header_response { uint8_t major_version; @@ -644,7 +644,7 @@ namespace cryptonote std::string hash; difficulty_type difficulty; uint64_t reward; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(major_version) KV_SERIALIZE(minor_version) @@ -672,7 +672,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -680,7 +680,7 @@ namespace cryptonote }; }; - + struct COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH { struct request @@ -696,7 +696,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -720,7 +720,7 @@ namespace cryptonote { std::string status; block_header_response block_header; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) @@ -749,7 +749,7 @@ namespace cryptonote std::vector tx_hashes; std::string blob; std::string json; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(tx_hashes) @@ -915,7 +915,7 @@ namespace cryptonote { std::string status; std::list connections; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(connections) @@ -966,7 +966,7 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_FAST_EXIT { struct request @@ -974,17 +974,17 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_OUT_PEERS { struct request @@ -994,17 +994,17 @@ namespace cryptonote KV_SERIALIZE(out_peers) END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_START_SAVE_GRAPH { struct request @@ -1012,17 +1012,17 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() }; }; - + struct COMMAND_RPC_STOP_SAVE_GRAPH { struct request @@ -1030,11 +1030,11 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP() }; - + struct response { std::string status; - + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() From dd6c44327be7d90574466bc37561b9d156466972 Mon Sep 17 00:00:00 2001 From: Dion Ahmetaj Date: Mon, 10 Oct 2016 17:19:36 -0400 Subject: [PATCH 3/4] changed params from start/end index to height/count --- src/cryptonote_core/cryptonote_core.cpp | 6 +++--- src/cryptonote_core/cryptonote_core.h | 2 +- src/daemon/command_parser_executor.cpp | 16 ++++++++-------- src/daemon/command_parser_executor.h | 2 +- src/daemon/command_server.cpp | 2 +- src/daemon/rpc_command_executor.cpp | 10 +++++----- src/daemon/rpc_command_executor.h | 2 +- src/rpc/core_rpc_server.cpp | 2 +- src/rpc/core_rpc_server.h | 4 ++-- src/rpc/core_rpc_server_commands_defs.h | 8 ++++---- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index b8bceb51c..ecbc1067c 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -616,12 +616,12 @@ namespace cryptonote return true; } //----------------------------------------------------------------------------------------------- - uint64_t core::get_coinbase_tx_sum(const uint64_t start_height, const uint64_t end_height) + uint64_t core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count) { std::list blocks; uint64_t coinbase_tx_sum = 0; - uint64_t current_index = start_height; - this->get_blocks(start_height, end_height - start_height, blocks); + uint64_t current_index = start_offset; + this->get_blocks(start_offset, count, blocks); BOOST_FOREACH(auto& b, blocks) { coinbase_tx_sum += get_outs_money_amount(b.miner_tx); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 662e7f108..c152e6a3f 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -605,7 +605,7 @@ namespace cryptonote * * @return the number of blocks to sync in one go */ - uint64_t get_coinbase_tx_sum(const uint64_t start_height, const uint64_t end_height); + uint64_t get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count); private: diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 0d810bc32..5d7ed6cc0 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -456,23 +456,23 @@ bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector1 && !epee::string_tools::get_xtype_from_string(end_index, args[1])) + if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1])) { - std::cout << "wrong end block index parameter" << std::endl; + std::cout << "wrong count parameter" << std::endl; return false; } - return m_executor.print_coinbase_tx_sum(start_index, end_index); + return m_executor.print_coinbase_tx_sum(height, count); } } // namespace daemonize diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 316c9e8a9..6a984aa71 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -103,7 +103,7 @@ public: bool start_save_graph(const std::vector& args); bool stop_save_graph(const std::vector& args); - + bool hard_fork_info(const std::vector& args); bool show_bans(const std::vector& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 2f3643779..1418b920f 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -218,7 +218,7 @@ t_command_server::t_command_server( m_command_lookup.set_handler( "print_coinbase_tx_sum" , std::bind(&t_command_parser_executor::print_coinbase_tx_sum, &m_parser, p::_1) - , "Print sum of coinbase transactions (start index, end index)" + , "Print sum of coinbase transactions (start height, block count)" ); } diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 80d330e92..bf154597c 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1270,14 +1270,14 @@ bool t_rpc_command_executor::output_histogram(uint64_t min_count, uint64_t max_c return true; } -bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t start_block_index, uint64_t end_block_index) +bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t count) { cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::request req; cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::response res; epee::json_rpc::error error_resp; - req.start_height = start_block_index; - req.end_height = end_block_index; + req.height = height; + req.count = count; std::string fail_message = "Unsuccessful"; @@ -1297,8 +1297,8 @@ bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t start_block_index, u } } - tools::msg_writer() << "Sum of coinbase transactions between block indexes " - << start_block_index << " and " << end_block_index << " (inclusive) is " + tools::msg_writer() << "Sum of coinbase transactions between block heights [" + << height << ", " << (height + count) << ") is " << cryptonote::print_money(res.amount); return true; } diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index aa2b89ac2..c097453e7 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -134,7 +134,7 @@ public: bool output_histogram(uint64_t min_count, uint64_t max_count); - bool print_coinbase_tx_sum(uint64_t start_block_index, uint64_t end_block_index); + bool print_coinbase_tx_sum(uint64_t height, uint64_t count); }; } // namespace daemonize diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index a1744c89c..af36961f2 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1268,7 +1268,7 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp) { - res.amount = m_core.get_coinbase_tx_sum(req.start_height, req.end_height); + res.amount = m_core.get_coinbase_tx_sum(req.height, req.count); return true; } //------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 8ccdc0dd3..147f019d6 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -128,8 +128,8 @@ namespace cryptonote bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res); bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res); bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res); - bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); - bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); + bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res); + bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res); bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); bool on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res); bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 4f79b3ed8..47ce37f2f 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1231,12 +1231,12 @@ namespace cryptonote { struct request { - uint64_t start_height; - uint64_t end_height; + uint64_t height; + uint64_t count; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(start_height); - KV_SERIALIZE(end_height); + KV_SERIALIZE(height); + KV_SERIALIZE(count); END_KV_SERIALIZE_MAP() }; From 7db29d6903fe24eabaaf3b3afc364b6924d5b463 Mon Sep 17 00:00:00 2001 From: Dion Ahmetaj Date: Mon, 10 Oct 2016 19:55:18 -0400 Subject: [PATCH 4/4] print_coinbase_tx_sum now breaks output into fee and emission components --- src/cryptonote_core/cryptonote_core.cpp | 24 +++++++++++++++++++----- src/cryptonote_core/cryptonote_core.h | 2 +- src/daemon/rpc_command_executor.cpp | 4 +++- src/rpc/core_rpc_server.cpp | 4 +++- src/rpc/core_rpc_server_commands_defs.h | 6 ++++-- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index ecbc1067c..9a44d9d3f 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -616,18 +616,32 @@ namespace cryptonote return true; } //----------------------------------------------------------------------------------------------- - uint64_t core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count) + std::pair core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count) { std::list blocks; - uint64_t coinbase_tx_sum = 0; - uint64_t current_index = start_offset; + std::list txs; + std::list missed_txs; + uint64_t coinbase_amount = 0; + uint64_t emission_amount = 0; + uint64_t total_fee_amount = 0; + uint64_t tx_fee_amount = 0; this->get_blocks(start_offset, count, blocks); BOOST_FOREACH(auto& b, blocks) { - coinbase_tx_sum += get_outs_money_amount(b.miner_tx); + coinbase_amount = get_outs_money_amount(b.miner_tx); + this->get_transactions(b.tx_hashes, txs, missed_txs); + BOOST_FOREACH(const auto& tx, txs) + { + tx_fee_amount += get_tx_fee(tx); + } + + emission_amount += coinbase_amount - tx_fee_amount; + total_fee_amount += tx_fee_amount; + coinbase_amount = 0; + tx_fee_amount = 0; } - return coinbase_tx_sum; + return std::pair(emission_amount, total_fee_amount); } //----------------------------------------------------------------------------------------------- bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index c152e6a3f..407e89197 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -605,7 +605,7 @@ namespace cryptonote * * @return the number of blocks to sync in one go */ - uint64_t get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count); + std::pair get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count); private: diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index bf154597c..db0d0a6e4 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1299,7 +1299,9 @@ bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t cou tools::msg_writer() << "Sum of coinbase transactions between block heights [" << height << ", " << (height + count) << ") is " - << cryptonote::print_money(res.amount); + << cryptonote::print_money(res.emission_amount + res.fee_amount) << " " + << "consisting of " << cryptonote::print_money(res.emission_amount) + << " in emissions, and " << cryptonote::print_money(res.fee_amount) << " in fees"; return true; } diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index af36961f2..e8b2d5cb1 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1268,7 +1268,9 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp) { - res.amount = m_core.get_coinbase_tx_sum(req.height, req.count); + std::pair amounts = m_core.get_coinbase_tx_sum(req.height, req.count); + res.emission_amount = amounts.first; + res.fee_amount = amounts.second; return true; } //------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 47ce37f2f..61c302e45 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1243,11 +1243,13 @@ namespace cryptonote struct response { std::string status; - uint64_t amount; + uint64_t emission_amount; + uint64_t fee_amount; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) - KV_SERIALIZE(amount) + KV_SERIALIZE(emission_amount) + KV_SERIALIZE(fee_amount) END_KV_SERIALIZE_MAP() }; };