fn check_shreds(
    leader_schedule: Option<impl LeaderScheduleFn>,
    shred1: &Shred,
    shred2: &Shred,
) -> Result<(), Error> {
    if shred1.slot() != shred2.slot() {
        Err(Error::SlotMismatch)
    } else if shred1.index() != shred2.index() {
        // TODO: Should also allow two coding shreds with different indices but
        // same fec-set-index and mismatching erasure-config.
        Err(Error::ShredIndexMismatch)
    } else if shred1.shred_type() != shred2.shred_type() {
        Err(Error::ShredTypeMismatch)
    } else if shred1.payload == shred2.payload {
        Err(Error::InvalidDuplicateShreds)
    } else {
        if let Some(leader_schedule) = leader_schedule {
            let slot_leader = leader_schedule(shred1.slot()).ok_or(Error::UnknownSlotLeader)?;
            if !shred1.verify(&slot_leader) || !shred2.verify(&slot_leader) {
                return Err(Error::InvalidSignature);
            }
        }
        Ok(())
    }
}
// Asserts that the two shreds can indicate duplicate proof for
// the same triplet of (slot, shred-index, and shred-type_), and
// that they have valid signatures from the slot leader.
Asserts that the two shreds can indicate duplicate proof for
the same triplet of (slot, shred-index, and shred-type_), and
that they have valid signatures from the slot leader.
Asserts that the two shreds can indicate duplicate proof for the same triplet of ( slot shred - index and shred - type_ ) and that they have valid signatures from the slot leader .
fn check_shreds(
    leader_schedule: Option<impl LeaderScheduleFn>,
    shred1: &Shred,
    shred2: &Shred,
) -> Result<(), Error> {
    if shred1.slot() != shred2.slot() {
        Err(Error::SlotMismatch)
    } else if shred1.index() != shred2.index() {
        // TODO: Should also allow two coding shreds with different indices but
        // same fec-set-index and mismatching erasure-config.
        Err(Error::ShredIndexMismatch)
    } else if shred1.shred_type() != shred2.shred_type() {
        Err(Error::ShredTypeMismatch)
    } else if shred1.payload == shred2.payload {
        Err(Error::InvalidDuplicateShreds)
    } else {
        if let Some(leader_schedule) = leader_schedule {
            let slot_leader = leader_schedule(shred1.slot()).ok_or(Error::UnknownSlotLeader)?;
            if !shred1.verify(&slot_leader) || !shred2.verify(&slot_leader) {
                return Err(Error::InvalidSignature);
            }
        }
        Ok(())
    }
}
fn check_shreds ( leader_schedule : Option < impl LeaderScheduleFn > , shred1 : & Shred , shred2 : & Shred , ) -> Result < ( ) , Error > { if shred1 . slot ( ) != shred2 . slot ( ) { Err ( Error :: SlotMismatch ) } else if shred1 . index ( ) != shred2 . index ( ) { // TODO: Should also allow two coding shreds with different indices but // same fec-set-index and mismatching erasure-config. Err ( Error :: ShredIndexMismatch ) } else if shred1 . shred_type ( ) != shred2 . shred_type ( ) { Err ( Error :: ShredTypeMismatch ) } else if shred1 . payload == shred2 . payload { Err ( Error :: InvalidDuplicateShreds ) } else { if let Some ( leader_schedule ) = leader_schedule { let slot_leader = leader_schedule ( shred1 . slot ( ) ) . ok_or ( Error :: UnknownSlotLeader ) ? ; if ! shred1 . verify ( & slot_leader ) || ! shred2 . verify ( & slot_leader ) { return Err ( Error :: InvalidSignature ) ; } } Ok ( ( ) ) } }
Asserts that the two shreds can indicate duplicate proof for
the same triplet of (slot, shred-index, and shred-type_), and
that they have valid signatures from the slot leader.
Asserts that the two shreds can indicate duplicate proof for the same triplet of ( slot shred - index and shred - type_ ) and that they have valid signatures from the slot leader .
leader_schedule
Option<impl LeaderScheduleFn>
shred1
&Shred
shred2
&Shred