diff options
author | Gleb Naumenko <naumenko.gs@gmail.com> | 2020-01-10 13:08:15 -0500 |
---|---|---|
committer | Gleb Naumenko <naumenko.gs@gmail.com> | 2020-01-23 14:23:06 -0500 |
commit | 3c1bc40205a3fcab606e70b0e3c13d68b2860e34 (patch) | |
tree | 15e674a90f50f0232e73dfe22033b195c72c8200 /src/addrman.cpp | |
parent | e4658aa8eaf1629dd5af8cf7b9717a8e72028251 (diff) |
Add extra logging of asmap use and bucketing
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r-- | src/addrman.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 2516c6dc7c..fc50cf4f9b 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -7,12 +7,16 @@ #include <hash.h> #include <serialize.h> +#include <logging.h> int CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector<bool> &asmap) const { uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash(); uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash(); - return hash2 % ADDRMAN_TRIED_BUCKET_COUNT; + int tried_bucket = hash2 % ADDRMAN_TRIED_BUCKET_COUNT; + uint32_t mapped_as = GetMappedAS(asmap); + LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to tried bucket %i.\n", ToStringIP(), mapped_as, tried_bucket); + return tried_bucket; } int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector<bool> &asmap) const @@ -20,7 +24,10 @@ int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std: std::vector<unsigned char> vchSourceGroupKey = src.GetGroup(asmap); uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash(); uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP)).GetCheapHash(); - return hash2 % ADDRMAN_NEW_BUCKET_COUNT; + int new_bucket = hash2 % ADDRMAN_NEW_BUCKET_COUNT; + uint32_t mapped_as = GetMappedAS(asmap); + LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to new bucket %i.\n", ToStringIP(), mapped_as, new_bucket); + return new_bucket; } int CAddrInfo::GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const |