mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user