MCPcopy Create free account
hub / github.com/ElementsProject/elements / NetinfoRequestHandler

Class NetinfoRequestHandler

src/bitcoin-cli.cpp:370–671  ·  view source on GitHub ↗

Process netinfo requests */

Source from the content-addressed store, hash-verified

368
369/** Process netinfo requests */
370class NetinfoRequestHandler : public BaseRequestHandler
371{
372private:
373 static constexpr uint8_t MAX_DETAIL_LEVEL{4};
374 std::array<std::array<uint16_t, NETWORKS.size() + 1>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total)
375 uint8_t m_block_relay_peers_count{0};
376 uint8_t m_manual_peers_count{0};
377 int8_t NetworkStringToId(const std::string& str) const
378 {
379 for (size_t i = 0; i < NETWORKS.size(); ++i) {
380 if (str == NETWORKS[i]) return i;
381 }
382 return UNKNOWN_NETWORK;
383 }
384 uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level
385 bool DetailsRequested() const { return m_details_level > 0 && m_details_level < 5; }
386 bool IsAddressSelected() const { return m_details_level == 2 || m_details_level == 4; }
387 bool IsVersionSelected() const { return m_details_level == 3 || m_details_level == 4; }
388 bool m_is_asmap_on{false};
389 size_t m_max_addr_length{0};
390 size_t m_max_addr_processed_length{5};
391 size_t m_max_addr_rate_limited_length{6};
392 size_t m_max_age_length{5};
393 size_t m_max_id_length{2};
394 struct Peer {
395 std::string addr;
396 std::string sub_version;
397 std::string conn_type;
398 std::string network;
399 std::string age;
400 double min_ping;
401 double ping;
402 int64_t addr_processed;
403 int64_t addr_rate_limited;
404 int64_t last_blck;
405 int64_t last_recv;
406 int64_t last_send;
407 int64_t last_trxn;
408 int id;
409 int mapped_as;
410 int version;
411 bool is_addr_relay_enabled;
412 bool is_bip152_hb_from;
413 bool is_bip152_hb_to;
414 bool is_block_relay;
415 bool is_outbound;
416 bool operator<(const Peer& rhs) const { return std::tie(is_outbound, min_ping) < std::tie(rhs.is_outbound, rhs.min_ping); }
417 };
418 std::vector<Peer> m_peers;
419 std::string ChainToString() const
420 {
421 if (gArgs.GetChainName() == CBaseChainParams::TESTNET) return " testnet";
422 if (gArgs.GetChainName() == CBaseChainParams::SIGNET) return " signet";
423 if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
424 return "";
425 }
426 std::string PingTimeToString(double seconds) const
427 {

Callers 1

CommandLineRPCFunction · 0.85

Calls 2

GetTimeSecondsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected