| 427 | } |
| 428 | |
| 429 | void 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 | |
| 453 | void AddrManImpl::Delete(nid_type nId) |
| 454 | { |