async fn verify_header(
        &mut self,
        new_header: &SignedHeader<Chain::Commit, Chain::Header>,
        now: SystemTime,
    ) -> Result<(), error::Error> {
        let in_store = self
            .trusted_store
            .get(StoreHeight::Given(new_header.header().height()));

        // If the given header height is already in the store
        if let Ok(state) = in_store {
            let stored_header = state.last_header().header();

            // ... but it does not match the stored hash, then we fail
            if stored_header.hash() != new_header.header().hash() {
                fail!(
                    error::Kind::LightClient,
                    "existing trusted header {} does not match new header {}",
                    stored_header.hash(),
                    new_header.header().hash()
                )
            }
        }

        // If we already have a trusted state, we attempt bisection for the
        // new header at the given height. If it succeeds, we add the new
        // trusted states to the store and update our last trusted state.
        if let Some(ref last_trusted_state) = self.last_trusted_state {
            let new_header_height = new_header.header().height();

            let new_trusted_states = tendermint::lite::verifier::verify_bisection(
                last_trusted_state.clone(),
                new_header_height,
                self.trust_threshold,
                self.trusting_period,
                now,
                self.chain.requester(),
            )
            .await
            .map_err(|e| error::Kind::LightClient.context(e))?;

            for new_trusted_state in new_trusted_states {
                self.update_trusted_state(new_trusted_state)?;
            }

            Ok(())
        } else {
            fail!(
                error::Kind::LightClient,
                "no current trusted state to verify new header with"
            )
        }
    }
/// Verify the given signed header and validator set against the
/// trusted store.
///
/// If the given header is already in the store, but it does not match
/// the stored hash, we fail with an error.
///
/// Otherwise, and only if we already have a trusted state,
/// we attempt bisection for the new header at the given height.
/// If this succeeds, we add the new trusted states to the store and
/// update our last trusted state.
///
/// In any other case, we fail with an error.
Verify the given signed header and validator set against the
trusted store.

If the given header is already in the store, but it does not match
the stored hash, we fail with an error.

Otherwise, and only if we already have a trusted state,
we attempt bisection for the new header at the given height.
If this succeeds, we add the new trusted states to the store and
update our last trusted state.

In any other case, we fail with an error.
Verify the given signed header and validator set against the trusted store . If the given header is already in the store but it does not match the stored hash we fail with an error . Otherwise and only if we already have a trusted state we attempt bisection for the new header at the given height . If this succeeds we add the new trusted states to the store and update our last trusted state . In any other case we fail with an error .
async fn verify_header(
        &mut self,
        new_header: &SignedHeader<Chain::Commit, Chain::Header>,
        now: SystemTime,
    ) -> Result<(), error::Error> {
        let in_store = self
            .trusted_store
            .get(StoreHeight::Given(new_header.header().height()));
        // If the given header height is already in the store
        if let Ok(state) = in_store {
            let stored_header = state.last_header().header();
            // ... but it does not match the stored hash, then we fail
            if stored_header.hash() != new_header.header().hash() {
                fail!(
                    error::Kind::LightClient,
                    "existing trusted header {} does not match new header {}",
                    stored_header.hash(),
                    new_header.header().hash()
                )
            }
        }
        // If we already have a trusted state, we attempt bisection for the
        // new header at the given height. If it succeeds, we add the new
        // trusted states to the store and update our last trusted state.
        if let Some(ref last_trusted_state) = self.last_trusted_state {
            let new_header_height = new_header.header().height();
            let new_trusted_states = tendermint::lite::verifier::verify_bisection(
                last_trusted_state.clone(),
                new_header_height,
                self.trust_threshold,
                self.trusting_period,
                now,
                self.chain.requester(),
            )
            .await
            .map_err(|e| error::Kind::LightClient.context(e))?;
            for new_trusted_state in new_trusted_states {
                self.update_trusted_state(new_trusted_state)?;
            }
            Ok(())
        } else {
            fail!(
                error::Kind::LightClient,
                "no current trusted state to verify new header with"
            )
        }
    }
async fn verify_header ( & mut self , new_header : & SignedHeader < Chain :: Commit , Chain :: Header > , now : SystemTime , ) -> Result < ( ) , error :: Error > { let in_store = self . trusted_store . get ( StoreHeight :: Given ( new_header . header ( ) . height ( ) ) ) ; // If the given header height is already in the store if let Ok ( state ) = in_store { let stored_header = state . last_header ( ) . header ( ) ; // ... but it does not match the stored hash, then we fail if stored_header . hash ( ) != new_header . header ( ) . hash ( ) { fail ! ( error Kind LightClient " " stored_header hash ( ) new_header header ( ) hash ( ) ) } } // If we already have a trusted state, we attempt bisection for the // new header at the given height. If it succeeds, we add the new // trusted states to the store and update our last trusted state. if let Some ( ref last_trusted_state ) = self . last_trusted_state { let new_header_height = new_header . header ( ) . height ( ) ; let new_trusted_states = tendermint :: lite :: verifier :: verify_bisection ( last_trusted_state . clone ( ) , new_header_height , self . trust_threshold , self . trusting_period , now , self . chain . requester ( ) , ) . await . map_err ( | e | error :: Kind :: LightClient . context ( e ) ) ? ; for new_trusted_state in new_trusted_states { self . update_trusted_state ( new_trusted_state ) ? ; } Ok ( ( ) ) } else { fail ! ( error Kind LightClient " " ) } }
Verify the given signed header and validator set against the
trusted store.
Verify the given signed header and validator set against the trusted store .
&mut self
new_header
&SignedHeader<Chain::Commit, Chain::Header>
now
SystemTime
&mut self
new_header
&SignedHeader<Chain::Commit, Chain::Header>
now
SystemTime