pub(crate) fn new_complete_data(
        &mut self,
        data_id: &T,
        maybe_holder: Option<NodeId>,
    ) -> GossipAction {
        self.purge_finished();

        if self.finished.contains(data_id) {
            debug!(item=%data_id, "no further action: item already finished");
            return GossipAction::Noop;
        }

        let update = |state: &mut State| {
            state.holders.extend(maybe_holder);
            state.held_by_us = true;
        };

        if let Some(action) = self.update_current(data_id, update) {
            debug!(item=%data_id, %action, "item is currently being gossiped");
            return action;
        }

        // This isn't in finished or current - add a new entry to current.
        let mut state = State::default();
        update(&mut state);
        let is_new = true;
        let action = state.action(self.infection_target, self.holders_limit, is_new);
        let _ = self.current.insert(*data_id, state);
        debug!(item=%data_id, %action, "gossiping new item should begin");
        action
    }
/// We received or generated potentially new data with given ID.  If received from a peer,
/// its ID should be passed in `maybe_holder`.  If received from a client or generated on this
/// node, `maybe_holder` should be `None`.
///
/// This should only be called once we hold everything locally we need to be able to gossip it
/// onwards.  If we aren't able to gossip this data yet, call `new_partial_data` instead.
///
/// Returns whether we should gossip it, and a list of peers to exclude.
We received or generated potentially new data with given ID.  If received from a peer,
its ID should be passed in `maybe_holder`.  If received from a client or generated on this
node, `maybe_holder` should be `None`.

This should only be called once we hold everything locally we need to be able to gossip it
onwards.  If we aren't able to gossip this data yet, call `new_partial_data` instead.

Returns whether we should gossip it, and a list of peers to exclude.
We received or generated potentially new data with given ID . If received from a peer its ID should be passed in ` maybe_holder ` . If received from a client or generated on this node ` maybe_holder ` should be ` None ` . This should only be called once we hold everything locally we need to be able to gossip it onwards . If we aren ' t able to gossip this data yet call ` new_partial_data ` instead . Returns whether we should gossip it and a list of peers to exclude .
pub(crate) fn new_complete_data(
        &mut self,
        data_id: &T,
        maybe_holder: Option<NodeId>,
    ) -> GossipAction {
        self.purge_finished();
        if self.finished.contains(data_id) {
            debug!(item=%data_id, "no further action: item already finished");
            return GossipAction::Noop;
        }
        let update = |state: &mut State| {
            state.holders.extend(maybe_holder);
            state.held_by_us = true;
        };
        if let Some(action) = self.update_current(data_id, update) {
            debug!(item=%data_id, %action, "item is currently being gossiped");
            return action;
        }
        // This isn't in finished or current - add a new entry to current.
        let mut state = State::default();
        update(&mut state);
        let is_new = true;
        let action = state.action(self.infection_target, self.holders_limit, is_new);
        let _ = self.current.insert(*data_id, state);
        debug!(item=%data_id, %action, "gossiping new item should begin");
        action
    }
pub ( crate ) fn new_complete_data ( & mut self , data_id : & T , maybe_holder : Option < NodeId > , ) -> GossipAction { self . purge_finished ( ) ; if self . finished . contains ( data_id ) { debug ! ( item data_id " " ) ; return GossipAction :: Noop ; } let update = | state : & mut State | { state . holders . extend ( maybe_holder ) ; state . held_by_us = true ; } ; if let Some ( action ) = self . update_current ( data_id , update ) { debug ! ( item data_id action " " ) ; return action ; } // This isn't in finished or current - add a new entry to current. let mut state = State :: default ( ) ; update ( & mut state ) ; let is_new = true ; let action = state . action ( self . infection_target , self . holders_limit , is_new ) ; let _ = self . current . insert ( * data_id , state ) ; debug ! ( item data_id action " " ) ; action }
We received or generated potentially new data with given ID.
We received or generated potentially new data with given ID .
&mut self
data_id
&T
maybe_holder
Option<NodeId>
&mut self
data_id
&T
maybe_holder
Option<NodeId>