-
Notifications
You must be signed in to change notification settings - Fork 39.2k
net: call Select with reachable networks in ThreadOpenConnections
#29436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -710,7 +710,7 @@ void AddrManImpl::Attempt_(const CService& addr, bool fCountFailure, NodeSeconds | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::optional<Network> network) const | ||||||
| std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, const std::unordered_set<Network>& networks) const | ||||||
| { | ||||||
| AssertLockHeld(cs); | ||||||
|
|
||||||
|
|
@@ -719,13 +719,18 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option | |||||
| size_t new_count = nNew; | ||||||
| size_t tried_count = nTried; | ||||||
|
|
||||||
| if (network.has_value()) { | ||||||
| auto it = m_network_counts.find(*network); | ||||||
| if (it == m_network_counts.end()) return {}; | ||||||
|
|
||||||
| auto counts = it->second; | ||||||
| new_count = counts.n_new; | ||||||
| tried_count = counts.n_tried; | ||||||
| if (!networks.empty()) { | ||||||
|
brunoerg marked this conversation as resolved.
Outdated
|
||||||
| new_count = 0; | ||||||
| tried_count = 0; | ||||||
| for (auto& network : networks) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A
Suggested change
|
||||||
| auto it = m_network_counts.find(network); | ||||||
| if (it == m_network_counts.end()) { | ||||||
| continue; | ||||||
| } | ||||||
| auto counts = it->second; | ||||||
| new_count += counts.n_new; | ||||||
|
brunoerg marked this conversation as resolved.
Outdated
|
||||||
| tried_count += counts.n_tried; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (new_only && new_count == 0) return {}; | ||||||
|
|
@@ -758,9 +763,9 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::Select_(bool new_only, std::option | |||||
| position = (initial_position + i) % ADDRMAN_BUCKET_SIZE; | ||||||
| node_id = GetEntry(search_tried, bucket, position); | ||||||
| if (node_id != -1) { | ||||||
| if (network.has_value()) { | ||||||
| if (!networks.empty()) { | ||||||
| const auto it{mapInfo.find(node_id)}; | ||||||
| if (Assume(it != mapInfo.end()) && it->second.GetNetwork() == *network) break; | ||||||
| if (Assume(it != mapInfo.end()) && networks.contains(it->second.GetNetwork())) break; | ||||||
| } else { | ||||||
| break; | ||||||
| } | ||||||
|
|
@@ -1208,11 +1213,11 @@ std::pair<CAddress, NodeSeconds> AddrManImpl::SelectTriedCollision() | |||||
| return ret; | ||||||
| } | ||||||
|
|
||||||
| std::pair<CAddress, NodeSeconds> AddrManImpl::Select(bool new_only, std::optional<Network> network) const | ||||||
| std::pair<CAddress, NodeSeconds> AddrManImpl::Select(bool new_only, const std::unordered_set<Network>& networks) const | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||||||
| { | ||||||
| LOCK(cs); | ||||||
| Check(); | ||||||
| auto addrRet = Select_(new_only, network); | ||||||
| auto addrRet = Select_(new_only, networks); | ||||||
| Check(); | ||||||
| return addrRet; | ||||||
| } | ||||||
|
|
@@ -1315,9 +1320,9 @@ std::pair<CAddress, NodeSeconds> AddrMan::SelectTriedCollision() | |||||
| return m_impl->SelectTriedCollision(); | ||||||
| } | ||||||
|
|
||||||
| std::pair<CAddress, NodeSeconds> AddrMan::Select(bool new_only, std::optional<Network> network) const | ||||||
| std::pair<CAddress, NodeSeconds> AddrMan::Select(bool new_only, const std::unordered_set<Network>& networks) const | ||||||
| { | ||||||
| return m_impl->Select(new_only, network); | ||||||
| return m_impl->Select(new_only, networks); | ||||||
| } | ||||||
|
|
||||||
| std::vector<CAddress> AddrMan::GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network, const bool filtered) const | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -285,7 +285,15 @@ FUZZ_TARGET(addrman, .init = initialize_addrman) | |||||
| auto max_pct = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096); | ||||||
| auto filtered = fuzzed_data_provider.ConsumeBool(); | ||||||
| (void)const_addr_man.GetAddr(max_addresses, max_pct, network, filtered); | ||||||
| (void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool(), network); | ||||||
|
|
||||||
| std::unordered_set<Network> nets; | ||||||
| for (const auto& net : ALL_NETWORKS) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (fuzzed_data_provider.ConsumeBool()) { | ||||||
| nets.insert(net); | ||||||
| } | ||||||
| } | ||||||
| (void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool(), nets); | ||||||
|
|
||||||
| std::optional<bool> in_new; | ||||||
| if (fuzzed_data_provider.ConsumeBool()) { | ||||||
| in_new = fuzzed_data_provider.ConsumeBool(); | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.