pub async fn update(
        &mut self,
        now: SystemTime,
    ) -> Result<Option<SignedHeader<Chain::Commit, Chain::Header>>, error::Error> {
        match self.last_trusted_state {
            Some(ref last_trusted_state) => {
                let last_trusted_height = last_trusted_state.last_header().header().height();

                let latest_header = self
                    .chain
                    .requester()
                    .signed_header(0)
                    .await
                    .map_err(|e| error::Kind::LightClient.context(e))?;

                if latest_header.header().height() > last_trusted_height {
                    self.verify_header(&latest_header, now).await?;

                    Ok(Some(latest_header))
                } else {
                    Ok(None)
                }
            }
            None => fail!(error::Kind::LightClient, "can't get last trusted state"),
        }
    }
/// Fetch and verify the latest header from the chain
///
/// If the fetched header is higher than the previous trusted state,
/// and it verifies then we succeed and return it wrapped in `Some(_)`.
///
/// If it is higher but does not verify we fail with an error.
///
/// If it is lower we succeed but return `None`.
///
/// If there is no trusted state yet we fail with an error.
Fetch and verify the latest header from the chain
If the fetched header is higher than the previous trusted state,
and it verifies then we succeed and return it wrapped in `Some(_)`.

If it is higher but does not verify we fail with an error.

If it is lower we succeed but return `None`.

If there is no trusted state yet we fail with an error.
Fetch and verify the latest header from the chain If the fetched header is higher than the previous trusted state and it verifies then we succeed and return it wrapped in ` Some ( _ ) ` . If it is higher but does not verify we fail with an error . If it is lower we succeed but return ` None ` . If there is no trusted state yet we fail with an error .
pub async fn update(
        &mut self,
        now: SystemTime,
    ) -> Result<Option<SignedHeader<Chain::Commit, Chain::Header>>, error::Error> {
        match self.last_trusted_state {
            Some(ref last_trusted_state) => {
                let last_trusted_height = last_trusted_state.last_header().header().height();
                let latest_header = self
                    .chain
                    .requester()
                    .signed_header(0)
                    .await
                    .map_err(|e| error::Kind::LightClient.context(e))?;
                if latest_header.header().height() > last_trusted_height {
                    self.verify_header(&latest_header, now).await?;
                    Ok(Some(latest_header))
                } else {
                    Ok(None)
                }
            }
            None => fail!(error::Kind::LightClient, "can't get last trusted state"),
        }
    }
pub async fn update ( & mut self , now : SystemTime , ) -> Result < Option < SignedHeader < Chain :: Commit , Chain :: Header > > , error :: Error > { match self . last_trusted_state { Some ( ref last_trusted_state ) => { let last_trusted_height = last_trusted_state . last_header ( ) . header ( ) . height ( ) ; let latest_header = self . chain . requester ( ) . signed_header ( 0 ) . await . map_err ( | e | error :: Kind :: LightClient . context ( e ) ) ? ; if latest_header . header ( ) . height ( ) > last_trusted_height { self . verify_header ( & latest_header , now ) . await ? ; Ok ( Some ( latest_header ) ) } else { Ok ( None ) } } None => fail ! ( error Kind LightClient " " ) , } }
Fetch and verify the latest header from the chain
If the fetched header is higher than the previous trusted state,
and it verifies then we succeed and return it wrapped in `Some(_)`.
Fetch and verify the latest header from the chain If the fetched header is higher than the previous trusted state and it verifies then we succeed and return it wrapped in ` Some ( _ ) ` .
&mut self
now
SystemTime
&mut self
now
SystemTime