@@ -58,9 +58,9 @@ int AddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const NetGr
58
58
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
59
59
}
60
60
61
- int AddrInfo::GetBucketPosition (const uint256& nKey, bool fNew , int nBucket ) const
61
+ int AddrInfo::GetBucketPosition (const uint256& nKey, bool fNew , int bucket ) const
62
62
{
63
- uint64_t hash1 = (CHashWriter (SER_GETHASH, 0 ) << nKey << (fNew ? uint8_t {' N' } : uint8_t {' K' }) << nBucket << GetKey ()).GetCheapHash ();
63
+ uint64_t hash1 = (CHashWriter (SER_GETHASH, 0 ) << nKey << (fNew ? uint8_t {' N' } : uint8_t {' K' }) << bucket << GetKey ()).GetCheapHash ();
64
64
return hash1 % ADDRMAN_BUCKET_SIZE;
65
65
}
66
66
@@ -714,19 +714,19 @@ void AddrManImpl::Attempt_(const CService& addr, bool fCountFailure, NodeSeconds
714
714
}
715
715
}
716
716
717
- std::pair<CAddress, NodeSeconds> AddrManImpl::Select_ (bool newOnly ) const
717
+ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_ (bool new_only ) const
718
718
{
719
719
AssertLockHeld (cs);
720
720
721
721
if (vRandom.empty ()) return {};
722
- if (newOnly && nNew == 0 ) return {};
722
+ if (new_only && nNew == 0 ) return {};
723
723
724
724
// Decide if we are going to search the new or tried table
725
725
bool search_tried;
726
726
int bucket_count;
727
727
728
728
// Use a 50% chance for choosing between tried and new table entries.
729
- if (!newOnly &&
729
+ if (!new_only &&
730
730
(nTried > 0 &&
731
731
(nNew == 0 || insecure_rand.randbool () == 0 ))) {
732
732
search_tried = true ;
@@ -736,39 +736,39 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool newOnly) const
736
736
bucket_count = ADDRMAN_NEW_BUCKET_COUNT;
737
737
}
738
738
739
- double fChanceFactor = 1.0 ;
739
+ double chance_factor = 1.0 ;
740
740
while (1 ) {
741
741
// Pick a bucket, and an initial position in that bucket.
742
- int nBucket = insecure_rand.randrange (bucket_count);
743
- int nBucketPos = insecure_rand.randrange (ADDRMAN_BUCKET_SIZE);
742
+ int bucket = insecure_rand.randrange (bucket_count);
743
+ int initial_position = insecure_rand.randrange (ADDRMAN_BUCKET_SIZE);
744
744
745
745
// Iterate over the positions of that bucket, starting at the initial one,
746
746
// and looping around.
747
747
int i;
748
748
for (i = 0 ; i < ADDRMAN_BUCKET_SIZE; ++i) {
749
- int position = (nBucketPos + i) % ADDRMAN_BUCKET_SIZE;
750
- int node_id = GetEntry (search_tried, nBucket , position);
749
+ int position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
750
+ int node_id = GetEntry (search_tried, bucket , position);
751
751
if (node_id != -1 ) break ;
752
752
}
753
753
754
754
// If the bucket is entirely empty, start over with a (likely) different one.
755
755
if (i == ADDRMAN_BUCKET_SIZE) continue ;
756
756
757
757
// Find the entry to return.
758
- int position = (nBucketPos + i) % ADDRMAN_BUCKET_SIZE;
759
- int nId = GetEntry (search_tried, nBucket , position);
758
+ int position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
759
+ int nId = GetEntry (search_tried, bucket , position);
760
760
const auto it_found{mapInfo.find (nId)};
761
761
assert (it_found != mapInfo.end ());
762
762
const AddrInfo& info{it_found->second };
763
763
764
- // With probability GetChance() * fChanceFactor , return the entry.
765
- if (insecure_rand.randbits (30 ) < fChanceFactor * info.GetChance () * (1 << 30 )) {
764
+ // With probability GetChance() * chance_factor , return the entry.
765
+ if (insecure_rand.randbits (30 ) < chance_factor * info.GetChance () * (1 << 30 )) {
766
766
LogPrint (BCLog::ADDRMAN, " Selected %s from %s\n " , info.ToStringAddrPort (), search_tried ? " tried" : " new" );
767
767
return {info, info.m_last_try };
768
768
}
769
769
770
770
// Otherwise start over with a (likely) different bucket, and increased chance factor.
771
- fChanceFactor *= 1.2 ;
771
+ chance_factor *= 1.2 ;
772
772
}
773
773
}
774
774
@@ -1168,11 +1168,11 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision()
1168
1168
return ret;
1169
1169
}
1170
1170
1171
- std::pair<CAddress, NodeSeconds> AddrManImpl::Select (bool newOnly ) const
1171
+ std::pair<CAddress, NodeSeconds> AddrManImpl::Select (bool new_only ) const
1172
1172
{
1173
1173
LOCK (cs);
1174
1174
Check ();
1175
- auto addrRet = Select_ (newOnly );
1175
+ auto addrRet = Select_ (new_only );
1176
1176
Check ();
1177
1177
return addrRet;
1178
1178
}
@@ -1266,9 +1266,9 @@ std::pair<CAddress, NodeSeconds> AddrMan::SelectTriedCollision()
1266
1266
return m_impl->SelectTriedCollision ();
1267
1267
}
1268
1268
1269
- std::pair<CAddress, NodeSeconds> AddrMan::Select (bool newOnly ) const
1269
+ std::pair<CAddress, NodeSeconds> AddrMan::Select (bool new_only ) const
1270
1270
{
1271
- return m_impl->Select (newOnly );
1271
+ return m_impl->Select (new_only );
1272
1272
}
1273
1273
1274
1274
std::vector<CAddress> AddrMan::GetAddr (size_t max_addresses, size_t max_pct, std::optional<Network> network) const
0 commit comments