From 021f86953e8a1dff8ecc768186368d345c865cc2 Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Fri, 10 Sep 2021 18:53:57 -0600 Subject: [style] Run changed files through clang formatter. --- src/addrman.cpp | 32 ++++++++++++++++---------------- src/addrman.h | 10 +++++----- src/addrman_impl.h | 24 ++++++++++++------------ src/test/addrman_tests.cpp | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index c015026cbc..c364a7710b 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -41,7 +41,7 @@ static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; /** The maximum time we'll spend trying to resolve a tried table collision, in seconds */ static constexpr int64_t ADDRMAN_TEST_WINDOW{40*60}; // 40 minutes -int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector &asmap) const +int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector& asmap) const { uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash(); uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash(); @@ -51,7 +51,7 @@ int AddrInfo::GetTriedBucket(const uint256& nKey, const std::vector &asmap return tried_bucket; } -int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector &asmap) const +int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector& asmap) const { std::vector vchSourceGroupKey = src.GetGroup(asmap); uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash(); @@ -62,7 +62,7 @@ int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std:: return new_bucket; } -int AddrInfo::GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const +int AddrInfo::GetBucketPosition(const uint256& nKey, bool fNew, int nBucket) const { uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << (fNew ? uint8_t{'N'} : uint8_t{'K'}) << nBucket << GetKey()).GetCheapHash(); return hash1 % ADDRMAN_BUCKET_SIZE; @@ -190,7 +190,7 @@ void AddrManImpl::Serialize(Stream& s_) const int nIds = 0; for (const auto& entry : mapInfo) { mapUnkIds[entry.first] = nIds; - const AddrInfo &info = entry.second; + const AddrInfo& info = entry.second; if (info.nRefCount) { assert(nIds != nNew); // this means nNew was wrong, oh ow s << info; @@ -199,7 +199,7 @@ void AddrManImpl::Serialize(Stream& s_) const } nIds = 0; for (const auto& entry : mapInfo) { - const AddrInfo &info = entry.second; + const AddrInfo& info = entry.second; if (info.fInTried) { assert(nIds != nTried); // this means nTried was wrong, oh ow s << info; @@ -283,7 +283,7 @@ void AddrManImpl::Unserialize(Stream& s_) // Deserialize entries from the new table. for (int n = 0; n < nNew; n++) { - AddrInfo &info = mapInfo[n]; + AddrInfo& info = mapInfo[n]; s >> info; mapAddr[info] = n; info.nRandomPos = vRandom.size(); @@ -1024,7 +1024,7 @@ size_t AddrManImpl::size() const return vRandom.size(); } -bool AddrManImpl::Add(const std::vector &vAddr, const CNetAddr& source, int64_t nTimePenalty) +bool AddrManImpl::Add(const std::vector& vAddr, const CNetAddr& source, int64_t nTimePenalty) { LOCK(cs); int nAdd = 0; @@ -1038,7 +1038,7 @@ bool AddrManImpl::Add(const std::vector &vAddr, const CNetAddr& source return nAdd > 0; } -void AddrManImpl::Good(const CService &addr, int64_t nTime) +void AddrManImpl::Good(const CService& addr, int64_t nTime) { LOCK(cs); Check(); @@ -1046,7 +1046,7 @@ void AddrManImpl::Good(const CService &addr, int64_t nTime) Check(); } -void AddrManImpl::Attempt(const CService &addr, bool fCountFailure, int64_t nTime) +void AddrManImpl::Attempt(const CService& addr, bool fCountFailure, int64_t nTime) { LOCK(cs); Check(); @@ -1089,7 +1089,7 @@ std::vector AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct, return addresses; } -void AddrManImpl::Connected(const CService &addr, int64_t nTime) +void AddrManImpl::Connected(const CService& addr, int64_t nTime) { LOCK(cs); Check(); @@ -1097,7 +1097,7 @@ void AddrManImpl::Connected(const CService &addr, int64_t nTime) Check(); } -void AddrManImpl::SetServices(const CService &addr, ServiceFlags nServices) +void AddrManImpl::SetServices(const CService& addr, ServiceFlags nServices) { LOCK(cs); Check(); @@ -1141,17 +1141,17 @@ size_t AddrMan::size() const return m_impl->size(); } -bool AddrMan::Add(const std::vector &vAddr, const CNetAddr& source, int64_t nTimePenalty) +bool AddrMan::Add(const std::vector& vAddr, const CNetAddr& source, int64_t nTimePenalty) { return m_impl->Add(vAddr, source, nTimePenalty); } -void AddrMan::Good(const CService &addr, int64_t nTime) +void AddrMan::Good(const CService& addr, int64_t nTime) { m_impl->Good(addr, nTime); } -void AddrMan::Attempt(const CService &addr, bool fCountFailure, int64_t nTime) +void AddrMan::Attempt(const CService& addr, bool fCountFailure, int64_t nTime) { m_impl->Attempt(addr, fCountFailure, nTime); } @@ -1176,12 +1176,12 @@ std::vector AddrMan::GetAddr(size_t max_addresses, size_t max_pct, std return m_impl->GetAddr(max_addresses, max_pct, network); } -void AddrMan::Connected(const CService &addr, int64_t nTime) +void AddrMan::Connected(const CService& addr, int64_t nTime) { m_impl->Connected(addr, nTime); } -void AddrMan::SetServices(const CService &addr, ServiceFlags nServices) +void AddrMan::SetServices(const CService& addr, ServiceFlags nServices) { m_impl->SetServices(addr, nServices); } diff --git a/src/addrman.h b/src/addrman.h index fcb2147832..174ab4f811 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -70,13 +70,13 @@ public: size_t size() const; //! Add addresses to addrman's new table. - bool Add(const std::vector &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0); + bool Add(const std::vector& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0); //! Mark an entry as accessible, possibly moving it from "new" to "tried". - void Good(const CService &addr, int64_t nTime = GetAdjustedTime()); + void Good(const CService& addr, int64_t nTime = GetAdjustedTime()); //! Mark an entry as connection attempted to. - void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime()); + void Attempt(const CService& addr, bool fCountFailure, int64_t nTime = GetAdjustedTime()); //! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions. void ResolveCollisions(); @@ -121,10 +121,10 @@ public: * @param[in] addr The address of the peer we were connected to * @param[in] nTime The time that we were last connected to this peer */ - void Connected(const CService &addr, int64_t nTime = GetAdjustedTime()); + void Connected(const CService& addr, int64_t nTime = GetAdjustedTime()); //! Update an entry's service bits. - void SetServices(const CService &addr, ServiceFlags nServices); + void SetServices(const CService& addr, ServiceFlags nServices); const std::vector& GetAsmap() const; diff --git a/src/addrman_impl.h b/src/addrman_impl.h index 157f7d5da6..1dc7f25f9c 100644 --- a/src/addrman_impl.h +++ b/src/addrman_impl.h @@ -111,29 +111,29 @@ public: size_t size() const EXCLUSIVE_LOCKS_REQUIRED(!cs); - bool Add(const std::vector &vAddr, const CNetAddr& source, int64_t nTimePenalty) + bool Add(const std::vector& vAddr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(!cs); - void Good(const CService &addr, int64_t nTime) + void Good(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(!cs); - void Attempt(const CService &addr, bool fCountFailure, int64_t nTime) + void Attempt(const CService& addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(!cs); void ResolveCollisions() EXCLUSIVE_LOCKS_REQUIRED(!cs); std::pair SelectTriedCollision() EXCLUSIVE_LOCKS_REQUIRED(!cs); - std::pair Select(bool newOnly) const + std::pair Select(bool newOnly) const EXCLUSIVE_LOCKS_REQUIRED(!cs); std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network) const EXCLUSIVE_LOCKS_REQUIRED(!cs); - void Connected(const CService &addr, int64_t nTime) + void Connected(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(!cs); - void SetServices(const CService &addr, ServiceFlags nServices) + void SetServices(const CService& addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(!cs); const std::vector& GetAsmap() const; @@ -225,10 +225,10 @@ private: const std::vector m_asmap; //! Find an entry. - AddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); + AddrInfo* Find(const CNetAddr& addr, int* pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Create a new entry and add it to the internal data structures mapInfo, mapAddr and vRandom. - AddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); + AddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Swap two elements in vRandom. void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2) const EXCLUSIVE_LOCKS_REQUIRED(cs); @@ -242,11 +242,11 @@ private: //! Move an entry from the "new" table(s) to the "tried" table void MakeTried(AddrInfo& info, int nId) EXCLUSIVE_LOCKS_REQUIRED(cs); - void Good_(const CService &addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs); + void Good_(const CService& addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs); - bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs); + bool Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs); - void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs); + void Attempt_(const CService& addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs); std::pair Select_(bool newOnly) const EXCLUSIVE_LOCKS_REQUIRED(cs); @@ -254,7 +254,7 @@ private: void Connected_(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs); - void SetServices_(const CService &addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs); + void SetServices_(const CService& addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs); void ResolveCollisions_() EXCLUSIVE_LOCKS_REQUIRED(cs); diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 69ad7c7e24..bd6f470219 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -83,7 +83,7 @@ private: bool deterministic; public: explicit AddrManTest(bool makeDeterministic = true, - std::vector asmap = std::vector()) + std::vector asmap = std::vector()) : AddrMan(asmap, makeDeterministic, /* consistency_check_ratio */ 100) { deterministic = makeDeterministic; -- cgit v1.2.3