fn action(
        &mut self,
        infection_target: usize,
        holders_limit: usize,
        is_new: bool,
    ) -> GossipAction {
        if self.is_finished(infection_target, holders_limit) {
            return GossipAction::Noop;
        }

        if self.held_by_us {
            let count =
                infection_target.saturating_sub(self.in_flight_count + self.infected_by_us.len());
            if count > 0 {
                self.in_flight_count += count;
                return GossipAction::ShouldGossip(ShouldGossip {
                    count,
                    exclude_peers: self.holders.clone(),
                    is_already_held: !is_new,
                });
            } else {
                return GossipAction::Noop;
            }
        }

        if is_new {
            let holder = *self
                .holders
                .iter()
                .next()
                .expect("holders cannot be empty if we don't hold the data");
            GossipAction::GetRemainder { holder }
        } else {
            GossipAction::AwaitingRemainder
        }
    }
/// Returns a `GossipAction` derived from the given state.
Returns a `GossipAction` derived from the given state.
Returns a ` GossipAction ` derived from the given state .
fn action(
        &mut self,
        infection_target: usize,
        holders_limit: usize,
        is_new: bool,
    ) -> GossipAction {
        if self.is_finished(infection_target, holders_limit) {
            return GossipAction::Noop;
        }
        if self.held_by_us {
            let count =
                infection_target.saturating_sub(self.in_flight_count + self.infected_by_us.len());
            if count > 0 {
                self.in_flight_count += count;
                return GossipAction::ShouldGossip(ShouldGossip {
                    count,
                    exclude_peers: self.holders.clone(),
                    is_already_held: !is_new,
                });
            } else {
                return GossipAction::Noop;
            }
        }
        if is_new {
            let holder = *self
                .holders
                .iter()
                .next()
                .expect("holders cannot be empty if we don't hold the data");
            GossipAction::GetRemainder { holder }
        } else {
            GossipAction::AwaitingRemainder
        }
    }
fn action ( & mut self , infection_target : usize , holders_limit : usize , is_new : bool , ) -> GossipAction { if self . is_finished ( infection_target , holders_limit ) { return GossipAction :: Noop ; } if self . held_by_us { let count = infection_target . saturating_sub ( self . in_flight_count + self . infected_by_us . len ( ) ) ; if count > 0 { self . in_flight_count += count ; return GossipAction :: ShouldGossip ( ShouldGossip { count , exclude_peers : self . holders . clone ( ) , is_already_held : ! is_new , } ) ; } else { return GossipAction :: Noop ; } } if is_new { let holder = * self . holders . iter ( ) . next ( ) . expect ( " " ) ; GossipAction :: GetRemainder { holder } } else { GossipAction :: AwaitingRemainder } }
Returns a `GossipAction` derived from the given state.
Returns a ` GossipAction ` derived from the given state .
&mut self
infection_target
usize
holders_limit
usize
is_new
bool
&mut self
infection_target
usize
holders_limit
usize
is_new
bool