This commit is contained in:
Vasil Dimov 2024-04-29 04:35:26 +02:00 committed by GitHub
commit 933a7dc62c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -57,6 +57,11 @@ int AddrInfo::GetTriedBucket(const uint256& nKey, const NetGroupManager& netgrou
int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const NetGroupManager& netgroupman) const
{
std::vector<unsigned char> vchSourceGroupKey = netgroupman.GetGroup(src);
if (src.IsTor() || src.IsI2P() || src.IsCJDNS()) {
// For the purposes of new-bucketing, treat the entire Tor network as a single source (same
// for I2P and CJDNS).
vchSourceGroupKey.resize(1);
}
uint64_t hash1 = (HashWriter{} << nKey << netgroupman.GetGroup(*this) << vchSourceGroupKey).GetCheapHash();
uint64_t hash2 = (HashWriter{} << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP)).GetCheapHash();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;