Skip to content

Commit 9de77e8

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin#21192: cli: Treat high detail levels as maximum in -netinfo
882ce25 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 882ce25 theStack: Tested ACK 882ce25 Tree-SHA512: 5ed13213d00940c81f70c5fe5092f5fcc78c0184e1cc83b6c58a7bf24cf0f634816ce28f468aac588a4d202a6a7c1b411c0690099f1a8bf1999e662de4afcccd
1 parent e22ebca commit 9de77e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bitcoin-cli.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
320320
private:
321321
static constexpr int8_t UNKNOWN_NETWORK{-1};
322322
static constexpr uint8_t m_networks_size{3};
323+
static constexpr uint8_t MAX_DETAIL_LEVEL{4};
323324
const std::array<std::string, m_networks_size> m_networks{{"ipv4", "ipv6", "onion"}};
324325
std::array<std::array<uint16_t, m_networks_size + 2>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total/block-relay)
325326
int8_t NetworkStringToId(const std::string& str) const
@@ -437,7 +438,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
437438
if (!args.empty()) {
438439
uint8_t n{0};
439440
if (ParseUInt8(args.at(0), &n)) {
440-
m_details_level = n;
441+
m_details_level = std::min(n, MAX_DETAIL_LEVEL);
441442
} else if (args.at(0) == "help") {
442443
m_is_help_requested = true;
443444
} else {

0 commit comments

Comments
 (0)