fn on_artifact(
        &self,
        time_source: &dyn TimeSource,
        artifact: artifact::Artifact,
        advert: p2p::GossipAdvert,
        peer_id: NodeId,
    ) -> Result<(), OnArtifactError<artifact::Artifact>> {
        match (artifact.try_into(), advert.try_into()) {
            (Ok(msg), Ok(advert)) => {
                let result = self
                    .client
                    .as_ref()
                    .check_artifact_acceptance(msg, &peer_id)?;
                match result {
                    ArtifactAcceptance::Processed => (),
                    ArtifactAcceptance::AcceptedForProcessing(message) => {
                        Artifact::check_advert(&message, &advert).map_err(|expected| {
                            AdvertMismatchError {
                                received: advert.into(),
                                expected: expected.into(),
                            }
                        })?;
                        // this sends to an unbounded channel, which is what we want here
                        self.processor.on_artifact(UnvalidatedArtifact {
                            message,
                            peer_id,
                            timestamp: time_source.get_relative_time(),
                        })
                    }
                };
                Ok(())
            }
            (Err(artifact), _) => Err(OnArtifactError::NotProcessed(Box::new(artifact))),
            (_, Err(advert)) => Err(OnArtifactError::MessageConversionfailed(advert)),
        }
    }
/// The method is called when the given artifact is received.
The method is called when the given artifact is received.
The method is called when the given artifact is received .
fn on_artifact(
        &self,
        time_source: &dyn TimeSource,
        artifact: artifact::Artifact,
        advert: p2p::GossipAdvert,
        peer_id: NodeId,
    ) -> Result<(), OnArtifactError<artifact::Artifact>> {
        match (artifact.try_into(), advert.try_into()) {
            (Ok(msg), Ok(advert)) => {
                let result = self
                    .client
                    .as_ref()
                    .check_artifact_acceptance(msg, &peer_id)?;
                match result {
                    ArtifactAcceptance::Processed => (),
                    ArtifactAcceptance::AcceptedForProcessing(message) => {
                        Artifact::check_advert(&message, &advert).map_err(|expected| {
                            AdvertMismatchError {
                                received: advert.into(),
                                expected: expected.into(),
                            }
                        })?;
                        // this sends to an unbounded channel, which is what we want here
                        self.processor.on_artifact(UnvalidatedArtifact {
                            message,
                            peer_id,
                            timestamp: time_source.get_relative_time(),
                        })
                    }
                };
                Ok(())
            }
            (Err(artifact), _) => Err(OnArtifactError::NotProcessed(Box::new(artifact))),
            (_, Err(advert)) => Err(OnArtifactError::MessageConversionfailed(advert)),
        }
    }
fn on_artifact ( & self , time_source : & dyn TimeSource , artifact : artifact :: Artifact , advert : p2p :: GossipAdvert , peer_id : NodeId , ) -> Result < ( ) , OnArtifactError < artifact :: Artifact > > { match ( artifact . try_into ( ) , advert . try_into ( ) ) { ( Ok ( msg ) , Ok ( advert ) ) => { let result = self . client . as_ref ( ) . check_artifact_acceptance ( msg , & peer_id ) ? ; match result { ArtifactAcceptance :: Processed => ( ) , ArtifactAcceptance :: AcceptedForProcessing ( message ) => { Artifact :: check_advert ( & message , & advert ) . map_err ( | expected | { AdvertMismatchError { received : advert . into ( ) , expected : expected . into ( ) , } } ) ? ; // this sends to an unbounded channel, which is what we want here self . processor . on_artifact ( UnvalidatedArtifact { message , peer_id , timestamp : time_source . get_relative_time ( ) , } ) } } ; Ok ( ( ) ) } ( Err ( artifact ) , _ ) => Err ( OnArtifactError :: NotProcessed ( Box :: new ( artifact ) ) ) , ( _ , Err ( advert ) ) => Err ( OnArtifactError :: MessageConversionfailed ( advert ) ) , } }
The method is called when the given artifact is received.
The method is called when the given artifact is received .
&self
time_source
&dyn TimeSource
artifact
artifact::Artifact
advert
p2p::GossipAdvert
peer_id
NodeId
&self
time_source
&dyn TimeSource
artifact
artifact::Artifact
advert
p2p::GossipAdvert
peer_id
NodeId