diff options
author | John Newbery <john@johnnewbery.com> | 2021-08-05 14:10:02 +0100 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-08-19 11:29:54 +0100 |
commit | 7e6e65918f75211b517fc887f5d90df8edd52ced (patch) | |
tree | a58e8031205061393d89bba7130cf9723f0fc87d /src/addrman.cpp | |
parent | 406be5ff9699874dc1d38d11f036e33cbdb820c9 (diff) | |
download | bitcoin-7e6e65918f75211b517fc887f5d90df8edd52ced.tar.xz |
[addrman] inline Clear() into CAddrMan ctor
Clear() is now only called from the ctor, so just inline the code into
that function.
The LOCK(cs) can be removed, since there can be no data races in the ctor.
Also move the function definition out of the header and into the cpp file.
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r-- | src/addrman.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index e8f98f727b..690ea19c30 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -77,6 +77,32 @@ double CAddrInfo::GetChance(int64_t nNow) const return fChance; } +CAddrMan::CAddrMan(bool deterministic, int32_t consistency_check_ratio) + : insecure_rand{deterministic} + , m_consistency_check_ratio{consistency_check_ratio} +{ + std::vector<int>().swap(vRandom); + nKey = insecure_rand.rand256(); + for (size_t bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) { + for (size_t entry = 0; entry < ADDRMAN_BUCKET_SIZE; entry++) { + vvNew[bucket][entry] = -1; + } + } + for (size_t bucket = 0; bucket < ADDRMAN_TRIED_BUCKET_COUNT; bucket++) { + for (size_t entry = 0; entry < ADDRMAN_BUCKET_SIZE; entry++) { + vvTried[bucket][entry] = -1; + } + } + + nIdCount = 0; + nTried = 0; + nNew = 0; + nLastGood = 1; //Initially at 1 so that "never" is strictly worse. + mapInfo.clear(); + mapAddr.clear(); + if (deterministic) nKey = uint256{1}; +} + CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId) { AssertLockHeld(cs); |