async fn init_with_trust_options(
        &mut self,
        trust_options: &TrustOptions,
    ) -> Result<(), error::Error> {
        debug!("initialize client with given trust_options");

        // TODO: Fetch from primary (?)
        let signed_header = self
            .chain
            .requester()
            .signed_header(trust_options.height)
            .await
            .map_err(|e| error::Kind::Rpc.context(e))?;

        debug!(
            trust_options.height,
            header.hash = %signed_header.header().hash(),
            "fetched header at height {}", trust_options.height
        );

        // TODO: Validate basic

        if trust_options.hash != signed_header.header().hash() {
            fail!(
                error::Kind::LightClient,
                "expected header's hash {}, but got {}",
                trust_options.hash,
                signed_header.header().hash()
            )
        }

        // TODO: Compare header with witnesses (?)

        debug!("TODO: compare header with witnesses");

        // TODO: Fetch from primary (?)
        let validator_set = self
            .chain
            .requester()
            .validator_set(trust_options.height)
            .await
            .map_err(|e| error::Kind::Rpc.context(e))?;

        debug!(
            trust_options.height,
            validator_set.hash = %validator_set.hash(),
            header.validators_hash = %signed_header.header().validators_hash(),
            "fetched validator set at height {}", trust_options.height);

        if signed_header.header().validators_hash() != validator_set.hash() {
            fail!(
                error::Kind::LightClient,
                "expected header's validators ({}) to match those that were supplied ({})",
                signed_header.header().validators_hash(),
                validator_set.hash()
            )
        }

        debug!("validator set hashes match");

        // FIXME: Is this necessary?
        signed_header
            .commit()
            .validate(&validator_set)
            .map_err(|e| error::Kind::LightClient.context(e))?;

        debug!("header is valid");

        tendermint::lite::verifier::verify_commit_trusting(
            &validator_set,
            signed_header.commit(),
            trust_options.trust_threshold,
        )
        .map_err(|e| error::Kind::LightClient.context(e))?;

        debug!("verify_commit_trusting result is valid");

        let trusted_state = TrustedState::new(signed_header, validator_set);
        self.update_trusted_state(trusted_state)?;

        Ok(())
    }
/// Initialize this client with the given trust options.
///
/// This pulls the header and validator set at the height specified in
/// the trust options, and checks their hashes against the hashes
/// specified in the trust options.
///
/// Then validate the commit against its validator set.
///
/// Then verify that +1/3 of the validator set signed the commit.
///
/// If everything succeeds, add the header to the trusted store and
/// update the last trusted state with it.
Initialize this client with the given trust options.
This pulls the header and validator set at the height specified in
the trust options, and checks their hashes against the hashes
specified in the trust options.

Then validate the commit against its validator set.

Then verify that +1/3 of the validator set signed the commit.

If everything succeeds, add the header to the trusted store and
update the last trusted state with it.
Initialize this client with the given trust options . This pulls the header and validator set at the height specified in the trust options and checks their hashes against the hashes specified in the trust options . Then validate the commit against its validator set . Then verify that + 1 / 3 of the validator set signed the commit . If everything succeeds add the header to the trusted store and update the last trusted state with it .
async fn init_with_trust_options(
        &mut self,
        trust_options: &TrustOptions,
    ) -> Result<(), error::Error> {
        debug!("initialize client with given trust_options");
        // TODO: Fetch from primary (?)
        let signed_header = self
            .chain
            .requester()
            .signed_header(trust_options.height)
            .await
            .map_err(|e| error::Kind::Rpc.context(e))?;
        debug!(
            trust_options.height,
            header.hash = %signed_header.header().hash(),
            "fetched header at height {}", trust_options.height
        );
        // TODO: Validate basic
        if trust_options.hash != signed_header.header().hash() {
            fail!(
                error::Kind::LightClient,
                "expected header's hash {}, but got {}",
                trust_options.hash,
                signed_header.header().hash()
            )
        }
        // TODO: Compare header with witnesses (?)
        debug!("TODO: compare header with witnesses");
        // TODO: Fetch from primary (?)
        let validator_set = self
            .chain
            .requester()
            .validator_set(trust_options.height)
            .await
            .map_err(|e| error::Kind::Rpc.context(e))?;
        debug!(
            trust_options.height,
            validator_set.hash = %validator_set.hash(),
            header.validators_hash = %signed_header.header().validators_hash(),
            "fetched validator set at height {}", trust_options.height);
        if signed_header.header().validators_hash() != validator_set.hash() {
            fail!(
                error::Kind::LightClient,
                "expected header's validators ({}) to match those that were supplied ({})",
                signed_header.header().validators_hash(),
                validator_set.hash()
            )
        }
        debug!("validator set hashes match");
        // FIXME: Is this necessary?
        signed_header
            .commit()
            .validate(&validator_set)
            .map_err(|e| error::Kind::LightClient.context(e))?;
        debug!("header is valid");
        tendermint::lite::verifier::verify_commit_trusting(
            &validator_set,
            signed_header.commit(),
            trust_options.trust_threshold,
        )
        .map_err(|e| error::Kind::LightClient.context(e))?;
        debug!("verify_commit_trusting result is valid");
        let trusted_state = TrustedState::new(signed_header, validator_set);
        self.update_trusted_state(trusted_state)?;
        Ok(())
    }
async fn init_with_trust_options ( & mut self , trust_options : & TrustOptions , ) -> Result < ( ) , error :: Error > { debug ! ( " " ) ; // TODO: Fetch from primary (?) let signed_header = self . chain . requester ( ) . signed_header ( trust_options . height ) . await . map_err ( | e | error :: Kind :: Rpc . context ( e ) ) ? ; debug ! ( trust_options height header hash signed_header header ( ) hash ( ) " " trust_options height ) ; // TODO: Validate basic if trust_options . hash != signed_header . header ( ) . hash ( ) { fail ! ( error Kind LightClient " " trust_options hash signed_header header ( ) hash ( ) ) } // TODO: Compare header with witnesses (?) debug ! ( " " ) ; // TODO: Fetch from primary (?) let validator_set = self . chain . requester ( ) . validator_set ( trust_options . height ) . await . map_err ( | e | error :: Kind :: Rpc . context ( e ) ) ? ; debug ! ( trust_options height validator_set hash validator_set hash ( ) header validators_hash signed_header header ( ) validators_hash ( ) " " trust_options height ) ; if signed_header . header ( ) . validators_hash ( ) != validator_set . hash ( ) { fail ! ( error Kind LightClient " " signed_header header ( ) validators_hash ( ) validator_set hash ( ) ) } debug ! ( " " ) ; // FIXME: Is this necessary? signed_header . commit ( ) . validate ( & validator_set ) . map_err ( | e | error :: Kind :: LightClient . context ( e ) ) ? ; debug ! ( " " ) ; tendermint :: lite :: verifier :: verify_commit_trusting ( & validator_set , signed_header . commit ( ) , trust_options . trust_threshold , ) . map_err ( | e | error :: Kind :: LightClient . context ( e ) ) ? ; debug ! ( " " ) ; let trusted_state = TrustedState :: new ( signed_header , validator_set ) ; self . update_trusted_state ( trusted_state ) ? ; Ok ( ( ) ) }
Initialize this client with the given trust options.
Initialize this client with the given trust options .
&mut self
trust_options
&TrustOptions
&mut self
trust_options
&TrustOptions