MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SelectTriedCollision_

Method SelectTriedCollision_

src/addrman.cpp:956–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954}
955
956std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision_()
957{
958 AssertLockHeld(cs);
959
960 if (m_tried_collisions.size() == 0) return {};
961
962 std::set<nid_type>::iterator it = m_tried_collisions.begin();
963
964 // Selects a random element from m_tried_collisions
965 std::advance(it, insecure_rand.randrange(m_tried_collisions.size()));
966 nid_type id_new = *it;
967
968 // If id_new not found in mapInfo remove it from m_tried_collisions
969 if (!mapInfo.contains(id_new)) {
970 m_tried_collisions.erase(it);
971 return {};
972 }
973
974 const AddrInfo& newInfo = mapInfo[id_new];
975
976 // which tried bucket to move the entry to
977 int tried_bucket = newInfo.GetTriedBucket(nKey, m_netgroupman);
978 int tried_bucket_pos = newInfo.GetBucketPosition(nKey, false, tried_bucket);
979
980 const AddrInfo& info_old = mapInfo[vvTried[tried_bucket][tried_bucket_pos]];
981 return {info_old, info_old.m_last_try};
982}
983
984std::optional<AddressPosition> AddrManImpl::FindAddressEntry_(const CAddress& addr)
985{

Callers

nothing calls this directly

Calls 7

randrangeMethod · 0.80
GetTriedBucketMethod · 0.80
GetBucketPositionMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
containsMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected