@@ -188,7 +188,7 @@ void AddrManImpl::Serialize(Stream& s_) const
188188
189189 int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30 );
190190 s << nUBuckets;
191- std::unordered_map<int , int > mapUnkIds;
191+ std::unordered_map<nid_type , int > mapUnkIds;
192192 int nIds = 0 ;
193193 for (const auto & entry : mapInfo) {
194194 mapUnkIds[entry.first ] = nIds;
@@ -398,7 +398,7 @@ void AddrManImpl::Unserialize(Stream& s_)
398398 }
399399}
400400
401- AddrInfo* AddrManImpl::Find (const CService& addr, int * pnId)
401+ AddrInfo* AddrManImpl::Find (const CService& addr, nid_type * pnId)
402402{
403403 AssertLockHeld (cs);
404404
@@ -413,11 +413,11 @@ AddrInfo* AddrManImpl::Find(const CService& addr, int* pnId)
413413 return nullptr ;
414414}
415415
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)
417417{
418418 AssertLockHeld (cs);
419419
420- int nId = nIdCount++;
420+ nid_type nId = nIdCount++;
421421 mapInfo[nId] = AddrInfo (addr, addrSource);
422422 mapAddr[addr] = nId;
423423 mapInfo[nId].nRandomPos = vRandom.size ();
@@ -438,8 +438,8 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
438438
439439 assert (nRndPos1 < vRandom.size () && nRndPos2 < vRandom.size ());
440440
441- int nId1 = vRandom[nRndPos1];
442- int nId2 = vRandom[nRndPos2];
441+ nid_type nId1 = vRandom[nRndPos1];
442+ nid_type nId2 = vRandom[nRndPos2];
443443
444444 const auto it_1{mapInfo.find (nId1)};
445445 const auto it_2{mapInfo.find (nId2)};
@@ -453,7 +453,7 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
453453 vRandom[nRndPos2] = nId1;
454454}
455455
456- void AddrManImpl::Delete (int nId)
456+ void AddrManImpl::Delete (nid_type nId)
457457{
458458 AssertLockHeld (cs);
459459
@@ -476,7 +476,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
476476
477477 // if there is an entry in the specified bucket, delete it.
478478 if (vvNew[nUBucket][nUBucketPos] != -1 ) {
479- int nIdDelete = vvNew[nUBucket][nUBucketPos];
479+ nid_type nIdDelete = vvNew[nUBucket][nUBucketPos];
480480 AddrInfo& infoDelete = mapInfo[nIdDelete];
481481 assert (infoDelete.nRefCount > 0 );
482482 infoDelete.nRefCount --;
@@ -488,7 +488,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
488488 }
489489}
490490
491- void AddrManImpl::MakeTried (AddrInfo& info, int nId)
491+ void AddrManImpl::MakeTried (AddrInfo& info, nid_type nId)
492492{
493493 AssertLockHeld (cs);
494494
@@ -515,7 +515,7 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
515515 // first make space to add it (the existing tried entry there is moved to new, deleting whatever is there).
516516 if (vvTried[nKBucket][nKBucketPos] != -1 ) {
517517 // find an item to evict
518- int nIdEvict = vvTried[nKBucket][nKBucketPos];
518+ nid_type nIdEvict = vvTried[nKBucket][nKBucketPos];
519519 assert (mapInfo.count (nIdEvict) == 1 );
520520 AddrInfo& infoOld = mapInfo[nIdEvict];
521521
@@ -554,7 +554,7 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, std::c
554554 if (!addr.IsRoutable ())
555555 return false ;
556556
557- int nId;
557+ nid_type nId;
558558 AddrInfo* pinfo = Find (addr, &nId);
559559
560560 // 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
627627{
628628 AssertLockHeld (cs);
629629
630- int nId;
630+ nid_type nId;
631631
632632 m_last_good = time;
633633
@@ -753,7 +753,8 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option
753753
754754 // Iterate over the positions of that bucket, starting at the initial one,
755755 // and looping around.
756- int i, position, node_id;
756+ int i, position;
757+ nid_type node_id;
757758 for (i = 0 ; i < ADDRMAN_BUCKET_SIZE; ++i) {
758759 position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
759760 node_id = GetEntry (search_tried, bucket, position);
@@ -786,7 +787,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option
786787 }
787788}
788789
789- int AddrManImpl::GetEntry (bool use_tried, size_t bucket, size_t position) const
790+ nid_type AddrManImpl::GetEntry (bool use_tried, size_t bucket, size_t position) const
790791{
791792 AssertLockHeld (cs);
792793
@@ -849,7 +850,7 @@ std::vector<std::pair<AddrInfo, AddressPosition>> AddrManImpl::GetEntries_(bool
849850 std::vector<std::pair<AddrInfo, AddressPosition>> infos;
850851 for (int bucket = 0 ; bucket < bucket_count; ++bucket) {
851852 for (int position = 0 ; position < ADDRMAN_BUCKET_SIZE; ++position) {
852- int id = GetEntry (from_tried, bucket, position);
853+ nid_type id = GetEntry (from_tried, bucket, position);
853854 if (id >= 0 ) {
854855 AddrInfo info = mapInfo.at (id);
855856 AddressPosition location = AddressPosition (
@@ -904,8 +905,8 @@ void AddrManImpl::ResolveCollisions_()
904905{
905906 AssertLockHeld (cs);
906907
907- for (std::set<int >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
908- int id_new = *it;
908+ for (std::set<nid_type >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
909+ nid_type id_new = *it;
909910
910911 bool erase_collision = false ;
911912
@@ -923,7 +924,7 @@ void AddrManImpl::ResolveCollisions_()
923924 } else if (vvTried[tried_bucket][tried_bucket_pos] != -1 ) { // The position in the tried bucket is not empty
924925
925926 // Get the to-be-evicted address that is being tested
926- int id_old = vvTried[tried_bucket][tried_bucket_pos];
927+ nid_type id_old = vvTried[tried_bucket][tried_bucket_pos];
927928 AddrInfo& info_old = mapInfo[id_old];
928929
929930 const auto current_time{Now<NodeSeconds>()};
@@ -969,11 +970,11 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision_()
969970
970971 if (m_tried_collisions.size () == 0 ) return {};
971972
972- std::set<int >::iterator it = m_tried_collisions.begin ();
973+ std::set<nid_type >::iterator it = m_tried_collisions.begin ();
973974
974975 // Selects a random element from m_tried_collisions
975976 std::advance (it, insecure_rand.randrange (m_tried_collisions.size ()));
976- int id_new = *it;
977+ nid_type id_new = *it;
977978
978979 // If id_new not found in mapInfo remove it from m_tried_collisions
979980 if (mapInfo.count (id_new) != 1 ) {
@@ -1058,15 +1059,15 @@ int AddrManImpl::CheckAddrman() const
10581059 LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE (
10591060 strprintf (" new %i, tried %i, total %u" , nNew, nTried, vRandom.size ()), BCLog::ADDRMAN);
10601061
1061- std::unordered_set<int > setTried;
1062- std::unordered_map<int , int > mapNew;
1062+ std::unordered_set<nid_type > setTried;
1063+ std::unordered_map<nid_type , int > mapNew;
10631064 std::unordered_map<Network, NewTriedCount> local_counts;
10641065
10651066 if (vRandom.size () != (size_t )(nTried + nNew))
10661067 return -7 ;
10671068
10681069 for (const auto & entry : mapInfo) {
1069- int n = entry.first ;
1070+ nid_type n = entry.first ;
10701071 const AddrInfo& info = entry.second ;
10711072 if (info.fInTried ) {
10721073 if (!TicksSinceEpoch<std::chrono::seconds>(info.m_last_success )) {
0 commit comments