aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorDion Ahmetaj <Dion Ahmetaj>2016-10-10 15:45:51 -0400
committerDion Ahmetaj <Dion Ahmetaj>2016-10-10 15:45:51 -0400
commit412da636225f32ba62bdba7e3ed0281dcea08b05 (patch)
treee85e4f4b94183122d8512860be490606f29741ab /src/daemon
parentMerge pull request #1182 (diff)
downloadmonero-412da636225f32ba62bdba7e3ed0281dcea08b05.tar.xz
added print_coinbase_tx_sum option
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp42
-rw-r--r--src/daemon/command_parser_executor.h20
-rw-r--r--src/daemon/command_server.cpp17
-rw-r--r--src/daemon/rpc_command_executor.cpp67
-rw-r--r--src/daemon/rpc_command_executor.h20
5 files changed, 115 insertions, 51 deletions
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<std::string>& ar
return m_executor.set_log_level(l);
}
-bool t_command_parser_executor::print_height(const std::vector<std::string>& args)
+bool t_command_parser_executor::print_height(const std::vector<std::string>& args)
{
if (!args.empty()) return false;
@@ -339,17 +339,17 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a
bool t_command_parser_executor::out_peers(const std::vector<std::string>& 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<std::string>&
return m_executor.output_histogram(min_count, max_count);
}
+bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::string>& 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<std::string>& args);
bool out_peers(const std::vector<std::string>& args);
-
+
bool start_save_graph(const std::vector<std::string>& args);
-
+
bool stop_save_graph(const std::vector<std::string>& args);
-
+
bool hard_fork_info(const std::vector<std::string>& args);
bool show_bans(const std::vector<std::string>& args);
@@ -115,6 +115,8 @@ public:
bool flush_txpool(const std::vector<std::string>& args);
bool output_histogram(const std::vector<std::string>& args);
+
+ bool print_coinbase_tx_sum(const std::vector<std::string>& 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