fn validated_expected_connection(
        &self,
        msg_type: ConnectionMsgType,
    ) -> Result<ConnectionEnd, ConnectionError> {
        let prefix = self
            .src_chain()
            .query_commitment_prefix()
            .map_err(|e| ConnectionError::QueryError(self.src_chain().id(), e))?;

        // If there is a connection present on the destination chain, it should look like this:
        let counterparty = Counterparty::new(
            self.src_client_id().clone(),
            Option::from(self.src_connection_id().clone()),
            prefix,
        );

        // The highest expected state, depends on the message type:
        let highest_state = match msg_type {
            ConnectionMsgType::OpenAck => State::TryOpen,
            ConnectionMsgType::OpenConfirm => State::TryOpen,
            _ => State::Uninitialized,
        };

        let versions = self
            .src_chain()
            .query_compatible_versions()
            .map_err(|e| ConnectionError::QueryError(self.src_chain().id(), e))?;

        let dst_expected_connection = ConnectionEnd::new(
            highest_state,
            self.dst_client_id().clone(),
            counterparty,
            versions,
            Duration::from_secs(0),
        );

        // Retrieve existing connection if any
        let dst_connection = self
            .dst_chain()
            .query_connection(self.dst_connection_id(), ICSHeight::default())
            .map_err(|e| ConnectionError::QueryError(self.dst_chain().id(), e))?;

        // Check if a connection is expected to exist on destination chain
        // A connection must exist on destination chain for Ack and Confirm Tx-es to succeed
        if dst_connection.state_matches(&State::Uninitialized) {
            return Err(ConnectionError::Failed(format!(
                "missing connection {} on source chain {}",
                self.src_connection_id().clone(),
                self.dst_chain().id()
            )));
        }

        check_destination_connection_state(
            self.dst_connection_id().clone(),
            dst_connection,
            dst_expected_connection.clone(),
        )?;

        Ok(dst_expected_connection)
    }
/// Retrieves the connection from destination and compares against the expected connection
/// built from the message type (`msg_type`) and options (`opts`).
/// If the expected and the destination connections are compatible, it returns the expected connection
Retrieves the connection from destination and compares against the expected connection
built from the message type (`msg_type`) and options (`opts`).
If the expected and the destination connections are compatible, it returns the expected connection
Retrieves the connection from destination and compares against the expected connection built from the message type ( ` msg_type ` ) and options ( ` opts ` ) . If the expected and the destination connections are compatible it returns the expected connection
fn validated_expected_connection(
        &self,
        msg_type: ConnectionMsgType,
    ) -> Result<ConnectionEnd, ConnectionError> {
        let prefix = self
            .src_chain()
            .query_commitment_prefix()
            .map_err(|e| ConnectionError::QueryError(self.src_chain().id(), e))?;
        // If there is a connection present on the destination chain, it should look like this:
        let counterparty = Counterparty::new(
            self.src_client_id().clone(),
            Option::from(self.src_connection_id().clone()),
            prefix,
        );
        // The highest expected state, depends on the message type:
        let highest_state = match msg_type {
            ConnectionMsgType::OpenAck => State::TryOpen,
            ConnectionMsgType::OpenConfirm => State::TryOpen,
            _ => State::Uninitialized,
        };
        let versions = self
            .src_chain()
            .query_compatible_versions()
            .map_err(|e| ConnectionError::QueryError(self.src_chain().id(), e))?;
        let dst_expected_connection = ConnectionEnd::new(
            highest_state,
            self.dst_client_id().clone(),
            counterparty,
            versions,
            Duration::from_secs(0),
        );
        // Retrieve existing connection if any
        let dst_connection = self
            .dst_chain()
            .query_connection(self.dst_connection_id(), ICSHeight::default())
            .map_err(|e| ConnectionError::QueryError(self.dst_chain().id(), e))?;
        // Check if a connection is expected to exist on destination chain
        // A connection must exist on destination chain for Ack and Confirm Tx-es to succeed
        if dst_connection.state_matches(&State::Uninitialized) {
            return Err(ConnectionError::Failed(format!(
                "missing connection {} on source chain {}",
                self.src_connection_id().clone(),
                self.dst_chain().id()
            )));
        }
        check_destination_connection_state(
            self.dst_connection_id().clone(),
            dst_connection,
            dst_expected_connection.clone(),
        )?;
        Ok(dst_expected_connection)
    }
fn validated_expected_connection ( & self , msg_type : ConnectionMsgType , ) -> Result < ConnectionEnd , ConnectionError > { let prefix = self . src_chain ( ) . query_commitment_prefix ( ) . map_err ( | e | ConnectionError :: QueryError ( self . src_chain ( ) . id ( ) , e ) ) ? ; // If there is a connection present on the destination chain, it should look like this: let counterparty = Counterparty :: new ( self . src_client_id ( ) . clone ( ) , Option :: from ( self . src_connection_id ( ) . clone ( ) ) , prefix , ) ; // The highest expected state, depends on the message type: let highest_state = match msg_type { ConnectionMsgType :: OpenAck => State :: TryOpen , ConnectionMsgType :: OpenConfirm => State :: TryOpen , _ => State :: Uninitialized , } ; let versions = self . src_chain ( ) . query_compatible_versions ( ) . map_err ( | e | ConnectionError :: QueryError ( self . src_chain ( ) . id ( ) , e ) ) ? ; let dst_expected_connection = ConnectionEnd :: new ( highest_state , self . dst_client_id ( ) . clone ( ) , counterparty , versions , Duration :: from_secs ( 0 ) , ) ; // Retrieve existing connection if any let dst_connection = self . dst_chain ( ) . query_connection ( self . dst_connection_id ( ) , ICSHeight :: default ( ) ) . map_err ( | e | ConnectionError :: QueryError ( self . dst_chain ( ) . id ( ) , e ) ) ? ; // Check if a connection is expected to exist on destination chain // A connection must exist on destination chain for Ack and Confirm Tx-es to succeed if dst_connection . state_matches ( & State :: Uninitialized ) { return Err ( ConnectionError :: Failed ( format ! ( " " self src_connection_id ( ) clone ( ) self dst_chain ( ) id ( ) ) ) ) ; } check_destination_connection_state ( self . dst_connection_id ( ) . clone ( ) , dst_connection , dst_expected_connection . clone ( ) , ) ? ; Ok ( dst_expected_connection ) }
Retrieves the connection from destination and compares against the expected connection
built from the message type (`msg_type`) and options (`opts`).
Retrieves the connection from destination and compares against the expected connection built from the message type ( ` msg_type ` ) and options ( ` opts ` ) .
&self
msg_type
ConnectionMsgType
&self
msg_type
ConnectionMsgType