[refactor] [addrman] Update constant comments

Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
This commit is contained in:
John Newbery 2021-08-18 09:45:54 +01:00 committed by Amiti Uttarwar
parent af9638a0fb
commit 85b15ddc8f
2 changed files with 13 additions and 23 deletions

View file

@ -15,37 +15,27 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
//! over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread /** 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}; 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 */
//! 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}; static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
/** Maximum number of times an address can be added to the new table */
//! in how many buckets for entries with new addresses a single address may occur
static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8}; static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
/** How old addresses can maximally be */
//! how old addresses can maximally be
static constexpr int64_t ADDRMAN_HORIZON_DAYS{30}; static constexpr int64_t ADDRMAN_HORIZON_DAYS{30};
/** After how many failed attempts we give up on a new node */
//! after how many failed attempts we give up on a new node
static constexpr int32_t ADDRMAN_RETRIES{3}; static constexpr int32_t ADDRMAN_RETRIES{3};
/** How many successive failures are allowed ... */
//! how many successive failures are allowed ...
static constexpr int32_t ADDRMAN_MAX_FAILURES{10}; static constexpr int32_t ADDRMAN_MAX_FAILURES{10};
/** ... in at least this many days */
//! ... in at least this many days
static constexpr int64_t ADDRMAN_MIN_FAIL_DAYS{7}; 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 */
//! 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}; static constexpr int64_t ADDRMAN_REPLACEMENT_HOURS{4};
/** The maximum number of tried addr collisions to store */
//! the maximum number of tried addr collisions to store
static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10}; 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 */
//! 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 static constexpr int64_t ADDRMAN_TEST_WINDOW{40*60}; // 40 minutes
int CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const int CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const
{ {
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash(); uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash();

View file

@ -131,15 +131,15 @@ public:
* configuration option will introduce (expensive) consistency checks for the entire data structure. * configuration option will introduce (expensive) consistency checks for the entire data structure.
*/ */
//! total number of buckets for tried addresses /** Total number of buckets for tried addresses */
static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8}; static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8};
static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2}; static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2};
//! total number of buckets for new addresses /** Total number of buckets for new addresses */
static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10}; static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10};
static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2}; 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 /** Maximum allowed number of entries in buckets for new and tried addresses */
static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6}; static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6};
static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2}; static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2};