Merge #21192: cli: Treat high detail levels as maximum in -netinfo

882ce25132e1b6880916fa154850a708e6a968b2 cli: Treat high detail levels as the maximum in -netinfo (Wladimir J. van der Laan)

Pull request description:

  I somehow often type `-netinfo 5` which gets treated as `-netinfo 0`, after this change it's `-netinfo 4` which seems more convenient behavior.

ACKs for top commit:
  jonatack:
    ACK 882ce25132e1b6880916fa154850a708e6a968b2
  theStack:
    Tested ACK 882ce25132e1b6880916fa154850a708e6a968b2

Tree-SHA512: 5ed13213d00940c81f70c5fe5092f5fcc78c0184e1cc83b6c58a7bf24cf0f634816ce28f468aac588a4d202a6a7c1b411c0690099f1a8bf1999e662de4afcccd
This commit is contained in:
Wladimir J. van der Laan 2021-02-17 12:44:15 +01:00 committed by pasta
parent e22ebca746
commit 9de77e8f46
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -320,6 +320,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
private:
static constexpr int8_t UNKNOWN_NETWORK{-1};
static constexpr uint8_t m_networks_size{3};
static constexpr uint8_t MAX_DETAIL_LEVEL{4};
const std::array<std::string, m_networks_size> m_networks{{"ipv4", "ipv6", "onion"}};
std::array<std::array<uint16_t, m_networks_size + 2>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total/block-relay)
int8_t NetworkStringToId(const std::string& str) const
@ -437,7 +438,7 @@ public:
if (!args.empty()) {
uint8_t n{0};
if (ParseUInt8(args.at(0), &n)) {
m_details_level = n;
m_details_level = std::min(n, MAX_DETAIL_LEVEL);
} else if (args.at(0) == "help") {
m_is_help_requested = true;
} else {