@@ -182,7 +182,7 @@ void AddrManImpl::Serialize(Stream& s_) const
182
182
183
183
int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30 );
184
184
s << nUBuckets;
185
- std::unordered_map<int , int > mapUnkIds;
185
+ std::unordered_map<nid_type , int > mapUnkIds;
186
186
int nIds = 0 ;
187
187
for (const auto & entry : mapInfo) {
188
188
mapUnkIds[entry.first ] = nIds;
@@ -397,7 +397,7 @@ void AddrManImpl::Unserialize(Stream& s_)
397
397
}
398
398
}
399
399
400
- AddrInfo* AddrManImpl::Find (const CService& addr, int * pnId)
400
+ AddrInfo* AddrManImpl::Find (const CService& addr, nid_type * pnId)
401
401
{
402
402
AssertLockHeld (cs);
403
403
@@ -412,11 +412,11 @@ AddrInfo* AddrManImpl::Find(const CService& addr, int* pnId)
412
412
return nullptr ;
413
413
}
414
414
415
- AddrInfo* AddrManImpl::Create (const CAddress& addr, const CNetAddr& addrSource, int * pnId)
415
+ AddrInfo* AddrManImpl::Create (const CAddress& addr, const CNetAddr& addrSource, nid_type * pnId)
416
416
{
417
417
AssertLockHeld (cs);
418
418
419
- int nId = nIdCount++;
419
+ nid_type nId = nIdCount++;
420
420
mapInfo[nId] = AddrInfo (addr, addrSource);
421
421
mapAddr[addr] = nId;
422
422
mapInfo[nId].nRandomPos = vRandom.size ();
@@ -435,8 +435,8 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
435
435
436
436
assert (nRndPos1 < vRandom.size () && nRndPos2 < vRandom.size ());
437
437
438
- int nId1 = vRandom[nRndPos1];
439
- int nId2 = vRandom[nRndPos2];
438
+ nid_type nId1 = vRandom[nRndPos1];
439
+ nid_type nId2 = vRandom[nRndPos2];
440
440
441
441
const auto it_1{mapInfo.find (nId1)};
442
442
const auto it_2{mapInfo.find (nId2)};
@@ -450,7 +450,7 @@ void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
450
450
vRandom[nRndPos2] = nId1;
451
451
}
452
452
453
- void AddrManImpl::Delete (int nId)
453
+ void AddrManImpl::Delete (nid_type nId)
454
454
{
455
455
AssertLockHeld (cs);
456
456
@@ -472,7 +472,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
472
472
473
473
// if there is an entry in the specified bucket, delete it.
474
474
if (vvNew[nUBucket][nUBucketPos] != -1 ) {
475
- int nIdDelete = vvNew[nUBucket][nUBucketPos];
475
+ nid_type nIdDelete = vvNew[nUBucket][nUBucketPos];
476
476
AddrInfo& infoDelete = mapInfo[nIdDelete];
477
477
assert (infoDelete.nRefCount > 0 );
478
478
infoDelete.nRefCount --;
@@ -484,7 +484,7 @@ void AddrManImpl::ClearNew(int nUBucket, int nUBucketPos)
484
484
}
485
485
}
486
486
487
- void AddrManImpl::MakeTried (AddrInfo& info, int nId)
487
+ void AddrManImpl::MakeTried (AddrInfo& info, nid_type nId)
488
488
{
489
489
AssertLockHeld (cs);
490
490
@@ -510,7 +510,7 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
510
510
// first make space to add it (the existing tried entry there is moved to new, deleting whatever is there).
511
511
if (vvTried[nKBucket][nKBucketPos] != -1 ) {
512
512
// find an item to evict
513
- int nIdEvict = vvTried[nKBucket][nKBucketPos];
513
+ nid_type nIdEvict = vvTried[nKBucket][nKBucketPos];
514
514
assert (mapInfo.count (nIdEvict) == 1 );
515
515
AddrInfo& infoOld = mapInfo[nIdEvict];
516
516
@@ -546,7 +546,7 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_
546
546
if (!addr.IsRoutable ())
547
547
return false ;
548
548
549
- int nId;
549
+ nid_type nId;
550
550
AddrInfo* pinfo = Find (addr, &nId);
551
551
552
552
// Do not set a penalty for a source's self-announcement
@@ -618,7 +618,7 @@ bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, int64_t nT
618
618
{
619
619
AssertLockHeld (cs);
620
620
621
- int nId;
621
+ nid_type nId;
622
622
623
623
nLastGood = nTime;
624
624
@@ -845,8 +845,8 @@ void AddrManImpl::ResolveCollisions_()
845
845
{
846
846
AssertLockHeld (cs);
847
847
848
- for (std::set<int >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
849
- int id_new = *it;
848
+ for (std::set<nid_type >::iterator it = m_tried_collisions.begin (); it != m_tried_collisions.end ();) {
849
+ nid_type id_new = *it;
850
850
851
851
bool erase_collision = false ;
852
852
@@ -864,7 +864,7 @@ void AddrManImpl::ResolveCollisions_()
864
864
} else if (vvTried[tried_bucket][tried_bucket_pos] != -1 ) { // The position in the tried bucket is not empty
865
865
866
866
// Get the to-be-evicted address that is being tested
867
- int id_old = vvTried[tried_bucket][tried_bucket_pos];
867
+ nid_type id_old = vvTried[tried_bucket][tried_bucket_pos];
868
868
AddrInfo& info_old = mapInfo[id_old];
869
869
870
870
// Has successfully connected in last X hours
@@ -908,11 +908,11 @@ std::pair<CAddress, int64_t> AddrManImpl::SelectTriedCollision_()
908
908
909
909
if (m_tried_collisions.size () == 0 ) return {};
910
910
911
- std::set<int >::iterator it = m_tried_collisions.begin ();
911
+ std::set<nid_type >::iterator it = m_tried_collisions.begin ();
912
912
913
913
// Selects a random element from m_tried_collisions
914
914
std::advance (it, insecure_rand.randrange (m_tried_collisions.size ()));
915
- int id_new = *it;
915
+ nid_type id_new = *it;
916
916
917
917
// If id_new not found in mapInfo remove it from m_tried_collisions
918
918
if (mapInfo.count (id_new) != 1 ) {
@@ -975,14 +975,14 @@ int AddrManImpl::CheckAddrman() const
975
975
LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE (
976
976
strprintf (" new %i, tried %i, total %u" , nNew, nTried, vRandom.size ()), BCLog::ADDRMAN);
977
977
978
- std::unordered_set<int > setTried;
979
- std::unordered_map<int , int > mapNew;
978
+ std::unordered_set<nid_type > setTried;
979
+ std::unordered_map<nid_type , int > mapNew;
980
980
981
981
if (vRandom.size () != (size_t )(nTried + nNew))
982
982
return -7 ;
983
983
984
984
for (const auto & entry : mapInfo) {
985
- int n = entry.first ;
985
+ nid_type n = entry.first ;
986
986
const AddrInfo& info = entry.second ;
987
987
if (info.fInTried ) {
988
988
if (!info.nLastSuccess )
0 commit comments