aboutsummaryrefslogtreecommitdiff
path: root/src/addrman_impl.h
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2022-11-29 17:16:26 -0500
committerMartin Zumsande <mzumsande@gmail.com>2023-01-26 18:11:13 -0500
commitd35595a78a4a6cae72d3204c1ec3f82f77a10d56 (patch)
tree65c2b6e89ebb2b15857638cb78eb3e21e023f232 /src/addrman_impl.h
parentadc41cf3b22f8f168e88ce3ad5f27c1130f12beb (diff)
addrman: add function to return size by network and table
For now, the new functionality will be used in the context of querying fixed seeds. Other possible applications for future changes is the use in the context of making automatic connections to specific networks, or making more detailed info about addrman accessible via rpc.
Diffstat (limited to 'src/addrman_impl.h')
-rw-r--r--src/addrman_impl.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/addrman_impl.h b/src/addrman_impl.h
index 39754b673e..f75cccb303 100644
--- a/src/addrman_impl.h
+++ b/src/addrman_impl.h
@@ -114,6 +114,8 @@ public:
size_t size() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
+ size_t Size(std::optional<Network> net, std::optional<bool> in_new) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
+
bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, std::chrono::seconds time_penalty)
EXCLUSIVE_LOCKS_REQUIRED(!cs);
@@ -215,6 +217,14 @@ private:
/** Reference to the netgroup manager. netgroupman must be constructed before addrman and destructed after. */
const NetGroupManager& m_netgroupman;
+ struct NewTriedCount {
+ size_t n_new;
+ size_t n_tried;
+ };
+
+ /** Number of entries in addrman per network and new/tried table. */
+ std::unordered_map<Network, NewTriedCount> m_network_counts GUARDED_BY(cs);
+
//! Find an entry.
AddrInfo* Find(const CService& addr, int* pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
@@ -257,6 +267,8 @@ private:
std::optional<AddressPosition> FindAddressEntry_(const CAddress& addr) EXCLUSIVE_LOCKS_REQUIRED(cs);
+ size_t Size_(std::optional<Network> net, std::optional<bool> in_new) const EXCLUSIVE_LOCKS_REQUIRED(cs);
+
//! Consistency check, taking into account m_consistency_check_ratio.
//! Will std::abort if an inconsistency is detected.
void Check() const EXCLUSIVE_LOCKS_REQUIRED(cs);