From 5840476714ffebb2599999c85a23b52ebcff6090 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Tue, 24 Aug 2021 11:47:17 +0100 Subject: [addrman] Make m_asmap private Add a GetAsmap() getter function that returns a reference to const. --- src/addrman.h | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/addrman.h') diff --git a/src/addrman.h b/src/addrman.h index f9c12ba3f9..3776e478ce 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -181,22 +181,6 @@ static const int64_t ADDRMAN_TEST_WINDOW = 40*60; // 40 minutes class CAddrMan { public: - // Compressed IP->ASN mapping, loaded from a file when a node starts. - // Should be always empty if no file was provided. - // This mapping is then used for bucketing nodes in Addrman. - // - // If asmap is provided, nodes will be bucketed by - // AS they belong to, in order to make impossible for a node - // to connect to several nodes hosted in a single AS. - // This is done in response to Erebus attack, but also to generally - // diversify the connections every node creates, - // especially useful when a large fraction of nodes - // operate under a couple of cloud providers. - // - // If a new asmap was provided, the existing records - // would be re-bucketed accordingly. - const std::vector m_asmap; - // Read asmap from provided binary file static std::vector DecodeAsmap(fs::path path); @@ -593,6 +577,8 @@ public: Check(); } + const std::vector& GetAsmap() const { return m_asmap; } + private: //! A mutex to protect the inner data structures. mutable Mutex cs; @@ -660,6 +646,22 @@ private: /** Perform consistency checks every m_consistency_check_ratio operations (if non-zero). */ const int32_t m_consistency_check_ratio; + // Compressed IP->ASN mapping, loaded from a file when a node starts. + // Should be always empty if no file was provided. + // This mapping is then used for bucketing nodes in Addrman. + // + // If asmap is provided, nodes will be bucketed by + // AS they belong to, in order to make impossible for a node + // to connect to several nodes hosted in a single AS. + // This is done in response to Erebus attack, but also to generally + // diversify the connections every node creates, + // especially useful when a large fraction of nodes + // operate under a couple of cloud providers. + // + // If a new asmap was provided, the existing records + // would be re-bucketed accordingly. + const std::vector m_asmap; + //! Find an entry. CAddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); -- cgit v1.2.3