@@ -188,7 +188,7 @@ void AddrManImpl::Serialize(Stream& s_) const
188
188
189
189
int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30 );
190
190
s << nUBuckets;
191
- std::unordered_map<int , int > mapUnkIds;
191
+ std::unordered_map<nid_type , int > mapUnkIds;
192
192
int nIds = 0 ;
193
193
for (const auto & entry : mapInfo) {
194
194
mapUnkIds[entry.first ] = nIds;
@@ -398,7 +398,7 @@ void AddrManImpl::Unserialize(Stream& s_)
398
398
}
399
399
}
400
400
401
- AddrInfo* AddrManImpl::Find (const CService& addr, int * pnId)
401
+ AddrInfo* AddrManImpl::Find (const CService& addr, nid_type * pnId)
402
402
{
403
403
AssertLockHeld (cs);
404
404
@@ -413,11 +413,11 @@ AddrInfo* AddrManImpl::Find(const CService& addr, int* pnId)
413
413
return nullptr ;
414
414
}
415
415
416
- AddrInfo* AddrManImpl::Create (const CAddress& addr, const CNetAddr& addrSource, int * pnId)
416
+ AddrInfo* AddrManImpl::Create (const CAddress& addr, const CNetAddr& addrSource, nid_type * pnId)
417
417
{
418
418
AssertLockHeld (cs);
419
419
420
- int nId = nIdCount++;
420
+ nid_type nId = nIdCount++;
421
421
mapInfo[nId] = AddrInfo (addr, addrSource);
422
422
mapAddr[addr] = nId;
423
423
mapInfo[nId].nRandomPos = vRandom.size ();
@@ -438,8 +438,8 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
438
438
439
439
assert (nRndPos1 < vRandom.size () && nRndPos2 < vRandom.size ());
440
440
441
- int nId1 = vRandom[nRndPos1];
442
- int nId2 = vRandom[nRndPos2];
441
+ nid_type nId1 = vRandom[nRndPos1];
442
+ nid_type nId2 = vRandom[nRndPos2];
443
443
444
444
const auto it_1{mapInfo.find (nId1)};
445
445
const auto it_2{mapInfo.find (nId2)};
@@ -453,7 +453,7 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
453
453
vRandom[nRndPos2] = nId1;
454
454
}
455
455
456
- void AddrManImpl::Delete (int nId)
456
+ void AddrManImpl::Delete (nid_type nId)
457
457
{
458
458
AssertLockHeld (cs);
459
459
@@ -476,7 +476,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
476
476
477
477
// if there is an entry in the specified bucket, delete it.
478
478
if (vvNew[nUBucket][nUBucketPos] != -1 ) {
479
- int nIdDelete = vvNew[nUBucket][nUBucketPos];
479
+ nid_type nIdDelete = vvNew[nUBucket][nUBucketPos];
480
480
AddrInfo& infoDelete = mapInfo[nIdDelete];
481
481
assert (infoDelete.nRefCount > 0 );
482
482
infoDelete.nRefCount --;
@@ -488,7 +488,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
488
488
}
489
489
}
490
490
491
- void AddrManImpl::MakeTried (AddrInfo& info, int nId)
491
+ void AddrManImpl::MakeTried (AddrInfo& info, nid_type nId)
492
492
{
493
493
AssertLockHeld (cs);
494
494
@@ -515,7 +515,7 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
515
515
// first make space to add it (the existing tried entry there is moved to new, deleting whatever is there).
516
516
if (vvTried[nKBucket][nKBucketPos] != -1 ) {
517
517
// find an item to evict
518
- int nIdEvict = vvTried[nKBucket][nKBucketPos];
518
+ nid_type nIdEvict = vvTried[nKBucket][nKBucketPos];
519
519
assert (mapInfo.count (nIdEvict) == 1 );
520
520
AddrInfo& infoOld = mapInfo[nIdEvict];
521
521
@@ -554,7 +554,7 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, std::c
554
554
if (!addr.IsRoutable ())
555
555
return false ;
556
556
557
- int nId;
557
+ nid_type nId;
558
558
AddrInfo* pinfo = Find (addr, &nId);
559
559
560
560
// Do not set a penalty for a source's self-announcement
@@ -627,7 +627,7 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, NodeSecond
627
627
{
628
628
AssertLockHeld (cs);
629
629
630
- int nId;
630
+ nid_type nId;
631
631
632
632
m_last_good = time;
633
633
@@ -758,7 +758,8 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, const std::
758
758
759
759
// Iterate over the positions of that bucket, starting at the initial one,
760
760
// and looping around.
761
- int i, position, node_id;
761
+ int i, position;
762
+ nid_type node_id;
762
763
for (i = 0 ; i < ADDRMAN_BUCKET_SIZE; ++i) {
763
764
position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
764
765
node_id = GetEntry (search_tried, bucket, position);
@@ -791,7 +792,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, const std::
791
792
}
792
793
}
793
794
794
- int AddrManImpl::GetEntry (bool use_tried, size_t bucket, size_t position) const
795
+ nid_type AddrManImpl::GetEntry (bool use_tried, size_t bucket, size_t position) const
795
796
{
796
797
AssertLockHeld (cs);
797
798
@@ -854,7 +855,7 @@ std::vector<std::pair<AddrInfo, AddressPosition>> AddrManImpl::GetEntries_(bool
854
855
std::vector<std::pair<AddrInfo, AddressPosition>> infos;
855
856
for (int bucket = 0 ; bucket < bucket_count; ++bucket) {
856
857
for (int position = 0 ; position < ADDRMAN_BUCKET_SIZE; ++position) {
857
- int id = GetEntry (from_tried, bucket, position);
858
+ nid_type id = GetEntry (from_tried, bucket, position);
858
859
if (id >= 0 ) {
859
860
AddrInfo info = mapInfo.at (id);
860
861
AddressPosition location = AddressPosition (
@@ -909,8 +910,8 @@ void AddrManImpl::ResolveCollisions_()
909
910
{
910
911
AssertLockHeld (cs);
911
912
912
- for (std::set<int >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
913
- int id_new = *it;
913
+ for (std::set<nid_type >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
914
+ nid_type id_new = *it;
914
915
915
916
bool erase_collision = false ;
916
917
@@ -928,7 +929,7 @@ void AddrManImpl::ResolveCollisions_()
928
929
} else if (vvTried[tried_bucket][tried_bucket_pos] != -1 ) { // The position in the tried bucket is not empty
929
930
930
931
// Get the to-be-evicted address that is being tested
931
- int id_old = vvTried[tried_bucket][tried_bucket_pos];
932
+ nid_type id_old = vvTried[tried_bucket][tried_bucket_pos];
932
933
AddrInfo& info_old = mapInfo[id_old];
933
934
934
935
const auto current_time{Now<NodeSeconds>()};
@@ -974,11 +975,11 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision_()
974
975
975
976
if (m_tried_collisions.size () == 0 ) return {};
976
977
977
- std::set<int >::iterator it = m_tried_collisions.begin ();
978
+ std::set<nid_type >::iterator it = m_tried_collisions.begin ();
978
979
979
980
// Selects a random element from m_tried_collisions
980
981
std::advance (it, insecure_rand.randrange (m_tried_collisions.size ()));
981
- int id_new = *it;
982
+ nid_type id_new = *it;
982
983
983
984
// If id_new not found in mapInfo remove it from m_tried_collisions
984
985
if (mapInfo.count (id_new) != 1 ) {
@@ -1063,15 +1064,15 @@ int AddrManImpl::CheckAddrman() const
1063
1064
LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE (
1064
1065
strprintf (" new %i, tried %i, total %u" , nNew, nTried, vRandom.size ()), BCLog::ADDRMAN);
1065
1066
1066
- std::unordered_set<int > setTried;
1067
- std::unordered_map<int , int > mapNew;
1067
+ std::unordered_set<nid_type > setTried;
1068
+ std::unordered_map<nid_type , int > mapNew;
1068
1069
std::unordered_map<Network, NewTriedCount> local_counts;
1069
1070
1070
1071
if (vRandom.size () != (size_t )(nTried + nNew))
1071
1072
return -7 ;
1072
1073
1073
1074
for (const auto & entry : mapInfo) {
1074
- int n = entry.first ;
1075
+ nid_type n = entry.first ;
1075
1076
const AddrInfo& info = entry.second ;
1076
1077
if (info.fInTried ) {
1077
1078
if (!TicksSinceEpoch<std::chrono::seconds>(info.m_last_success )) {
0 commit comments