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

use choose_multiple to clean get_peers() up #3457

Merged

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Oct 1, 2020

Small refactor to cleanup find_peers().
We can use choose_multiple() to conveniently find count random entries, rather than shuffling them up manually.

Copy link
Member

@quentinlesceller quentinlesceller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

.collect::<Vec<_>>();
peers[..].shuffle(&mut thread_rng());
Ok(peers.iter().take(count).cloned().collect())
.choose_multiple(&mut thread_rng(), count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

@quentinlesceller quentinlesceller merged commit f25b7ae into mimblewimble:master Oct 1, 2020
@antiochp antiochp deleted the refactor_choose_peers branch October 2, 2020 09:13
@antiochp antiochp mentioned this pull request Nov 26, 2020
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.

None yet

2 participants