pub(crate) fn remove_holder_if_unresponsive(
        &mut self,
        data_id: &T,
        peer: NodeId,
    ) -> GossipAction {
        if let Some(mut state) = self.current.remove(data_id) {
            if !state.held_by_us {
                let _ = state.holders.remove(&peer);
                debug!(item=%data_id, %peer, "removed peer as a holder of the item");
                if state.holders.is_empty() {
                    // We don't hold the full data, and we don't know any holders - remove the entry
                    debug!(item=%data_id, "no further action: item now removed as no holders");
                    return GossipAction::Noop;
                }
            }
            let is_new = !state.held_by_us;
            let action = state.action(self.infection_target, self.holders_limit, is_new);
            let _ = self.current.insert(*data_id, state);
            debug!(item=%data_id, %action, "assuming peer response did not timeout");
            return action;
        }

        GossipAction::Noop
    }
/// If we hold the full data, assume `peer` provided it to us and shouldn't be removed as a
/// holder.  Otherwise, assume `peer` was unresponsive and remove from list of holders.
///
/// If this causes the list of holders to become empty, and we also don't hold the full data,
/// then this entry is removed as if we'd never heard of it.
If we hold the full data, assume `peer` provided it to us and shouldn't be removed as a
holder.  Otherwise, assume `peer` was unresponsive and remove from list of holders.

If this causes the list of holders to become empty, and we also don't hold the full data,
then this entry is removed as if we'd never heard of it.
If we hold the full data assume ` peer ` provided it to us and shouldn ' t be removed as a holder . Otherwise assume ` peer ` was unresponsive and remove from list of holders . If this causes the list of holders to become empty and we also don ' t hold the full data then this entry is removed as if we ' d never heard of it .
pub(crate) fn remove_holder_if_unresponsive(
        &mut self,
        data_id: &T,
        peer: NodeId,
    ) -> GossipAction {
        if let Some(mut state) = self.current.remove(data_id) {
            if !state.held_by_us {
                let _ = state.holders.remove(&peer);
                debug!(item=%data_id, %peer, "removed peer as a holder of the item");
                if state.holders.is_empty() {
                    // We don't hold the full data, and we don't know any holders - remove the entry
                    debug!(item=%data_id, "no further action: item now removed as no holders");
                    return GossipAction::Noop;
                }
            }
            let is_new = !state.held_by_us;
            let action = state.action(self.infection_target, self.holders_limit, is_new);
            let _ = self.current.insert(*data_id, state);
            debug!(item=%data_id, %action, "assuming peer response did not timeout");
            return action;
        }
        GossipAction::Noop
    }
pub ( crate ) fn remove_holder_if_unresponsive ( & mut self , data_id : & T , peer : NodeId , ) -> GossipAction { if let Some ( mut state ) = self . current . remove ( data_id ) { if ! state . held_by_us { let _ = state . holders . remove ( & peer ) ; debug ! ( item data_id peer " " ) ; if state . holders . is_empty ( ) { // We don't hold the full data, and we don't know any holders - remove the entry debug ! ( item data_id " " ) ; return GossipAction :: Noop ; } } let is_new = ! state . held_by_us ; let action = state . action ( self . infection_target , self . holders_limit , is_new ) ; let _ = self . current . insert ( * data_id , state ) ; debug ! ( item data_id action " " ) ; return action ; } GossipAction :: Noop }
If we hold the full data, assume `peer` provided it to us and shouldn't be removed as a
holder.
If we hold the full data assume ` peer ` provided it to us and shouldn ' t be removed as a holder .
&mut self
data_id
&T
peer
NodeId
&mut self
data_id
&T
peer
NodeId