fn check_block_proposal(
        &self,
        txn: &Transaction,
        validator_pubkey: &PublicKeyBytes,
        slot: Slot,
        signing_root: SigningRoot,
    ) -> Result<Safe, NotSafe> {
        let validator_id = self.get_validator_id_in_txn(txn, validator_pubkey)?;

        let existing_block = txn
            .prepare(
                "SELECT slot, signing_root
                 FROM signed_blocks
                 WHERE validator_id = ?1 AND slot = ?2",
            )?
            .query_row(params![validator_id, slot], SignedBlock::from_row)
            .optional()?;

        if let Some(existing_block) = existing_block {
            if existing_block.signing_root == signing_root {
                // Same slot and same hash -> we're re-broadcasting a previously signed block
                return Ok(Safe::SameData);
            } else {
                // Same epoch but not the same hash -> it's a DoubleBlockProposal
                return Err(NotSafe::InvalidBlock(InvalidBlock::DoubleBlockProposal(
                    existing_block,
                )));
            }
        }

        let min_slot = txn
            .prepare("SELECT MIN(slot) FROM signed_blocks WHERE validator_id = ?1")?
            .query_row(params![validator_id], |row| row.get(0))?;

        if let Some(min_slot) = min_slot {
            if slot <= min_slot {
                return Err(NotSafe::InvalidBlock(
                    InvalidBlock::SlotViolatesLowerBound {
                        block_slot: slot,
                        bound_slot: min_slot,
                    },
                ));
            }
        }

        Ok(Safe::Valid)
    }
/// Check a block proposal from `validator_pubkey` for slash safety.
Check a block proposal from `validator_pubkey` for slash safety.
Check a block proposal from ` validator_pubkey ` for slash safety .
fn check_block_proposal(
        &self,
        txn: &Transaction,
        validator_pubkey: &PublicKeyBytes,
        slot: Slot,
        signing_root: SigningRoot,
    ) -> Result<Safe, NotSafe> {
        let validator_id = self.get_validator_id_in_txn(txn, validator_pubkey)?;
        let existing_block = txn
            .prepare(
                "SELECT slot, signing_root
                 FROM signed_blocks
                 WHERE validator_id = ?1 AND slot = ?2",
            )?
            .query_row(params![validator_id, slot], SignedBlock::from_row)
            .optional()?;
        if let Some(existing_block) = existing_block {
            if existing_block.signing_root == signing_root {
                // Same slot and same hash -> we're re-broadcasting a previously signed block
                return Ok(Safe::SameData);
            } else {
                // Same epoch but not the same hash -> it's a DoubleBlockProposal
                return Err(NotSafe::InvalidBlock(InvalidBlock::DoubleBlockProposal(
                    existing_block,
                )));
            }
        }
        let min_slot = txn
            .prepare("SELECT MIN(slot) FROM signed_blocks WHERE validator_id = ?1")?
            .query_row(params![validator_id], |row| row.get(0))?;
        if let Some(min_slot) = min_slot {
            if slot <= min_slot {
                return Err(NotSafe::InvalidBlock(
                    InvalidBlock::SlotViolatesLowerBound {
                        block_slot: slot,
                        bound_slot: min_slot,
                    },
                ));
            }
        }
        Ok(Safe::Valid)
    }
fn check_block_proposal ( & self , txn : & Transaction , validator_pubkey : & PublicKeyBytes , slot : Slot , signing_root : SigningRoot , ) -> Result < Safe , NotSafe > { let validator_id = self . get_validator_id_in_txn ( txn , validator_pubkey ) ? ; let existing_block = txn . prepare ( " " , ) ? . query_row ( params ! [ validator_id slot ] , SignedBlock :: from_row ) . optional ( ) ? ; if let Some ( existing_block ) = existing_block { if existing_block . signing_root == signing_root { // Same slot and same hash -> we're re-broadcasting a previously signed block return Ok ( Safe :: SameData ) ; } else { // Same epoch but not the same hash -> it's a DoubleBlockProposal return Err ( NotSafe :: InvalidBlock ( InvalidBlock :: DoubleBlockProposal ( existing_block , ) ) ) ; } } let min_slot = txn . prepare ( " " ) ? . query_row ( params ! [ validator_id ] , | row | row . get ( 0 ) ) ? ; if let Some ( min_slot ) = min_slot { if slot <= min_slot { return Err ( NotSafe :: InvalidBlock ( InvalidBlock :: SlotViolatesLowerBound { block_slot : slot , bound_slot : min_slot , } , ) ) ; } } Ok ( Safe :: Valid ) }
Check a block proposal from `validator_pubkey` for slash safety.
Check a block proposal from ` validator_pubkey ` for slash safety .
&self
txn
&Transaction
validator_pubkey
&PublicKeyBytes
slot
Slot
signing_root
SigningRoot