-
Notifications
You must be signed in to change notification settings - Fork 214
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
[Merged by Bors] - fetch: check if hash peer is connected before using it #4939
[Merged by Bors] - fetch: check if hash peer is connected before using it #4939
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4939 +/- ##
=======================================
Coverage 77.0% 77.1%
=======================================
Files 263 263
Lines 30532 30531 -1
=======================================
+ Hits 23537 23558 +21
+ Misses 5503 5482 -21
+ Partials 1492 1491 -1
|
fetch/fetch.go
Outdated
pm := map[p2p.Peer]struct{}{} | ||
for _, p := range peers { | ||
pm[p] = struct{}{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it is better to ask host.Connected or something like that. creating a map from peer list on every request is not ideal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. will add a method that checks fh.Network().Connectedness(p) == network.Connected
bors merge |
bors cancel |
Canceled. |
bors merge |
Build failed: |
bors merge |
Pull request successfully merged into develop. Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
peers := maps.Keys(pm) | ||
rng.Shuffle(len(peers), func(i, j int) { peers[i], peers[j] = peers[j], peers[i] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maps.Keys
extracts the keys from a map
by ranging over it. range
for maps doesn't produce a deterministic order:
https://go.dev/play/p/nImOnOek6c3
So shuffling might not be necessary.
Motivation
Closes #4938