pub fn prune_slashing_protection_db(&self, current_epoch: Epoch, first_run: bool) {
        // Attempt to prune every SLASHING_PROTECTION_HISTORY_EPOCHs, with a tolerance for
        // missing the epoch that aligns exactly.
        let mut last_prune = self.slashing_protection_last_prune.lock();
        if current_epoch / SLASHING_PROTECTION_HISTORY_EPOCHS
            <= *last_prune / SLASHING_PROTECTION_HISTORY_EPOCHS
        {
            return;
        }

        if first_run {
            info!(
                self.log,
                "Pruning slashing protection DB";
                "epoch" => current_epoch,
                "msg" => "pruning may take several minutes the first time it runs"
            );
        } else {
            info!(self.log, "Pruning slashing protection DB"; "epoch" => current_epoch);
        }

        let _timer = metrics::start_timer(&metrics::SLASHING_PROTECTION_PRUNE_TIMES);

        let new_min_target_epoch = current_epoch.saturating_sub(SLASHING_PROTECTION_HISTORY_EPOCHS);
        let new_min_slot = new_min_target_epoch.start_slot(E::slots_per_epoch());

        let validators = self.validators.read();
        if let Err(e) = self
            .slashing_protection
            .prune_all_signed_attestations(validators.iter_voting_pubkeys(), new_min_target_epoch)
        {
            error!(
                self.log,
                "Error during pruning of signed attestations";
                "error" => ?e,
            );
            return;
        }

        if let Err(e) = self
            .slashing_protection
            .prune_all_signed_blocks(validators.iter_voting_pubkeys(), new_min_slot)
        {
            error!(
                self.log,
                "Error during pruning of signed blocks";
                "error" => ?e,
            );
            return;
        }

        *last_prune = current_epoch;

        info!(self.log, "Completed pruning of slashing protection DB");
    }
/// Prune the slashing protection database so that it remains performant.
///
/// This function will only do actual pruning periodically, so it should usually be
/// cheap to call. The `first_run` flag can be used to print a more verbose message when pruning
/// runs.
Prune the slashing protection database so that it remains performant.
This function will only do actual pruning periodically, so it should usually be
cheap to call. The `first_run` flag can be used to print a more verbose message when pruning
runs.
Prune the slashing protection database so that it remains performant . This function will only do actual pruning periodically so it should usually be cheap to call . The ` first_run ` flag can be used to print a more verbose message when pruning runs .
pub fn prune_slashing_protection_db(&self, current_epoch: Epoch, first_run: bool) {
        // Attempt to prune every SLASHING_PROTECTION_HISTORY_EPOCHs, with a tolerance for
        // missing the epoch that aligns exactly.
        let mut last_prune = self.slashing_protection_last_prune.lock();
        if current_epoch / SLASHING_PROTECTION_HISTORY_EPOCHS
            <= *last_prune / SLASHING_PROTECTION_HISTORY_EPOCHS
        {
            return;
        }
        if first_run {
            info!(
                self.log,
                "Pruning slashing protection DB";
                "epoch" => current_epoch,
                "msg" => "pruning may take several minutes the first time it runs"
            );
        } else {
            info!(self.log, "Pruning slashing protection DB"; "epoch" => current_epoch);
        }
        let _timer = metrics::start_timer(&metrics::SLASHING_PROTECTION_PRUNE_TIMES);
        let new_min_target_epoch = current_epoch.saturating_sub(SLASHING_PROTECTION_HISTORY_EPOCHS);
        let new_min_slot = new_min_target_epoch.start_slot(E::slots_per_epoch());
        let validators = self.validators.read();
        if let Err(e) = self
            .slashing_protection
            .prune_all_signed_attestations(validators.iter_voting_pubkeys(), new_min_target_epoch)
        {
            error!(
                self.log,
                "Error during pruning of signed attestations";
                "error" => ?e,
            );
            return;
        }
        if let Err(e) = self
            .slashing_protection
            .prune_all_signed_blocks(validators.iter_voting_pubkeys(), new_min_slot)
        {
            error!(
                self.log,
                "Error during pruning of signed blocks";
                "error" => ?e,
            );
            return;
        }
        *last_prune = current_epoch;
        info!(self.log, "Completed pruning of slashing protection DB");
    }
pub fn prune_slashing_protection_db ( & self , current_epoch : Epoch , first_run : bool ) { // Attempt to prune every SLASHING_PROTECTION_HISTORY_EPOCHs, with a tolerance for // missing the epoch that aligns exactly. let mut last_prune = self . slashing_protection_last_prune . lock ( ) ; if current_epoch / SLASHING_PROTECTION_HISTORY_EPOCHS <= * last_prune / SLASHING_PROTECTION_HISTORY_EPOCHS { return ; } if first_run { info ! ( self log " " " " current_epoch " " " " ) ; } else { info ! ( self log " " " " current_epoch ) ; } let _timer = metrics :: start_timer ( & metrics :: SLASHING_PROTECTION_PRUNE_TIMES ) ; let new_min_target_epoch = current_epoch . saturating_sub ( SLASHING_PROTECTION_HISTORY_EPOCHS ) ; let new_min_slot = new_min_target_epoch . start_slot ( E :: slots_per_epoch ( ) ) ; let validators = self . validators . read ( ) ; if let Err ( e ) = self . slashing_protection . prune_all_signed_attestations ( validators . iter_voting_pubkeys ( ) , new_min_target_epoch ) { error ! ( self log " " " " e ) ; return ; } if let Err ( e ) = self . slashing_protection . prune_all_signed_blocks ( validators . iter_voting_pubkeys ( ) , new_min_slot ) { error ! ( self log " " " " e ) ; return ; } * last_prune = current_epoch ; info ! ( self log " " ) ; }
Prune the slashing protection database so that it remains performant.
Prune the slashing protection database so that it remains performant .
&self
current_epoch
Epoch
first_run
bool