pub async fn new_from_trust_options(
        chain: Chain,
        trusted_store: Store,
        trust_options: &TrustOptions,
    ) -> Result<Self, error::Error> {
        let mut client = Self::new_from_trusted_store(chain, trusted_store, &trust_options)?;

        // If we already have a last trusted state
        if let Some(ref trusted_state) = client.last_trusted_state {
            debug!("found last trusted state");

            // Check that the last trusted header can actually be trusted with the given trust options
            client
                .check_trusted_header(trusted_state.last_header(), &trust_options)
                .await?;

            debug!("trusted header was valid");

            // If the last header we trust is below the given trusted height, we need
            // to fetch and verify the header at the given trusted height instead.
            let last_header_height = trusted_state.last_header().header().height();

            if last_header_height < trust_options.height {
                debug!(
                    last_header.height = last_header_height,
                    trust_options.height, "last header height below trust options height"
                );

                client.init_with_trust_options(trust_options).await?;
            }
        } else {
            // Otherwise, init the client with the given trusted height, etc.
            client.init_with_trust_options(trust_options).await?;
        }

        Ok(client)
    }
/// Create a new `Client` for the given `chain`, storing headers
/// in the given `trusted_store`, and verifying them with the
/// given `trust_options`.
///
/// This method is async because it needs to pull the latest header
/// from the chain, verify it, and store it.


This method is async because it needs to pull the latest header
from the chain, verify it, and store it.
This method is async because it needs to pull the latest header from the chain verify it and store it .
pub async fn new_from_trust_options(
        chain: Chain,
        trusted_store: Store,
        trust_options: &TrustOptions,
    ) -> Result<Self, error::Error> {
        let mut client = Self::new_from_trusted_store(chain, trusted_store, &trust_options)?;
        // If we already have a last trusted state
        if let Some(ref trusted_state) = client.last_trusted_state {
            debug!("found last trusted state");
            // Check that the last trusted header can actually be trusted with the given trust options
            client
                .check_trusted_header(trusted_state.last_header(), &trust_options)
                .await?;
            debug!("trusted header was valid");
            // If the last header we trust is below the given trusted height, we need
            // to fetch and verify the header at the given trusted height instead.
            let last_header_height = trusted_state.last_header().header().height();
            if last_header_height < trust_options.height {
                debug!(
                    last_header.height = last_header_height,
                    trust_options.height, "last header height below trust options height"
                );
                client.init_with_trust_options(trust_options).await?;
            }
        } else {
            // Otherwise, init the client with the given trusted height, etc.
            client.init_with_trust_options(trust_options).await?;
        }
        Ok(client)
    }
pub async fn new_from_trust_options ( chain : Chain , trusted_store : Store , trust_options : & TrustOptions , ) -> Result < Self , error :: Error > { let mut client = Self :: new_from_trusted_store ( chain , trusted_store , & trust_options ) ? ; // If we already have a last trusted state if let Some ( ref trusted_state ) = client . last_trusted_state { debug ! ( " " ) ; // Check that the last trusted header can actually be trusted with the given trust options client . check_trusted_header ( trusted_state . last_header ( ) , & trust_options ) . await ? ; debug ! ( " " ) ; // If the last header we trust is below the given trusted height, we need // to fetch and verify the header at the given trusted height instead. let last_header_height = trusted_state . last_header ( ) . header ( ) . height ( ) ; if last_header_height < trust_options . height { debug ! ( last_header height last_header_height trust_options height " " ) ; client . init_with_trust_options ( trust_options ) . await ? ; } } else { // Otherwise, init the client with the given trusted height, etc. client . init_with_trust_options ( trust_options ) . await ? ; } Ok ( client ) }
Create a new `Client` for the given `chain`, storing headers
in the given `trusted_store`, and verifying them with the
given `trust_options`.
Create a new ` Client ` for the given ` chain ` storing headers in the given ` trusted_store ` and verifying them with the given ` trust_options ` .
chain
Chain
trusted_store
Store
trust_options
&TrustOptions
chain
Chain
trusted_store
Store
trust_options
&TrustOptions