@@ -537,61 +537,6 @@ void AddrManImpl::MakeTried(AddrInfo& info, int nId)
537
537
info.fInTried = true ;
538
538
}
539
539
540
- void AddrManImpl::Good_ (const CService& addr, bool test_before_evict, int64_t nTime)
541
- {
542
- AssertLockHeld (cs);
543
-
544
- int nId;
545
-
546
- nLastGood = nTime;
547
-
548
- AddrInfo* pinfo = Find (addr, &nId);
549
-
550
- // if not found, bail out
551
- if (!pinfo)
552
- return ;
553
-
554
- AddrInfo& info = *pinfo;
555
-
556
- // update info
557
- info.nLastSuccess = nTime;
558
- info.nLastTry = nTime;
559
- info.nAttempts = 0 ;
560
- // nTime is not updated here, to avoid leaking information about
561
- // currently-connected peers.
562
-
563
- // if it is already in the tried set, don't do anything else
564
- if (info.fInTried )
565
- return ;
566
-
567
- // if it is not in new, something bad happened
568
- if (!Assume (info.nRefCount > 0 )) {
569
- return ;
570
- }
571
-
572
- // which tried bucket to move the entry to
573
- int tried_bucket = info.GetTriedBucket (nKey, m_asmap);
574
- int tried_bucket_pos = info.GetBucketPosition (nKey, false , tried_bucket);
575
-
576
- // Will moving this address into tried evict another entry?
577
- if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1 )) {
578
- if (m_tried_collisions.size () < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
579
- m_tried_collisions.insert (nId);
580
- }
581
- // Output the entry we'd be colliding with, for debugging purposes
582
- auto colliding_entry = mapInfo.find (vvTried[tried_bucket][tried_bucket_pos]);
583
- LogPrint (BCLog::ADDRMAN, " Collision with %s while attempting to move %s to tried table. Collisions=%d\n " ,
584
- colliding_entry != mapInfo.end () ? colliding_entry->second .ToString () : " " ,
585
- addr.ToString (),
586
- m_tried_collisions.size ());
587
- } else {
588
- // move nId to the tried tables
589
- MakeTried (info, nId);
590
- LogPrint (BCLog::ADDRMAN, " Moved %s mapped to AS%i to tried[%i][%i]\n " ,
591
- addr.ToString (), addr.GetMappedAS (m_asmap), tried_bucket, tried_bucket_pos);
592
- }
593
- }
594
-
595
540
bool AddrManImpl::AddSingle (const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty)
596
541
{
597
542
AssertLockHeld (cs);
@@ -667,6 +612,61 @@ bool AddrManImpl::AddSingle(const CAddress& addr, const CNetAddr& source, int64_
667
612
return fInsert ;
668
613
}
669
614
615
+ void AddrManImpl::Good_ (const CService& addr, bool test_before_evict, int64_t nTime)
616
+ {
617
+ AssertLockHeld (cs);
618
+
619
+ int nId;
620
+
621
+ nLastGood = nTime;
622
+
623
+ AddrInfo* pinfo = Find (addr, &nId);
624
+
625
+ // if not found, bail out
626
+ if (!pinfo)
627
+ return ;
628
+
629
+ AddrInfo& info = *pinfo;
630
+
631
+ // update info
632
+ info.nLastSuccess = nTime;
633
+ info.nLastTry = nTime;
634
+ info.nAttempts = 0 ;
635
+ // nTime is not updated here, to avoid leaking information about
636
+ // currently-connected peers.
637
+
638
+ // if it is already in the tried set, don't do anything else
639
+ if (info.fInTried )
640
+ return ;
641
+
642
+ // if it is not in new, something bad happened
643
+ if (!Assume (info.nRefCount > 0 )) {
644
+ return ;
645
+ }
646
+
647
+ // which tried bucket to move the entry to
648
+ int tried_bucket = info.GetTriedBucket (nKey, m_asmap);
649
+ int tried_bucket_pos = info.GetBucketPosition (nKey, false , tried_bucket);
650
+
651
+ // Will moving this address into tried evict another entry?
652
+ if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1 )) {
653
+ if (m_tried_collisions.size () < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
654
+ m_tried_collisions.insert (nId);
655
+ }
656
+ // Output the entry we'd be colliding with, for debugging purposes
657
+ auto colliding_entry = mapInfo.find (vvTried[tried_bucket][tried_bucket_pos]);
658
+ LogPrint (BCLog::ADDRMAN, " Collision with %s while attempting to move %s to tried table. Collisions=%d\n " ,
659
+ colliding_entry != mapInfo.end () ? colliding_entry->second .ToString () : " " ,
660
+ addr.ToString (),
661
+ m_tried_collisions.size ());
662
+ } else {
663
+ // move nId to the tried tables
664
+ MakeTried (info, nId);
665
+ LogPrint (BCLog::ADDRMAN, " Moved %s mapped to AS%i to tried[%i][%i]\n " ,
666
+ addr.ToString (), addr.GetMappedAS (m_asmap), tried_bucket, tried_bucket_pos);
667
+ }
668
+ }
669
+
670
670
bool AddrManImpl::Add_ (const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
671
671
{
672
672
int added{0 };
0 commit comments