aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp22
-rw-r--r--src/daemon/command_parser_executor.h2
-rw-r--r--src/daemon/command_server.cpp5
-rw-r--r--src/daemon/rpc_command_executor.cpp35
-rw-r--r--src/daemon/rpc_command_executor.h2
5 files changed, 66 insertions, 0 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 6ea862b56..5d7ed6cc0 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -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 height parameter" << std::endl;
+ return false;
+ }
+ uint64_t height = 0;
+ uint64_t count = 0;
+ if(!epee::string_tools::get_xtype_from_string(height, args[0]))
+ {
+ std::cout << "wrong starter block height parameter" << std::endl;
+ return false;
+ }
+ if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
+ {
+ std::cout << "wrong count parameter" << std::endl;
+ return false;
+ }
+
+ 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 7819bd261..6a984aa71 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -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..1418b920f 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -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 height, block count)"
+ );
}
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..db0d0a6e4 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1270,5 +1270,40 @@ 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 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.height = height;
+ req.count = count;
+
+ 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 heights ["
+ << height << ", " << (height + count) << ") is "
+ << 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;
+}
+
}// namespace daemonize
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index 5eed44353..c097453e7 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -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 height, uint64_t count);
};
} // namespace daemonize