async fn spawn_add_initial_peers<C>(
    peer_count: usize,
    outbound_connector: C,
) -> (
    JoinHandle<Result<ActiveConnectionCounter, BoxError>>,
    mpsc::Receiver<DiscoveredPeer>,
    JoinHandle<Result<(), BoxError>>,
)
where
    C: Service<OutboundConnectorRequest, Response = (SocketAddr, peer::Client), Error = BoxError>
        + Clone
        + Send
        + 'static,
    C::Future: Send + 'static,
{
    // Create a list of dummy IPs and initialize a config using them as the
    // initial peers.
    let mut peers = HashSet::new();
    for address_number in 0..peer_count {
        peers.insert(
            SocketAddr::new(Ipv4Addr::new(127, 1, 1, address_number as _).into(), 1).to_string(),
        );
    }

    // This address isn't actually bound - it just gets passed to the address book.
    let unused_v4 = "0.0.0.0:0".parse().unwrap();

    let config = Config {
        initial_mainnet_peers: peers,

        network: Network::Mainnet,
        listen_addr: unused_v4,

        ..Config::default()
    };

    let (peerset_tx, peerset_rx) = mpsc::channel::<DiscoveredPeer>(peer_count + 1);

    let (_address_book, address_book_updater, _address_metrics, address_book_updater_guard) =
        AddressBookUpdater::spawn(&config, unused_v4);

    let add_fut = add_initial_peers(config, outbound_connector, peerset_tx, address_book_updater);
    let add_task_handle = tokio::spawn(add_fut);

    (add_task_handle, peerset_rx, address_book_updater_guard)
}
/// Initialize a task that connects to `peer_count` initial peers using the
/// given connector.
///
/// Connects to IP addresses in the IPv4 localhost range.
/// Does not open a local listener port.
///
/// Returns the initial peers task [`JoinHandle`], the peer set receiver,
/// and the address book updater task join handle.
Initialize a task that connects to `peer_count` initial peers using the
given connector.

Connects to IP addresses in the IPv4 localhost range.
Does not open a local listener port.

Returns the initial peers task [`JoinHandle`], the peer set receiver,
and the address book updater task join handle.
Initialize a task that connects to ` peer_count ` initial peers using the given connector . Connects to IP addresses in the IPv4 localhost range . Does not open a local listener port . Returns the initial peers task [ ` JoinHandle ` ] the peer set receiver and the address book updater task join handle .
async fn spawn_add_initial_peers<C>(
    peer_count: usize,
    outbound_connector: C,
) -> (
    JoinHandle<Result<ActiveConnectionCounter, BoxError>>,
    mpsc::Receiver<DiscoveredPeer>,
    JoinHandle<Result<(), BoxError>>,
)
where
    C: Service<OutboundConnectorRequest, Response = (SocketAddr, peer::Client), Error = BoxError>
        + Clone
        + Send
        + 'static,
    C::Future: Send + 'static,
{
    // Create a list of dummy IPs and initialize a config using them as the
    // initial peers.
    let mut peers = HashSet::new();
    for address_number in 0..peer_count {
        peers.insert(
            SocketAddr::new(Ipv4Addr::new(127, 1, 1, address_number as _).into(), 1).to_string(),
        );
    }
    // This address isn't actually bound - it just gets passed to the address book.
    let unused_v4 = "0.0.0.0:0".parse().unwrap();
    let config = Config {
        initial_mainnet_peers: peers,
        network: Network::Mainnet,
        listen_addr: unused_v4,
        ..Config::default()
    };
    let (peerset_tx, peerset_rx) = mpsc::channel::<DiscoveredPeer>(peer_count + 1);
    let (_address_book, address_book_updater, _address_metrics, address_book_updater_guard) =
        AddressBookUpdater::spawn(&config, unused_v4);
    let add_fut = add_initial_peers(config, outbound_connector, peerset_tx, address_book_updater);
    let add_task_handle = tokio::spawn(add_fut);
    (add_task_handle, peerset_rx, address_book_updater_guard)
}
async fn spawn_add_initial_peers < C > ( peer_count : usize , outbound_connector : C , ) -> ( JoinHandle < Result < ActiveConnectionCounter , BoxError > > , mpsc :: Receiver < DiscoveredPeer > , JoinHandle < Result < ( ) , BoxError > > , ) where C : Service < OutboundConnectorRequest , Response = ( SocketAddr , peer :: Client ) , Error = BoxError > + Clone + Send + ' static , C :: Future : Send + ' static , { // Create a list of dummy IPs and initialize a config using them as the // initial peers. let mut peers = HashSet :: new ( ) ; for address_number in 0 .. peer_count { peers . insert ( SocketAddr :: new ( Ipv4Addr :: new ( 127 , 1 , 1 , address_number as _ ) . into ( ) , 1 ) . to_string ( ) , ) ; } // This address isn't actually bound - it just gets passed to the address book. let unused_v4 = " " . parse ( ) . unwrap ( ) ; let config = Config { initial_mainnet_peers : peers , network : Network :: Mainnet , listen_addr : unused_v4 , .. Config :: default ( ) } ; let ( peerset_tx , peerset_rx ) = mpsc :: channel :: < DiscoveredPeer > ( peer_count + 1 ) ; let ( _address_book , address_book_updater , _address_metrics , address_book_updater_guard ) = AddressBookUpdater :: spawn ( & config , unused_v4 ) ; let add_fut = add_initial_peers ( config , outbound_connector , peerset_tx , address_book_updater ) ; let add_task_handle = tokio :: spawn ( add_fut ) ; ( add_task_handle , peerset_rx , address_book_updater_guard ) }
Initialize a task that connects to `peer_count` initial peers using the
given connector.
Initialize a task that connects to ` peer_count ` initial peers using the given connector .
peer_count
usize
outbound_connector
C