mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 15:20:49 +01:00
refactor: de-duplicate lookups
retain the values needed to prevent redundant node lookups
This commit is contained in:
parent
a13f3746dc
commit
2b6bd12eea
1 changed files with 4 additions and 6 deletions
|
@ -757,10 +757,10 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option
|
|||
|
||||
// Iterate over the positions of that bucket, starting at the initial one,
|
||||
// and looping around.
|
||||
int i;
|
||||
int i, position, node_id;
|
||||
for (i = 0; i < ADDRMAN_BUCKET_SIZE; ++i) {
|
||||
int position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
|
||||
int node_id = GetEntry(search_tried, bucket, position);
|
||||
position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
|
||||
node_id = GetEntry(search_tried, bucket, position);
|
||||
if (node_id != -1) {
|
||||
if (network.has_value()) {
|
||||
const auto it{mapInfo.find(node_id)};
|
||||
|
@ -777,9 +777,7 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option
|
|||
if (i == ADDRMAN_BUCKET_SIZE) continue;
|
||||
|
||||
// Find the entry to return.
|
||||
int position = (initial_position + i) % ADDRMAN_BUCKET_SIZE;
|
||||
int nId = GetEntry(search_tried, bucket, position);
|
||||
const auto it_found{mapInfo.find(nId)};
|
||||
const auto it_found{mapInfo.find(node_id)};
|
||||
assert(it_found != mapInfo.end());
|
||||
const AddrInfo& info{it_found->second};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue