fn select_closest_nodes(
        &self,
        to: &NodeProfile,
        mut profiles: Vec<&Node>,
        max: usize,
    ) -> Vec<Address> {
        // This is a bug in the way Vicinity is implemented. All profiles are sent to us in a pseudo
        // sorted order. If we then sort by proximity, we will always converge to the same
        // set of nodes (the top 20 stake pools sorted lexicographically by the hash of each nodes
        // Address). This will result in non-randomly induced links. To counter, we shuffle the
        // input first. This gives us more diversity in our pool selection, and should result in
        // better event propagation.
        profiles.shuffle(&mut rand::thread_rng());

        // Use unstable parallel sort as total number of nodes can be quite large.
        profiles.par_sort_unstable_by(|left, right| {
            to.proximity(left.profile())
                .cmp(&to.proximity(right.profile()))
        });

        profiles
            .into_iter()
            .take(max)
            .map(|v| v.address().clone())
            .collect()
    }
/// select nodes based on the proximity function (see Profile's proximity
/// member function).
select nodes based on the proximity function (see Profile's proximity
member function).
select nodes based on the proximity function ( see Profile ' s proximity member function ) .
fn select_closest_nodes(
        &self,
        to: &NodeProfile,
        mut profiles: Vec<&Node>,
        max: usize,
    ) -> Vec<Address> {
        // This is a bug in the way Vicinity is implemented. All profiles are sent to us in a pseudo
        // sorted order. If we then sort by proximity, we will always converge to the same
        // set of nodes (the top 20 stake pools sorted lexicographically by the hash of each nodes
        // Address). This will result in non-randomly induced links. To counter, we shuffle the
        // input first. This gives us more diversity in our pool selection, and should result in
        // better event propagation.
        profiles.shuffle(&mut rand::thread_rng());
        // Use unstable parallel sort as total number of nodes can be quite large.
        profiles.par_sort_unstable_by(|left, right| {
            to.proximity(left.profile())
                .cmp(&to.proximity(right.profile()))
        });
        profiles
            .into_iter()
            .take(max)
            .map(|v| v.address().clone())
            .collect()
    }
fn select_closest_nodes ( & self , to : & NodeProfile , mut profiles : Vec < & Node > , max : usize , ) -> Vec < Address > { // This is a bug in the way Vicinity is implemented. All profiles are sent to us in a pseudo // sorted order. If we then sort by proximity, we will always converge to the same // set of nodes (the top 20 stake pools sorted lexicographically by the hash of each nodes // Address). This will result in non-randomly induced links. To counter, we shuffle the // input first. This gives us more diversity in our pool selection, and should result in // better event propagation. profiles . shuffle ( & mut rand :: thread_rng ( ) ) ; // Use unstable parallel sort as total number of nodes can be quite large. profiles . par_sort_unstable_by ( | left , right | { to . proximity ( left . profile ( ) ) . cmp ( & to . proximity ( right . profile ( ) ) ) } ) ; profiles . into_iter ( ) . take ( max ) . map ( | v | v . address ( ) . clone ( ) ) . collect ( ) }
select nodes based on the proximity function (see Profile's proximity
member function).
select nodes based on the proximity function ( see Profile ' s proximity member function ) .
&self
to
&NodeProfile
profiles
Vec<&Node>
max
usize