Skip to content
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

Closed

Conversation

countvonzero
Copy link
Contributor

Motivation

Closes #4938

@countvonzero countvonzero marked this pull request as ready for review August 31, 2023 15:02
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #4939 (58648df) into develop (1f35f08) will increase coverage by 0.0%.
The diff coverage is 89.4%.

❗ Current head 58648df differs from pull request most recent head f1ee5cd. Consider uploading reports for the commit f1ee5cd to get more accurate results

@@           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     
Files Changed Coverage Δ
fetch/interface.go 100.0% <ø> (ø)
p2p/upgrade.go 63.9% <0.0%> (-0.9%) ⬇️
fetch/cache.go 82.3% <100.0%> (-0.7%) ⬇️
fetch/fetch.go 78.1% <100.0%> (+0.2%) ⬆️

... and 5 files with indirect coverage changes

fetch/fetch.go Outdated
pm := map[p2p.Peer]struct{}{}
for _, p := range peers {
pm[p] = struct{}{}
}
Copy link
Contributor

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

Copy link
Contributor Author

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

@countvonzero
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Aug 31, 2023
@countvonzero
Copy link
Contributor Author

bors cancel

@bors
Copy link

bors bot commented Aug 31, 2023

Canceled.

@countvonzero
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Aug 31, 2023
@bors
Copy link

bors bot commented Aug 31, 2023

Build failed:

@countvonzero
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Aug 31, 2023
@bors
Copy link

bors bot commented Aug 31, 2023

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.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title fetch: check if hash peer is connected before using it [Merged by Bors] - fetch: check if hash peer is connected before using it Aug 31, 2023
@bors bors bot closed this Aug 31, 2023
Comment on lines +81 to +82
peers := maps.Keys(pm)
rng.Shuffle(len(peers), func(i, j int) { peers[i], peers[j] = peers[j], peers[i] })
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fetcher does not ensure peer is connected before requesting
3 participants