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

Method SelectTriedCollision_

src/addrman.cpp:905–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905std::pair<CAddress, int64_t> AddrManImpl::SelectTriedCollision_()
906{
907 AssertLockHeld(cs);
908
909 if (m_tried_collisions.size() == 0) return {};
910
911 std::set<nid_type>::iterator it = m_tried_collisions.begin();
912
913 // Selects a random element from m_tried_collisions
914 std::advance(it, insecure_rand.randrange(m_tried_collisions.size()));
915 nid_type id_new = *it;
916
917 // If id_new not found in mapInfo remove it from m_tried_collisions
918 if (mapInfo.count(id_new) != 1) {
919 m_tried_collisions.erase(it);
920 return {};
921 }
922
923 const AddrInfo& newInfo = mapInfo[id_new];
924
925 // which tried bucket to move the entry to
926 int tried_bucket = newInfo.GetTriedBucket(nKey, m_asmap);
927 int tried_bucket_pos = newInfo.GetBucketPosition(nKey, false, tried_bucket);
928
929 const AddrInfo& info_old = mapInfo[vvTried[tried_bucket][tried_bucket_pos]];
930 return {info_old, info_old.nLastTry};
931}
932
933std::optional<AddressPosition> AddrManImpl::FindAddressEntry_(const CAddress& addr)
934{

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected