diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-05-13 12:13:27 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-07-21 16:01:09 +0200 |
commit | fa02934c8c9d290ea4d12683e8680c70967a4d3a (patch) | |
tree | 01b2fb4dccf059f74b54adcce97f53ad301c72bb /src/addrman.cpp | |
parent | a3791da0e80ab35e862989373f033e5be4dff26b (diff) | |
download | bitcoin-fa02934c8c9d290ea4d12683e8680c70967a4d3a.tar.xz |
refactor: Mark CAddrMan::Select const
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r-- | src/addrman.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 8192b4eba6..6cbcbed839 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -410,7 +410,7 @@ void CAddrMan::Attempt_(const CService& addr, bool fCountFailure, int64_t nTime) } } -CAddrInfo CAddrMan::Select_(bool newOnly) +CAddrInfo CAddrMan::Select_(bool newOnly) const { AssertLockHeld(cs); @@ -433,8 +433,9 @@ CAddrInfo CAddrMan::Select_(bool newOnly) nKBucketPos = (nKBucketPos + insecure_rand.randbits(ADDRMAN_BUCKET_SIZE_LOG2)) % ADDRMAN_BUCKET_SIZE; } int nId = vvTried[nKBucket][nKBucketPos]; - assert(mapInfo.count(nId) == 1); - CAddrInfo& info = mapInfo[nId]; + const auto it_found{mapInfo.find(nId)}; + assert(it_found != mapInfo.end()); + const CAddrInfo& info{it_found->second}; if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) return info; fChanceFactor *= 1.2; @@ -450,8 +451,9 @@ CAddrInfo CAddrMan::Select_(bool newOnly) nUBucketPos = (nUBucketPos + insecure_rand.randbits(ADDRMAN_BUCKET_SIZE_LOG2)) % ADDRMAN_BUCKET_SIZE; } int nId = vvNew[nUBucket][nUBucketPos]; - assert(mapInfo.count(nId) == 1); - CAddrInfo& info = mapInfo[nId]; + const auto it_found{mapInfo.find(nId)}; + assert(it_found != mapInfo.end()); + const CAddrInfo& info{it_found->second}; if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) return info; fChanceFactor *= 1.2; |