From 6c19ab401deca05ea7509e48780bb0a22f5152fe Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 22 Oct 2021 08:33:39 +1000 Subject: [PATCH] Minor tweaks --- zebra-network/src/peer_set/initialize.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index 7e3f97266e3..aa3819ed06d 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -3,7 +3,6 @@ // Portions of this submodule were adapted from tower-balance, // which is (c) 2019 Tower Contributors (MIT licensed). -use rand::seq::SliceRandom; use std::{collections::HashSet, net::SocketAddr, sync::Arc}; use futures::{ @@ -13,6 +12,7 @@ use futures::{ stream::{FuturesUnordered, StreamExt}, TryFutureExt, }; +use rand::seq::SliceRandom; use tokio::{net::TcpListener, sync::broadcast, time::Instant}; use tower::{ buffer::Buffer, discover::Change, layer::Layer, load::peak_ewma::PeakEwmaDiscover, @@ -302,6 +302,8 @@ async fn limit_initial_peers(config: &Config) -> HashSet { let initial_peers_vect: Vec = initial_peers.iter().copied().collect(); + // TODO: add unused peers to the AddressBook (#2931) + // https://docs.rs/rand/0.8.4/rand/seq/trait.SliceRandom.html#tymethod.partial_shuffle initial_peers_vect .choose_multiple(&mut rand::thread_rng(), config.peerset_initial_target_size) .copied()