pub(crate) fn is_doppelganger_vertex(&self, vertex: &Vertex<C>, state: &State<C>) -> bool {
        if !self.can_vote(state) {
            return false;
        }
        match vertex {
            Vertex::Unit(swunit) => {
                // If we already have the unit in our local state,
                // we must have had created it ourselves earlier and it is now gossiped back to us.
                self.is_our_unit(swunit.wire_unit()) && !state.has_unit(&swunit.hash())
            }
            Vertex::Endorsements(endorsements) => {
                if state::TODO_ENDORSEMENT_EVIDENCE_DISABLED {
                    return false;
                }
                // Check whether the list of endorsements includes one created by a doppelganger.
                // An endorsement created by a doppelganger cannot be found in the local protocol
                // state (since we haven't created it ourselves).
                let is_ours = |(vidx, _): &(ValidatorIndex, _)| vidx == &self.vidx;
                endorsements.endorsers.iter().any(is_ours)
                    && !state.has_endorsement(endorsements.unit(), self.vidx)
            }
            Vertex::Ping(ping) => {
                // If we get a ping from ourselves with a later timestamp than the latest one we
                // know of, another node must be signing with our key.
                ping.creator() == self.vidx && !state.has_ping(self.vidx, ping.timestamp())
            }
            Vertex::Evidence(_) => false,
        }
    }
/// Returns whether the incoming vertex was signed by our key even though we don't have it yet.
/// This can only happen if another node is running with the same signing key.
Returns whether the incoming vertex was signed by our key even though we don't have it yet.
This can only happen if another node is running with the same signing key.
Returns whether the incoming vertex was signed by our key even though we don ' t have it yet . This can only happen if another node is running with the same signing key .
pub(crate) fn is_doppelganger_vertex(&self, vertex: &Vertex<C>, state: &State<C>) -> bool {
        if !self.can_vote(state) {
            return false;
        }
        match vertex {
            Vertex::Unit(swunit) => {
                // If we already have the unit in our local state,
                // we must have had created it ourselves earlier and it is now gossiped back to us.
                self.is_our_unit(swunit.wire_unit()) && !state.has_unit(&swunit.hash())
            }
            Vertex::Endorsements(endorsements) => {
                if state::TODO_ENDORSEMENT_EVIDENCE_DISABLED {
                    return false;
                }
                // Check whether the list of endorsements includes one created by a doppelganger.
                // An endorsement created by a doppelganger cannot be found in the local protocol
                // state (since we haven't created it ourselves).
                let is_ours = |(vidx, _): &(ValidatorIndex, _)| vidx == &self.vidx;
                endorsements.endorsers.iter().any(is_ours)
                    && !state.has_endorsement(endorsements.unit(), self.vidx)
            }
            Vertex::Ping(ping) => {
                // If we get a ping from ourselves with a later timestamp than the latest one we
                // know of, another node must be signing with our key.
                ping.creator() == self.vidx && !state.has_ping(self.vidx, ping.timestamp())
            }
            Vertex::Evidence(_) => false,
        }
    }
pub ( crate ) fn is_doppelganger_vertex ( & self , vertex : & Vertex < C > , state : & State < C > ) -> bool { if ! self . can_vote ( state ) { return false ; } match vertex { Vertex :: Unit ( swunit ) => { // If we already have the unit in our local state, // we must have had created it ourselves earlier and it is now gossiped back to us. self . is_our_unit ( swunit . wire_unit ( ) ) && ! state . has_unit ( & swunit . hash ( ) ) } Vertex :: Endorsements ( endorsements ) => { if state :: TODO_ENDORSEMENT_EVIDENCE_DISABLED { return false ; } // Check whether the list of endorsements includes one created by a doppelganger. // An endorsement created by a doppelganger cannot be found in the local protocol // state (since we haven't created it ourselves). let is_ours = | ( vidx , _ ) : & ( ValidatorIndex , _ ) | vidx == & self . vidx ; endorsements . endorsers . iter ( ) . any ( is_ours ) && ! state . has_endorsement ( endorsements . unit ( ) , self . vidx ) } Vertex :: Ping ( ping ) => { // If we get a ping from ourselves with a later timestamp than the latest one we // know of, another node must be signing with our key. ping . creator ( ) == self . vidx && ! state . has_ping ( self . vidx , ping . timestamp ( ) ) } Vertex :: Evidence ( _ ) => false , } }
Returns whether the incoming vertex was signed by our key even though we don't have it yet.
Returns whether the incoming vertex was signed by our key even though we don ' t have it yet .
&self
vertex
&Vertex<C>
state
&State<C>
&self
vertex
&Vertex<C>
state
&State<C>