pub fn check_equivocation_proof<H, N>(report: EquivocationProof<H, N>) -> bool
where
    H: Clone + Encode + PartialEq,
    N: Clone + Encode + PartialEq,
{
    match report.equivocation {
        Equivocation::Prevote(equivocation) => {
            if equivocation.first.0.target_hash == equivocation.second.0.target_hash
                && equivocation.first.0.target_number == equivocation.second.0.target_number
            {
                return false;
            }
            let valid_first = check_message_signature(
                &grandpa::Message::Prevote(equivocation.first.0),
                &equivocation.identity,
                &equivocation.first.1,
                equivocation.round_number,
                report.set_id,
            );
            let valid_second = check_message_signature(
                &grandpa::Message::Prevote(equivocation.second.0),
                &equivocation.identity,
                &equivocation.second.1,
                equivocation.round_number,
                report.set_id,
            );
            return valid_first && valid_second;
        }
        Equivocation::Precommit(equivocation) => {
            if equivocation.first.0.target_hash == equivocation.second.0.target_hash
                && equivocation.first.0.target_number == equivocation.second.0.target_number
            {
                return false;
            }
            let valid_first = check_message_signature(
                &grandpa::Message::Precommit(equivocation.first.0),
                &equivocation.identity,
                &equivocation.first.1,
                equivocation.round_number,
                report.set_id,
            );
            let valid_second = check_message_signature(
                &grandpa::Message::Precommit(equivocation.second.0),
                &equivocation.identity,
                &equivocation.second.1,
                equivocation.round_number,
                report.set_id,
            );
            return valid_first && valid_second;
        }
    }
}
/// Verifies the equivocation proof by making sure that both votes target
/// different blocks and that its signatures are valid.
Verifies the equivocation proof by making sure that both votes target
different blocks and that its signatures are valid.
Verifies the equivocation proof by making sure that both votes target different blocks and that its signatures are valid .
pub fn check_equivocation_proof<H, N>(report: EquivocationProof<H, N>) -> bool
where
    H: Clone + Encode + PartialEq,
    N: Clone + Encode + PartialEq,
{
    match report.equivocation {
        Equivocation::Prevote(equivocation) => {
            if equivocation.first.0.target_hash == equivocation.second.0.target_hash
                && equivocation.first.0.target_number == equivocation.second.0.target_number
            {
                return false;
            }
            let valid_first = check_message_signature(
                &grandpa::Message::Prevote(equivocation.first.0),
                &equivocation.identity,
                &equivocation.first.1,
                equivocation.round_number,
                report.set_id,
            );
            let valid_second = check_message_signature(
                &grandpa::Message::Prevote(equivocation.second.0),
                &equivocation.identity,
                &equivocation.second.1,
                equivocation.round_number,
                report.set_id,
            );
            return valid_first && valid_second;
        }
        Equivocation::Precommit(equivocation) => {
            if equivocation.first.0.target_hash == equivocation.second.0.target_hash
                && equivocation.first.0.target_number == equivocation.second.0.target_number
            {
                return false;
            }
            let valid_first = check_message_signature(
                &grandpa::Message::Precommit(equivocation.first.0),
                &equivocation.identity,
                &equivocation.first.1,
                equivocation.round_number,
                report.set_id,
            );
            let valid_second = check_message_signature(
                &grandpa::Message::Precommit(equivocation.second.0),
                &equivocation.identity,
                &equivocation.second.1,
                equivocation.round_number,
                report.set_id,
            );
            return valid_first && valid_second;
        }
    }
}
pub fn check_equivocation_proof < H , N > ( report : EquivocationProof < H , N > ) -> bool where H : Clone + Encode + PartialEq , N : Clone + Encode + PartialEq , { match report . equivocation { Equivocation :: Prevote ( equivocation ) => { if equivocation . first . 0 . target_hash == equivocation . second . 0 . target_hash && equivocation . first . 0 . target_number == equivocation . second . 0 . target_number { return false ; } let valid_first = check_message_signature ( & grandpa :: Message :: Prevote ( equivocation . first . 0 ) , & equivocation . identity , & equivocation . first . 1 , equivocation . round_number , report . set_id , ) ; let valid_second = check_message_signature ( & grandpa :: Message :: Prevote ( equivocation . second . 0 ) , & equivocation . identity , & equivocation . second . 1 , equivocation . round_number , report . set_id , ) ; return valid_first && valid_second ; } Equivocation :: Precommit ( equivocation ) => { if equivocation . first . 0 . target_hash == equivocation . second . 0 . target_hash && equivocation . first . 0 . target_number == equivocation . second . 0 . target_number { return false ; } let valid_first = check_message_signature ( & grandpa :: Message :: Precommit ( equivocation . first . 0 ) , & equivocation . identity , & equivocation . first . 1 , equivocation . round_number , report . set_id , ) ; let valid_second = check_message_signature ( & grandpa :: Message :: Precommit ( equivocation . second . 0 ) , & equivocation . identity , & equivocation . second . 1 , equivocation . round_number , report . set_id , ) ; return valid_first && valid_second ; } } }
Verifies the equivocation proof by making sure that both votes target
different blocks and that its signatures are valid.
Verifies the equivocation proof by making sure that both votes target different blocks and that its signatures are valid .
report
EquivocationProof<H, N>
report
EquivocationProof<H, N>