fn prune_signed_attestations(
        &self,
        public_key: &PublicKeyBytes,
        new_min_target: Epoch,
        txn: &Transaction,
    ) -> Result<(), NotSafe> {
        let validator_id = self.get_validator_id_in_txn(txn, public_key)?;

        // The following holds:
        //   a.target < new_min_target --> a.source <= new_min_source
        //
        // The `MAX(target_epoch)` acts as a guard to prevent accidentally clearing the DB.
        txn.execute(
            "DELETE FROM signed_attestations
             WHERE
                validator_id = ?1 AND
                target_epoch < ?2 AND
                target_epoch < (SELECT MAX(target_epoch)
                                FROM signed_attestations
                                WHERE validator_id = ?1)",
            params![validator_id, new_min_target],
        )?;

        Ok(())
    }
/// Remove all attestations for `public_key` with `target < new_min_target`.
///
/// Pruning every attestation with target less than `new_min_target` also has the effect of
/// making the new minimum source the source of the attestation with `target == new_min_target`
/// (if any exists). This is exactly what's required for pruning after importing an interchange
/// file, whereby we want to update the new minimum source to the min source from the
/// interchange.
///
/// If the `new_min_target` was plucked out of thin air and doesn't necessarily correspond to
/// an extant attestation then this function is still safe. It will never delete *all* the
/// attestations in the database.
Remove all attestations for `public_key` with `target < new_min_target`.
Pruning every attestation with target less than `new_min_target` also has the effect of
making the new minimum source the source of the attestation with `target == new_min_target`
(if any exists). This is exactly what's required for pruning after importing an interchange
file, whereby we want to update the new minimum source to the min source from the
interchange.

If the `new_min_target` was plucked out of thin air and doesn't necessarily correspond to
an extant attestation then this function is still safe. It will never delete *all* the
attestations in the database.
Remove all attestations for ` public_key ` with ` target < new_min_target ` . Pruning every attestation with target less than ` new_min_target ` also has the effect of making the new minimum source the source of the attestation with ` target == new_min_target ` ( if any exists ) . This is exactly what ' s required for pruning after importing an interchange file whereby we want to update the new minimum source to the min source from the interchange . If the ` new_min_target ` was plucked out of thin air and doesn ' t necessarily correspond to an extant attestation then this function is still safe . It will never delete * all * the attestations in the database .
fn prune_signed_attestations(
        &self,
        public_key: &PublicKeyBytes,
        new_min_target: Epoch,
        txn: &Transaction,
    ) -> Result<(), NotSafe> {
        let validator_id = self.get_validator_id_in_txn(txn, public_key)?;
        // The following holds:
        //   a.target < new_min_target --> a.source <= new_min_source
        //
        // The `MAX(target_epoch)` acts as a guard to prevent accidentally clearing the DB.
        txn.execute(
            "DELETE FROM signed_attestations
             WHERE
                validator_id = ?1 AND
                target_epoch < ?2 AND
                target_epoch < (SELECT MAX(target_epoch)
                                FROM signed_attestations
                                WHERE validator_id = ?1)",
            params![validator_id, new_min_target],
        )?;
        Ok(())
    }
fn prune_signed_attestations ( & self , public_key : & PublicKeyBytes , new_min_target : Epoch , txn : & Transaction , ) -> Result < ( ) , NotSafe > { let validator_id = self . get_validator_id_in_txn ( txn , public_key ) ? ; // The following holds: //   a.target < new_min_target --> a.source <= new_min_source // // The `MAX(target_epoch)` acts as a guard to prevent accidentally clearing the DB. txn . execute ( " " , params ! [ validator_id new_min_target ] , ) ? ; Ok ( ( ) ) }
Remove all attestations for `public_key` with `target < new_min_target`.
Remove all attestations for ` public_key ` with ` target < new_min_target ` .
&self
public_key
&PublicKeyBytes
new_min_target
Epoch
txn
&Transaction