aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/command_parser_executor.cpp29
-rw-r--r--src/daemon/command_server.cpp1
-rw-r--r--src/daemon/rpc_command_executor.cpp29
-rw-r--r--src/daemon/rpc_command_executor.h2
4 files changed, 50 insertions, 11 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 37cb55ec8..73f33a674 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -48,9 +48,34 @@ t_command_parser_executor::t_command_parser_executor(
bool t_command_parser_executor::print_peer_list(const std::vector<std::string>& args)
{
- if (!args.empty()) return false;
+ if (args.size() > 3)
+ {
+ std::cout << "use: print_pl [white] [gray] [<limit>]" << std::endl;
+ return true;
+ }
+
+ bool white = false;
+ bool gray = false;
+ size_t limit = 0;
+ for (size_t i = 0; i < args.size(); ++i)
+ {
+ if (args[i] == "white")
+ {
+ white = true;
+ }
+ else if (args[i] == "gray")
+ {
+ gray = true;
+ }
+ else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
+ {
+ std::cout << "unexpected argument: " << args[i] << std::endl;
+ return true;
+ }
+ }
- return m_executor.print_peer_list();
+ const bool print_both = !white && !gray;
+ return m_executor.print_peer_list(white | print_both, gray | print_both, limit);
}
bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args)
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 786d1a601..96dea76b6 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -64,6 +64,7 @@ t_command_server::t_command_server(
m_command_lookup.set_handler(
"print_pl"
, std::bind(&t_command_parser_executor::print_peer_list, &m_parser, p::_1)
+ , "print_pl [white] [gray] [<limit>]"
, "Print the current peer list."
);
m_command_lookup.set_handler(
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 7cd61934f..0a35dcef9 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -79,6 +79,7 @@ namespace {
<< "POW hash: " << header.pow_hash << std::endl
<< "block size: " << header.block_size << std::endl
<< "block weight: " << header.block_weight << std::endl
+ << "long term weight: " << header.long_term_weight << std::endl
<< "num txes: " << header.num_txes << std::endl
<< "reward: " << cryptonote::print_money(header.reward);
}
@@ -156,7 +157,7 @@ t_rpc_command_executor::~t_rpc_command_executor()
}
}
-bool t_rpc_command_executor::print_peer_list() {
+bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit) {
cryptonote::COMMAND_RPC_GET_PEER_LIST::request req;
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
@@ -177,14 +178,24 @@ bool t_rpc_command_executor::print_peer_list() {
}
}
- for (auto & peer : res.white_list)
+ if (white)
{
- print_peer("white", peer);
+ auto peer = res.white_list.cbegin();
+ const auto end = limit ? peer + std::min(limit, res.white_list.size()) : res.white_list.cend();
+ for (; peer != end; ++peer)
+ {
+ print_peer("white", *peer);
+ }
}
- for (auto & peer : res.gray_list)
+ if (gray)
{
- print_peer("gray", peer);
+ auto peer = res.gray_list.cbegin();
+ const auto end = limit ? peer + std::min(limit, res.gray_list.size()) : res.gray_list.cend();
+ for (; peer != end; ++peer)
+ {
+ print_peer("gray", *peer);
+ }
}
return true;
@@ -500,6 +511,7 @@ bool t_rpc_command_executor::print_connections() {
}
tools::msg_writer() << std::setw(30) << std::left << "Remote Host"
+ << std::setw(6) << "SSL"
<< std::setw(20) << "Peer id"
<< std::setw(20) << "Support Flags"
<< std::setw(30) << "Recv/Sent (inactive,sec)"
@@ -519,6 +531,7 @@ bool t_rpc_command_executor::print_connections() {
tools::msg_writer()
//<< std::setw(30) << std::left << in_out
<< std::setw(30) << std::left << address
+ << std::setw(6) << (info.ssl ? "yes" : "no")
<< std::setw(20) << epee::string_tools::pad_string(info.peer_id, 16, '0', true)
<< std::setw(20) << info.support_flags
<< std::setw(30) << std::to_string(info.recv_count) + "(" + std::to_string(info.recv_idle_time) + ")/" + std::to_string(info.send_count) + "(" + std::to_string(info.send_idle_time) + ")"
@@ -878,7 +891,7 @@ bool t_rpc_command_executor::print_transaction_pool_long() {
}
else
{
- if (!m_rpc_server->on_get_transaction_pool(req, res, false) || res.status != CORE_RPC_STATUS_OK)
+ if (!m_rpc_server->on_get_transaction_pool(req, res) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << make_error(fail_message, res.status);
return true;
@@ -964,7 +977,7 @@ bool t_rpc_command_executor::print_transaction_pool_short() {
}
else
{
- if (!m_rpc_server->on_get_transaction_pool(req, res, false) || res.status != CORE_RPC_STATUS_OK)
+ if (!m_rpc_server->on_get_transaction_pool(req, res) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << make_error(fail_message, res.status);
return true;
@@ -1022,7 +1035,7 @@ bool t_rpc_command_executor::print_transaction_pool_stats() {
else
{
res.pool_stats = {};
- if (!m_rpc_server->on_get_transaction_pool_stats(req, res, false) || res.status != CORE_RPC_STATUS_OK)
+ if (!m_rpc_server->on_get_transaction_pool_stats(req, res) || res.status != CORE_RPC_STATUS_OK)
{
tools::fail_msg_writer() << make_error(fail_message, res.status);
return true;
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index de743065b..b1e9828a0 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -67,7 +67,7 @@ public:
~t_rpc_command_executor();
- bool print_peer_list();
+ bool print_peer_list(bool white = true, bool gray = true, size_t limit = 0);
bool print_peer_list_stats();