fn route_multiple(
        &mut self,
        req: Request,
        max_peers: usize,
    ) -> <Self as tower::Service<Request>>::Future {
        assert!(
            max_peers > 0,
            "requests must be routed to at least one peer"
        );
        assert!(
            max_peers <= self.ready_services.len(),
            "requests can only be routed to ready peers"
        );

        // # Security
        //
        // We choose peers randomly, ignoring load.
        // This avoids favouring malicious peers, because peers can influence their own load.
        //
        // The order of peers isn't completely random,
        // but peer request order is not security-sensitive.

        let futs = FuturesUnordered::new();
        for key in self.select_random_ready_peers(max_peers) {
            let mut svc = self
                .take_ready_service(&key)
                .expect("selected peers are ready");
            futs.push(svc.call(req.clone()).map_err(|_| ()));
            self.push_unready(key, svc);
        }

        async move {
            let results = futs.collect::<Vec<Result<_, _>>>().await;
            tracing::debug!(
                ok.len = results.iter().filter(|r| r.is_ok()).count(),
                err.len = results.iter().filter(|r| r.is_err()).count(),
                "sent peer request to multiple peers"
            );
            Ok(Response::Nil)
        }
        .boxed()
    }
/// Routes the same request to up to `max_peers` ready peers, ignoring return values.
///
/// `max_peers` must be at least one, and at most the number of ready peers.
Routes the same request to up to `max_peers` ready peers, ignoring return values.
`max_peers` must be at least one, and at most the number of ready peers.
Routes the same request to up to ` max_peers ` ready peers ignoring return values . ` max_peers ` must be at least one and at most the number of ready peers .
fn route_multiple(
        &mut self,
        req: Request,
        max_peers: usize,
    ) -> <Self as tower::Service<Request>>::Future {
        assert!(
            max_peers > 0,
            "requests must be routed to at least one peer"
        );
        assert!(
            max_peers <= self.ready_services.len(),
            "requests can only be routed to ready peers"
        );
        // # Security
        //
        // We choose peers randomly, ignoring load.
        // This avoids favouring malicious peers, because peers can influence their own load.
        //
        // The order of peers isn't completely random,
        // but peer request order is not security-sensitive.
        let futs = FuturesUnordered::new();
        for key in self.select_random_ready_peers(max_peers) {
            let mut svc = self
                .take_ready_service(&key)
                .expect("selected peers are ready");
            futs.push(svc.call(req.clone()).map_err(|_| ()));
            self.push_unready(key, svc);
        }
        async move {
            let results = futs.collect::<Vec<Result<_, _>>>().await;
            tracing::debug!(
                ok.len = results.iter().filter(|r| r.is_ok()).count(),
                err.len = results.iter().filter(|r| r.is_err()).count(),
                "sent peer request to multiple peers"
            );
            Ok(Response::Nil)
        }
        .boxed()
    }
fn route_multiple ( & mut self , req : Request , max_peers : usize , ) -> < Self as tower :: Service < Request > > :: Future { assert ! ( max_peers 0 " " ) ; assert ! ( max_peers self ready_services len ( ) " " ) ; // # Security // // We choose peers randomly, ignoring load. // This avoids favouring malicious peers, because peers can influence their own load. // // The order of peers isn't completely random, // but peer request order is not security-sensitive. let futs = FuturesUnordered :: new ( ) ; for key in self . select_random_ready_peers ( max_peers ) { let mut svc = self . take_ready_service ( & key ) . expect ( " " ) ; futs . push ( svc . call ( req . clone ( ) ) . map_err ( | _ | ( ) ) ) ; self . push_unready ( key , svc ) ; } async move { let results = futs . collect :: < Vec < Result < _ , _ > > > ( ) . await ; tracing :: debug ! ( ok len results iter ( ) filter ( r r is_ok ( ) ) count ( ) err len results iter ( ) filter ( r r is_err ( ) ) count ( ) " " ) ; Ok ( Response :: Nil ) } . boxed ( ) }
Routes the same request to up to `max_peers` ready peers, ignoring return values.
Routes the same request to up to ` max_peers ` ready peers ignoring return values .
&mut self
req
Request
max_peers
usize