mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
daemon: add pruned and publicrpc flags to print_pl
This commit is contained in:
parent
cdfa2e58df
commit
b51f4cdcaf
@ -51,12 +51,14 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
{
|
{
|
||||||
if (args.size() > 3)
|
if (args.size() > 3)
|
||||||
{
|
{
|
||||||
std::cout << "use: print_pl [white] [gray] [<limit>]" << std::endl;
|
std::cout << "use: print_pl [white] [gray] [<limit>] [pruned] [publicrpc]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool white = false;
|
bool white = false;
|
||||||
bool gray = false;
|
bool gray = false;
|
||||||
|
bool pruned = false;
|
||||||
|
bool publicrpc = false;
|
||||||
size_t limit = 0;
|
size_t limit = 0;
|
||||||
for (size_t i = 0; i < args.size(); ++i)
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -68,6 +70,14 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
{
|
{
|
||||||
gray = true;
|
gray = true;
|
||||||
}
|
}
|
||||||
|
else if (args[i] == "pruned")
|
||||||
|
{
|
||||||
|
pruned = true;
|
||||||
|
}
|
||||||
|
else if (args[i] == "publicrpc")
|
||||||
|
{
|
||||||
|
publicrpc = true;
|
||||||
|
}
|
||||||
else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
|
else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
|
||||||
{
|
{
|
||||||
std::cout << "unexpected argument: " << args[i] << std::endl;
|
std::cout << "unexpected argument: " << args[i] << std::endl;
|
||||||
@ -76,7 +86,7 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool print_both = !white && !gray;
|
const bool print_both = !white && !gray;
|
||||||
return m_executor.print_peer_list(white | print_both, gray | print_both, limit);
|
return m_executor.print_peer_list(white | print_both, gray | print_both, limit, pruned, publicrpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args)
|
||||||
|
@ -60,8 +60,13 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_peer(std::string const & prefix, cryptonote::peer const & peer)
|
void print_peer(std::string const & prefix, cryptonote::peer const & peer, bool pruned_only, bool publicrpc_only)
|
||||||
{
|
{
|
||||||
|
if (pruned_only && peer.pruning_seed == 0)
|
||||||
|
return;
|
||||||
|
if (publicrpc_only && peer.rpc_port == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
time_t last_seen = static_cast<time_t>(peer.last_seen);
|
time_t last_seen = static_cast<time_t>(peer.last_seen);
|
||||||
@ -169,7 +174,7 @@ t_rpc_command_executor::~t_rpc_command_executor()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit) {
|
bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit, bool pruned_only, bool publicrpc_only) {
|
||||||
cryptonote::COMMAND_RPC_GET_PEER_LIST::request req;
|
cryptonote::COMMAND_RPC_GET_PEER_LIST::request req;
|
||||||
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
|
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
|
||||||
|
|
||||||
@ -196,7 +201,7 @@ bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit
|
|||||||
const auto end = limit ? peer + std::min(limit, res.white_list.size()) : res.white_list.cend();
|
const auto end = limit ? peer + std::min(limit, res.white_list.size()) : res.white_list.cend();
|
||||||
for (; peer != end; ++peer)
|
for (; peer != end; ++peer)
|
||||||
{
|
{
|
||||||
print_peer("white", *peer);
|
print_peer("white", *peer, pruned_only, publicrpc_only);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +211,7 @@ bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit
|
|||||||
const auto end = limit ? peer + std::min(limit, res.gray_list.size()) : res.gray_list.cend();
|
const auto end = limit ? peer + std::min(limit, res.gray_list.size()) : res.gray_list.cend();
|
||||||
for (; peer != end; ++peer)
|
for (; peer != end; ++peer)
|
||||||
{
|
{
|
||||||
print_peer("gray", *peer);
|
print_peer("gray", *peer, pruned_only, publicrpc_only);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
|
|
||||||
~t_rpc_command_executor();
|
~t_rpc_command_executor();
|
||||||
|
|
||||||
bool print_peer_list(bool white = true, bool gray = true, size_t limit = 0);
|
bool print_peer_list(bool white = true, bool gray = true, size_t limit = 0, bool pruned_only = false, bool publicrpc_only = false);
|
||||||
|
|
||||||
bool print_peer_list_stats();
|
bool print_peer_list_stats();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user