/// The method checks whether the given signed ingress bytes constitutes a
/// valid singed ingress message.
///
/// To this end, the method converts the signed bytes into a `SignedIngress`
/// message (if possible) and verifies that the message expiry time is
/// neither in the past nor too far in the future.
The method checks whether the given signed ingress bytes constitutes a
valid singed ingress message.

To this end, the method converts the signed bytes into a `SignedIngress`
message (if possible) and verifies that the message expiry time is
neither in the past nor too far in the future.
The method checks whether the given signed ingress bytes constitutes a valid singed ingress message . To this end the method converts the signed bytes into a ` SignedIngress ` message ( if possible ) and verifies that the message expiry time is neither in the past nor too far in the future .
fn check_artifact_acceptance(
        &self,
        bytes: SignedRequestBytes,
        peer_id: &NodeId,
    ) -> Result<ArtifactAcceptance<SignedIngress>, ArtifactPoolError> {
        let msg: SignedIngress = bytes
            .try_into()
            .map_err(|err| ArtifactPoolError::ArtifactRejected(Box::new(err)))?;
        #[cfg(feature = "malicious_code")]
        {
            if self.malicious_flags.maliciously_disable_ingress_validation {
                return Ok(ArtifactAcceptance::AcceptedForProcessing(msg));
            }
        }
        let time_now = self.time_source.get_relative_time();
        // We account for a bit of drift here and accept messages with a bit longer
        // than `MAX_INGRESS_TTL` time-to-live into the ingress pool.
        // The purpose is to be a bit more permissive than the HTTP handler when the
        // ingress was first accepted because here the ingress may have come
        // from the network.
        let time_plus_ttl = time_now + MAX_INGRESS_TTL + PERMITTED_DRIFT_AT_ARTIFACT_MANAGER;
        let msg_expiry_time = msg.expiry_time();
        if msg_expiry_time < time_now {
            Err(ArtifactPoolError::MessageExpired)
        } else if msg_expiry_time > time_plus_ttl {
            debug!(
                self.log,
                "check_artifact_acceptance";
                ingress_message.message_id => format!("{}", msg.id()),
                ingress_message.reason => "message_expiry_too_far_in_future",
                ingress_message.expiry_time => Some(msg_expiry_time.as_nanos_since_unix_epoch()),
                ingress_message.batch_time => Some(time_now.as_nanos_since_unix_epoch()),
                ingress_message.batch_time_plus_ttl => Some(time_plus_ttl.as_nanos_since_unix_epoch())
            );
            Err(ArtifactPoolError::MessageExpiryTooLong)
        } else {
            self.ingress_pool
                .read()
                .unwrap()
                .check_quota(&msg, peer_id)?;
            Ok(ArtifactAcceptance::AcceptedForProcessing(msg))
        }
    }
fn check_artifact_acceptance ( & self , bytes : SignedRequestBytes , peer_id : & NodeId , ) -> Result < ArtifactAcceptance < SignedIngress > , ArtifactPoolError > { let msg : SignedIngress = bytes . try_into ( ) . map_err ( | err | ArtifactPoolError :: ArtifactRejected ( Box :: new ( err ) ) ) ? ; # [ cfg ( feature " " ) ] { if self . malicious_flags . maliciously_disable_ingress_validation { return Ok ( ArtifactAcceptance :: AcceptedForProcessing ( msg ) ) ; } } let time_now = self . time_source . get_relative_time ( ) ; // We account for a bit of drift here and accept messages with a bit longer // than `MAX_INGRESS_TTL` time-to-live into the ingress pool. // The purpose is to be a bit more permissive than the HTTP handler when the // ingress was first accepted because here the ingress may have come // from the network. let time_plus_ttl = time_now + MAX_INGRESS_TTL + PERMITTED_DRIFT_AT_ARTIFACT_MANAGER ; let msg_expiry_time = msg . expiry_time ( ) ; if msg_expiry_time < time_now { Err ( ArtifactPoolError :: MessageExpired ) } else if msg_expiry_time > time_plus_ttl { debug ! ( self log " " ingress_message message_id format ( " " msg id ( ) ) ingress_message reason " " ingress_message expiry_time Some ( msg_expiry_time as_nanos_since_unix_epoch ( ) ) ingress_message batch_time Some ( time_now as_nanos_since_unix_epoch ( ) ) ingress_message batch_time_plus_ttl Some ( time_plus_ttl as_nanos_since_unix_epoch ( ) ) ) ; Err ( ArtifactPoolError :: MessageExpiryTooLong ) } else { self . ingress_pool . read ( ) . unwrap ( ) . check_quota ( & msg , peer_id ) ? ; Ok ( ArtifactAcceptance :: AcceptedForProcessing ( msg ) ) } }
The method checks whether the given signed ingress bytes constitutes a
valid singed ingress message.
The method checks whether the given signed ingress bytes constitutes a valid singed ingress message .
&self
bytes
SignedRequestBytes
peer_id
&NodeId