MCPcopy Create free account
hub / github.com/ElementsProject/elements / Good_

Method Good_

src/addrman.cpp:617–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617bool AddrManImpl::Good_(const CService& addr, bool test_before_evict, int64_t nTime)
618{
619 AssertLockHeld(cs);
620
621 nid_type nId;
622
623 nLastGood = nTime;
624
625 AddrInfo* pinfo = Find(addr, &nId);
626
627 // if not found, bail out
628 if (!pinfo) return false;
629
630 AddrInfo& info = *pinfo;
631
632 // update info
633 info.nLastSuccess = nTime;
634 info.nLastTry = nTime;
635 info.nAttempts = 0;
636 // nTime is not updated here, to avoid leaking information about
637 // currently-connected peers.
638
639 // if it is already in the tried set, don't do anything else
640 if (info.fInTried) return false;
641
642 // if it is not in new, something bad happened
643 if (!Assume(info.nRefCount > 0)) return false;
644
645
646 // which tried bucket to move the entry to
647 int tried_bucket = info.GetTriedBucket(nKey, m_asmap);
648 int tried_bucket_pos = info.GetBucketPosition(nKey, false, tried_bucket);
649
650 // Will moving this address into tried evict another entry?
651 if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) {
652 if (m_tried_collisions.size() < ADDRMAN_SET_TRIED_COLLISION_SIZE) {
653 m_tried_collisions.insert(nId);
654 }
655 // Output the entry we'd be colliding with, for debugging purposes
656 auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
657 LogPrint(BCLog::ADDRMAN, "Collision with %s while attempting to move %s to tried table. Collisions=%d\n",
658 colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "",
659 addr.ToString(),
660 m_tried_collisions.size());
661 return false;
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 return true;
668 }
669}
670
671bool AddrManImpl::Add_(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty)
672{

Callers

nothing calls this directly

Calls 8

GetTriedBucketMethod · 0.80
GetBucketPositionMethod · 0.80
findMethod · 0.80
GetMappedASMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected