pub fn build_update_client_with_trusted(
        &self,
        target_height: Height,
        trusted_height: Height,
    ) -> Result<Vec<Any>, ForeignClientError> {
        // Wait for source chain to reach `target_height`
        while self.src_chain().query_latest_height().map_err(|e| {
            ForeignClientError::ClientUpdate(format!(
                "failed fetching src chain latest height with error: {}",
                e
            ))
        })? < target_height
        {
            thread::sleep(Duration::from_millis(100))
        }

        // Get the latest client state on destination.
        let client_state = self
            .dst_chain()
            .query_client_state(&self.id, Height::default())
            .map_err(|e| {
                ForeignClientError::ClientUpdate(format!(
                    "failed querying client state on dst chain {} with error: {}",
                    self.id, e
                ))
            })?;

        // If not specified, set trusted state to the highest height smaller than target height.
        // Otherwise ensure that a consensus state at trusted height exists on-chain.
        let cs_heights = self.consensus_state_heights()?;
        let trusted_height = if trusted_height == Height::zero() {
            // Get highest height smaller than target height
            cs_heights
                .into_iter()
                .find(|h| h < &target_height)
                .ok_or_else(|| {
                    ForeignClientError::ClientUpdate(format!(
                        "chain {} is missing trusted state smaller than target height {}",
                        self.dst_chain().id(),
                        target_height
                    ))
                })?
        } else {
            cs_heights
                .into_iter()
                .find(|h| h == &trusted_height)
                .ok_or_else(|| {
                    ForeignClientError::ClientUpdate(format!(
                        "chain {} is missing trusted state at height {}",
                        self.dst_chain().id(),
                        trusted_height
                    ))
                })?
        };

        if trusted_height >= target_height {
            warn!(
                "Client {} on {}: trusted height ({}) >= chain target height ({}). Omitting update message.",
                self.id, trusted_height, self.dst_chain.id(),
                target_height
            );
            return Ok(vec![]);
        }

        let header = self
            .src_chain()
            .build_header(trusted_height, target_height, client_state)
            .map_err(|e| {
                ForeignClientError::ClientUpdate(format!(
                    "failed building header with error: {}",
                    e
                ))
            })?
            .wrap_any();

        let signer = self.dst_chain().get_signer().map_err(|e| {
            ForeignClientError::ClientUpdate(format!(
                "failed getting signer for dst chain ({}) with error: {}",
                self.dst_chain.id(),
                e
            ))
        })?;
        let new_msg = MsgUpdateAnyClient {
            client_id: self.id.clone(),
            header,
            signer,
        };

        Ok(vec![new_msg.to_any()])
    }
/// Returns a vector with a message for updating the client to height `target_height`.
/// If the client already stores consensus states for this height, returns an empty vector.
Returns a vector with a message for updating the client to height `target_height`.
If the client already stores consensus states for this height, returns an empty vector.
Returns a vector with a message for updating the client to height ` target_height ` . If the client already stores consensus states for this height returns an empty vector .
pub fn build_update_client_with_trusted(
        &self,
        target_height: Height,
        trusted_height: Height,
    ) -> Result<Vec<Any>, ForeignClientError> {
        // Wait for source chain to reach `target_height`
        while self.src_chain().query_latest_height().map_err(|e| {
            ForeignClientError::ClientUpdate(format!(
                "failed fetching src chain latest height with error: {}",
                e
            ))
        })? < target_height
        {
            thread::sleep(Duration::from_millis(100))
        }
        // Get the latest client state on destination.
        let client_state = self
            .dst_chain()
            .query_client_state(&self.id, Height::default())
            .map_err(|e| {
                ForeignClientError::ClientUpdate(format!(
                    "failed querying client state on dst chain {} with error: {}",
                    self.id, e
                ))
            })?;
        // If not specified, set trusted state to the highest height smaller than target height.
        // Otherwise ensure that a consensus state at trusted height exists on-chain.
        let cs_heights = self.consensus_state_heights()?;
        let trusted_height = if trusted_height == Height::zero() {
            // Get highest height smaller than target height
            cs_heights
                .into_iter()
                .find(|h| h < &target_height)
                .ok_or_else(|| {
                    ForeignClientError::ClientUpdate(format!(
                        "chain {} is missing trusted state smaller than target height {}",
                        self.dst_chain().id(),
                        target_height
                    ))
                })?
        } else {
            cs_heights
                .into_iter()
                .find(|h| h == &trusted_height)
                .ok_or_else(|| {
                    ForeignClientError::ClientUpdate(format!(
                        "chain {} is missing trusted state at height {}",
                        self.dst_chain().id(),
                        trusted_height
                    ))
                })?
        };
        if trusted_height >= target_height {
            warn!(
                "Client {} on {}: trusted height ({}) >= chain target height ({}). Omitting update message.",
                self.id, trusted_height, self.dst_chain.id(),
                target_height
            );
            return Ok(vec![]);
        }
        let header = self
            .src_chain()
            .build_header(trusted_height, target_height, client_state)
            .map_err(|e| {
                ForeignClientError::ClientUpdate(format!(
                    "failed building header with error: {}",
                    e
                ))
            })?
            .wrap_any();
        let signer = self.dst_chain().get_signer().map_err(|e| {
            ForeignClientError::ClientUpdate(format!(
                "failed getting signer for dst chain ({}) with error: {}",
                self.dst_chain.id(),
                e
            ))
        })?;
        let new_msg = MsgUpdateAnyClient {
            client_id: self.id.clone(),
            header,
            signer,
        };
        Ok(vec![new_msg.to_any()])
    }
pub fn build_update_client_with_trusted ( & self , target_height : Height , trusted_height : Height , ) -> Result < Vec < Any > , ForeignClientError > { // Wait for source chain to reach `target_height` while self . src_chain ( ) . query_latest_height ( ) . map_err ( | e | { ForeignClientError :: ClientUpdate ( format ! ( " " e ) ) } ) ? < target_height { thread :: sleep ( Duration :: from_millis ( 100 ) ) } // Get the latest client state on destination. let client_state = self . dst_chain ( ) . query_client_state ( & self . id , Height :: default ( ) ) . map_err ( | e | { ForeignClientError :: ClientUpdate ( format ! ( " " self id e ) ) } ) ? ; // If not specified, set trusted state to the highest height smaller than target height. // Otherwise ensure that a consensus state at trusted height exists on-chain. let cs_heights = self . consensus_state_heights ( ) ? ; let trusted_height = if trusted_height == Height :: zero ( ) { // Get highest height smaller than target height cs_heights . into_iter ( ) . find ( | h | h < & target_height ) . ok_or_else ( | | { ForeignClientError :: ClientUpdate ( format ! ( " " self dst_chain ( ) id ( ) target_height ) ) } ) ? } else { cs_heights . into_iter ( ) . find ( | h | h == & trusted_height ) . ok_or_else ( | | { ForeignClientError :: ClientUpdate ( format ! ( " " self dst_chain ( ) id ( ) trusted_height ) ) } ) ? } ; if trusted_height >= target_height { warn ! ( " " self id trusted_height self dst_chain id ( ) target_height ) ; return Ok ( vec ! [ ] ) ; } let header = self . src_chain ( ) . build_header ( trusted_height , target_height , client_state ) . map_err ( | e | { ForeignClientError :: ClientUpdate ( format ! ( " " e ) ) } ) ? . wrap_any ( ) ; let signer = self . dst_chain ( ) . get_signer ( ) . map_err ( | e | { ForeignClientError :: ClientUpdate ( format ! ( " " self dst_chain id ( ) e ) ) } ) ? ; let new_msg = MsgUpdateAnyClient { client_id : self . id . clone ( ) , header , signer , } ; Ok ( vec ! [ new_msg to_any ( ) ] ) }
Returns a vector with a message for updating the client to height `target_height`.
Returns a vector with a message for updating the client to height ` target_height ` .
&self
target_height
Height
trusted_height
Height
&self
target_height
Height
trusted_height
Height