/// In the event of a ReOrg, resubmit all ReOrged transactions into the Mempool and process each newly introduced
/// block from the latest longest chain.
In the event of a ReOrg, resubmit all ReOrged transactions into the Mempool and process each newly introduced
block from the latest longest chain.
In the event of a ReOrg resubmit all ReOrged transactions into the Mempool and process each newly introduced block from the latest longest chain .
pub fn process_reorg(
        &mut self,
        removed_blocks: Vec<Arc<Block>>,
        new_blocks: Vec<Arc<Block>>,
    ) -> Result<(), MempoolError>
    {
        debug!(target: LOG_TARGET, "Mempool processing reorg");
        for block in &removed_blocks {
            debug!(
                target: LOG_TARGET,
                "Mempool processing reorg removed block {} ({})",
                block.header.height,
                block.header.hash().to_hex(),
            );
        }
        for block in &new_blocks {
            debug!(
                target: LOG_TARGET,
                "Mempool processing reorg added new block {} ({})",
                block.header.height,
                block.header.hash().to_hex(),
            );
        }
        let previous_tip = removed_blocks.last().map(|block| block.header.height);
        let new_tip = new_blocks.last().map(|block| block.header.height);
        self.insert_txs(
            self.reorg_pool
                .remove_reorged_txs_and_discard_double_spends(removed_blocks, &new_blocks)?,
        )?;
        self.process_published_blocks(new_blocks)?;
        if let (Some(previous_tip_height), Some(new_tip_height)) = (previous_tip, new_tip) {
            if new_tip_height < previous_tip_height {
                debug!(
                    target: LOG_TARGET,
                    "Checking for time locked transactions in unconfirmed pool as chain height was reduced from {} to \
                     {} during reorg.",
                    previous_tip_height,
                    new_tip_height,
                );
                self.pending_pool
                    .insert_txs(self.unconfirmed_pool.remove_timelocked(new_tip_height))?;
            } else {
                debug!(
                    target: LOG_TARGET,
                    "No need to check for time locked transactions in unconfirmed pool. Previous tip height: {}. New \
                     tip height: {}.",
                    previous_tip_height,
                    new_tip_height,
                );
            }
        }
        Ok(())
    }
pub fn process_reorg ( & mut self , removed_blocks : Vec < Arc < Block > > , new_blocks : Vec < Arc < Block > > , ) -> Result < ( ) , MempoolError > { debug ! ( target LOG_TARGET " " ) ; for block in & removed_blocks { debug ! ( target LOG_TARGET " " block header height block header hash ( ) to_hex ( ) ) ; } for block in & new_blocks { debug ! ( target LOG_TARGET " " block header height block header hash ( ) to_hex ( ) ) ; } let previous_tip = removed_blocks . last ( ) . map ( | block | block . header . height ) ; let new_tip = new_blocks . last ( ) . map ( | block | block . header . height ) ; self . insert_txs ( self . reorg_pool . remove_reorged_txs_and_discard_double_spends ( removed_blocks , & new_blocks ) ? , ) ? ; self . process_published_blocks ( new_blocks ) ? ; if let ( Some ( previous_tip_height ) , Some ( new_tip_height ) ) = ( previous_tip , new_tip ) { if new_tip_height < previous_tip_height { debug ! ( target LOG_TARGET " \
 " previous_tip_height new_tip_height ) ; self . pending_pool . insert_txs ( self . unconfirmed_pool . remove_timelocked ( new_tip_height ) ) ? ; } else { debug ! ( target LOG_TARGET " \
 " previous_tip_height new_tip_height ) ; } } Ok ( ( ) ) }
In the event of a ReOrg, resubmit all ReOrged transactions into the Mempool and process each newly introduced
block from the latest longest chain.
In the event of a ReOrg resubmit all ReOrged transactions into the Mempool and process each newly introduced block from the latest longest chain .
&mut self
removed_blocks
Vec<Arc<Block>>
new_blocks
Vec<Arc<Block>>