Skip to content

Commit 3c1bc40

Browse files
committed
Add extra logging of asmap use and bucketing
1 parent e4658aa commit 3c1bc40

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/addrman.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@
77

88
#include <hash.h>
99
#include <serialize.h>
10+
#include <logging.h>
1011

1112
int CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const
1213
{
1314
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash();
1415
uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash();
15-
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
16+
int tried_bucket = hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
17+
uint32_t mapped_as = GetMappedAS(asmap);
18+
LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to tried bucket %i.\n", ToStringIP(), mapped_as, tried_bucket);
19+
return tried_bucket;
1620
}
1721

1822
int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector<bool> &asmap) const
1923
{
2024
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup(asmap);
2125
uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash();
2226
uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP)).GetCheapHash();
23-
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
27+
int new_bucket = hash2 % ADDRMAN_NEW_BUCKET_COUNT;
28+
uint32_t mapped_as = GetMappedAS(asmap);
29+
LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to new bucket %i.\n", ToStringIP(), mapped_as, new_bucket);
30+
return new_bucket;
2431
}
2532

2633
int CAddrInfo::GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const

0 commit comments

Comments
 (0)