diff options
| author | xiphon <xiphon@protonmail.com> | 2019-01-18 00:55:55 +0000 |
|---|---|---|
| committer | xiphon <xiphon@protonmail.com> | 2019-01-18 01:32:18 +0000 |
| commit | d294a577faa11910985920f1e70a39398e53d82d (patch) | |
| tree | 8e5b459057e42c70c7ee7e21f4db796c386deb8e /src/daemon/rpc_command_executor.cpp | |
| parent | ed54ac8fdfe332c4ec6b9fd9331024d862ecad51 (diff) | |
| download | monzero-core-d294a577faa11910985920f1e70a39398e53d82d.tar.gz monzero-core-d294a577faa11910985920f1e70a39398e53d82d.tar.xz monzero-core-d294a577faa11910985920f1e70a39398e53d82d.zip | |
daemon: extend 'print_pl' command, optional filter by type and limit
Diffstat (limited to 'src/daemon/rpc_command_executor.cpp')
| -rw-r--r-- | src/daemon/rpc_command_executor.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 015e1e1f9..c1b623aef 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -154,7 +154,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; @@ -175,14 +175,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; |
