aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2021-08-17 13:55:11 -0700
committerAmiti Uttarwar <amiti@uttarwar.org>2021-08-26 11:56:13 -0700
commitaf9638a0fbb79bec743f4d2275b89e9573cfdc0a (patch)
treec93be21a68ce47eda0b541fea4ddd04876d7084c /src
parent7dc443a62d3c98d8d0849d83060e940356fe32a3 (diff)
downloadbitcoin-af9638a0fbb79bec743f4d2275b89e9573cfdc0a.tar.xz
[move-only] Extract constants from addrman .h to .cpp
Reviewer hint: use `git diff --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space` Co-authored-by: John Newbery <john@johnnewbery.com>
Diffstat (limited to 'src')
-rw-r--r--src/addrman.cpp31
-rw-r--r--src/addrman.h36
2 files changed, 33 insertions, 34 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 93f7cf6980..ec1c6c975f 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -15,6 +15,37 @@
#include <unordered_map>
#include <unordered_set>
+//! over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread
+static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8};
+
+//! over how many buckets entries with new addresses originating from a single group are spread
+static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
+
+//! in how many buckets for entries with new addresses a single address may occur
+static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
+
+//! how old addresses can maximally be
+static constexpr int64_t ADDRMAN_HORIZON_DAYS{30};
+
+//! after how many failed attempts we give up on a new node
+static constexpr int32_t ADDRMAN_RETRIES{3};
+
+//! how many successive failures are allowed ...
+static constexpr int32_t ADDRMAN_MAX_FAILURES{10};
+
+//! ... in at least this many days
+static constexpr int64_t ADDRMAN_MIN_FAIL_DAYS{7};
+
+//! how recent a successful connection should be before we allow an address to be evicted from tried
+static constexpr int64_t ADDRMAN_REPLACEMENT_HOURS{4};
+
+//! the maximum number of tried addr collisions to store
+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 CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const
{
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash();
diff --git a/src/addrman.h b/src/addrman.h
index ed7e4c4c5b..b6d115e741 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -133,48 +133,16 @@ public:
//! total number of buckets for tried addresses
static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8};
+static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2};
//! total number of buckets for new addresses
static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10};
+static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2};
//! maximum allowed number of entries in buckets for new and tried addresses
static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6};
-
-//! over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread
-static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8};
-
-//! over how many buckets entries with new addresses originating from a single group are spread
-static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
-
-//! in how many buckets for entries with new addresses a single address may occur
-static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
-
-//! how old addresses can maximally be
-static constexpr int64_t ADDRMAN_HORIZON_DAYS{30};
-
-//! after how many failed attempts we give up on a new node
-static constexpr int32_t ADDRMAN_RETRIES{3};
-
-//! how many successive failures are allowed ...
-static constexpr int32_t ADDRMAN_MAX_FAILURES{10};
-
-//! ... in at least this many days
-static constexpr int64_t ADDRMAN_MIN_FAIL_DAYS{7};
-
-//! how recent a successful connection should be before we allow an address to be evicted from tried
-static constexpr int64_t ADDRMAN_REPLACEMENT_HOURS{4};
-
-//! Convenience
-static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2};
-static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2};
static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2};
-//! the maximum number of tried addr collisions to store
-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
-
/**
* Stochastical (IP) address manager
*/