/// Recomputes the list of pending batches
///
/// Args:
///   committed (List<Batches>): Batches committed in the current chain
///   since the root of the fork switching from.
///   uncommitted (List<Batches): Batches that were committed in the old
///   fork since the common root.
Recomputes the list of pending batches
Args:
committed (List): Batches committed in the current chain
since the root of the fork switching from.
uncommitted (List<Batches): Batches that were committed in the old
fork since the common root.
Recomputes the list of pending batches Args : committed ( List ) : Batches committed in the current chain since the root of the fork switching from . uncommitted ( List<Batches ) : Batches that were committed in the old fork since the common root .
pub fn rebuild(
        &mut self,
        committed: Option<Vec<BatchPair>>,
        uncommitted: Option<Vec<BatchPair>>,
    ) {
        let committed_set = committed
            .map(|committed| {
                committed
                    .iter()
                    .map(|i| i.batch().header_signature().to_string())
                    .collect::<HashSet<_>>()
            })
            .unwrap_or_default();
        let previous_batches = self.batches.clone();
        self.reset();
        // Uncommitted and pending are disjoint sets since batches can only be
        // committed to a chain once.
        if let Some(batch_list) = uncommitted {
            for batch in batch_list {
                if !committed_set.contains(batch.batch().header_signature()) {
                    self.append(batch);
                }
            }
        }
        for batch in previous_batches {
            if !committed_set.contains(batch.batch().header_signature()) {
                self.append(batch);
            }
        }
        gauge!(
            "publisher.BlockPublisher.pending_batch_gauge",
            self.batches.len() as i64
        );
    }
pub fn rebuild ( & mut self , committed : Option < Vec < BatchPair > > , uncommitted : Option < Vec < BatchPair > > , ) { let committed_set = committed . map ( | committed | { committed . iter ( ) . map ( | i | i . batch ( ) . header_signature ( ) . to_string ( ) ) . collect :: < HashSet < _ > > ( ) } ) . unwrap_or_default ( ) ; let previous_batches = self . batches . clone ( ) ; self . reset ( ) ; // Uncommitted and pending are disjoint sets since batches can only be // committed to a chain once. if let Some ( batch_list ) = uncommitted { for batch in batch_list { if ! committed_set . contains ( batch . batch ( ) . header_signature ( ) ) { self . append ( batch ) ; } } } for batch in previous_batches { if ! committed_set . contains ( batch . batch ( ) . header_signature ( ) ) { self . append ( batch ) ; } } gauge ! ( " " self batches len ( ) as i64 ) ; }
Recomputes the list of pending batches
Args:
committed (List<Batches>): Batches committed in the current chain
since the root of the fork switching from.
Recomputes the list of pending batches Args : committed ( List<Batches > ) : Batches committed in the current chain since the root of the fork switching from .
&mut self
committed
Option<Vec<BatchPair>>
uncommitted
Option<Vec<BatchPair>>