fn after_finalization(
        &self,
        head_state: &BeaconState<T::EthSpec>,
        new_finalized_state_root: Hash256,
    ) -> Result<(), Error> {
        self.fork_choice.write().prune()?;
        let new_finalized_checkpoint = head_state.finalized_checkpoint;

        self.observed_block_producers.write().prune(
            new_finalized_checkpoint
                .epoch
                .start_slot(T::EthSpec::slots_per_epoch()),
        );

        self.snapshot_cache
            .try_write_for(BLOCK_PROCESSING_CACHE_LOCK_TIMEOUT)
            .map(|mut snapshot_cache| {
                snapshot_cache.prune(new_finalized_checkpoint.epoch);
            })
            .unwrap_or_else(|| {
                error!(
                    self.log,
                    "Failed to obtain cache write lock";
                    "lock" => "snapshot_cache",
                    "task" => "prune"
                );
            });

        self.op_pool.prune_all(head_state, self.epoch()?);

        self.store_migrator.process_finalization(
            new_finalized_state_root.into(),
            new_finalized_checkpoint,
            self.head_tracker.clone(),
        )?;

        if let Some(event_handler) = self.event_handler.as_ref() {
            if event_handler.has_finalized_subscribers() {
                event_handler.register(EventKind::FinalizedCheckpoint(SseFinalizedCheckpoint {
                    epoch: new_finalized_checkpoint.epoch,
                    block: new_finalized_checkpoint.root,
                    state: new_finalized_state_root,
                }));
            }
        }

        Ok(())
    }
/// Called after `self` has had a new block finalized.
///
/// Performs pruning and finality-based optimizations.
Called after `self` has had a new block finalized.
Performs pruning and finality-based optimizations.
Called after ` self ` has had a new block finalized . Performs pruning and finality - based optimizations .
fn after_finalization(
        &self,
        head_state: &BeaconState<T::EthSpec>,
        new_finalized_state_root: Hash256,
    ) -> Result<(), Error> {
        self.fork_choice.write().prune()?;
        let new_finalized_checkpoint = head_state.finalized_checkpoint;
        self.observed_block_producers.write().prune(
            new_finalized_checkpoint
                .epoch
                .start_slot(T::EthSpec::slots_per_epoch()),
        );
        self.snapshot_cache
            .try_write_for(BLOCK_PROCESSING_CACHE_LOCK_TIMEOUT)
            .map(|mut snapshot_cache| {
                snapshot_cache.prune(new_finalized_checkpoint.epoch);
            })
            .unwrap_or_else(|| {
                error!(
                    self.log,
                    "Failed to obtain cache write lock";
                    "lock" => "snapshot_cache",
                    "task" => "prune"
                );
            });
        self.op_pool.prune_all(head_state, self.epoch()?);
        self.store_migrator.process_finalization(
            new_finalized_state_root.into(),
            new_finalized_checkpoint,
            self.head_tracker.clone(),
        )?;
        if let Some(event_handler) = self.event_handler.as_ref() {
            if event_handler.has_finalized_subscribers() {
                event_handler.register(EventKind::FinalizedCheckpoint(SseFinalizedCheckpoint {
                    epoch: new_finalized_checkpoint.epoch,
                    block: new_finalized_checkpoint.root,
                    state: new_finalized_state_root,
                }));
            }
        }
        Ok(())
    }
fn after_finalization ( & self , head_state : & BeaconState < T :: EthSpec > , new_finalized_state_root : Hash256 , ) -> Result < ( ) , Error > { self . fork_choice . write ( ) . prune ( ) ? ; let new_finalized_checkpoint = head_state . finalized_checkpoint ; self . observed_block_producers . write ( ) . prune ( new_finalized_checkpoint . epoch . start_slot ( T :: EthSpec :: slots_per_epoch ( ) ) , ) ; self . snapshot_cache . try_write_for ( BLOCK_PROCESSING_CACHE_LOCK_TIMEOUT ) . map ( | mut snapshot_cache | { snapshot_cache . prune ( new_finalized_checkpoint . epoch ) ; } ) . unwrap_or_else ( | | { error ! ( self log " " " " " " " " " " ) ; } ) ; self . op_pool . prune_all ( head_state , self . epoch ( ) ? ) ; self . store_migrator . process_finalization ( new_finalized_state_root . into ( ) , new_finalized_checkpoint , self . head_tracker . clone ( ) , ) ? ; if let Some ( event_handler ) = self . event_handler . as_ref ( ) { if event_handler . has_finalized_subscribers ( ) { event_handler . register ( EventKind :: FinalizedCheckpoint ( SseFinalizedCheckpoint { epoch : new_finalized_checkpoint . epoch , block : new_finalized_checkpoint . root , state : new_finalized_state_root , } ) ) ; } } Ok ( ( ) ) }
Called after `self` has had a new block finalized.
Called after ` self ` has had a new block finalized .
&self
head_state
&BeaconState<T::EthSpec>
new_finalized_state_root
Hash256