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

Method SwapRandom

src/addrman.cpp:429–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429void AddrManImpl::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) const
430{
431 AssertLockHeld(cs);
432
433 if (nRndPos1 == nRndPos2)
434 return;
435
436 assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());
437
438 nid_type nId1 = vRandom[nRndPos1];
439 nid_type nId2 = vRandom[nRndPos2];
440
441 const auto it_1{mapInfo.find(nId1)};
442 const auto it_2{mapInfo.find(nId2)};
443 assert(it_1 != mapInfo.end());
444 assert(it_2 != mapInfo.end());
445
446 it_1->second.nRandomPos = nRndPos2;
447 it_2->second.nRandomPos = nRndPos1;
448
449 vRandom[nRndPos1] = nId2;
450 vRandom[nRndPos2] = nId1;
451}
452
453void AddrManImpl::Delete(nid_type nId)
454{

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected