pub fn spawn(mut self) -> Instrumented<JoinHandle<Result<()>>> {
        let span = info_span!("ProverSync", self = %self);
        tokio::spawn(async move {
            loop {
                let local_root = self.local_root();
                let signed_update_opt = self.db.update_by_previous_root(local_root)?;

                // This if block is somewhat ugly.
                // First we check if there is a signed update with the local root.
                //   If so we start ingesting messages under the new root.
                // Otherwise, if there is no update,
                //   We ignore the initial root
                //   We ensure that an update produced the local root.
                //      If no update produced the local root, we error.
                if let Some(signed_update) = signed_update_opt {
                    info!(
                        "Have signed update from {} to {}",
                        signed_update.update.previous_root, signed_update.update.new_root,
                    );
                    self.update_full(local_root, signed_update.update.new_root)
                        .await?;
                } else if !local_root.is_zero() && self.db.update_by_new_root(local_root)?.is_none()
                {
                    bail!(ProverSyncError::InvalidLocalRoot { local_root });
                }

                // kludge
                sleep(Duration::from_millis(100)).await;
            }
        })
        .instrument(span)
    }
/// Consume self and poll for signed updates at regular interval. Update
/// local merkle tree with all leaves between local root and
/// new root. Use short interval for bootup syncing and longer
/// interval for regular polling.
Consume self and poll for signed updates at regular interval. Update
local merkle tree with all leaves between local root and
new root. Use short interval for bootup syncing and longer
interval for regular polling.
Consume self and poll for signed updates at regular interval . Update local merkle tree with all leaves between local root and new root . Use short interval for bootup syncing and longer interval for regular polling .
pub fn spawn(mut self) -> Instrumented<JoinHandle<Result<()>>> {
        let span = info_span!("ProverSync", self = %self);
        tokio::spawn(async move {
            loop {
                let local_root = self.local_root();
                let signed_update_opt = self.db.update_by_previous_root(local_root)?;
                // This if block is somewhat ugly.
                // First we check if there is a signed update with the local root.
                //   If so we start ingesting messages under the new root.
                // Otherwise, if there is no update,
                //   We ignore the initial root
                //   We ensure that an update produced the local root.
                //      If no update produced the local root, we error.
                if let Some(signed_update) = signed_update_opt {
                    info!(
                        "Have signed update from {} to {}",
                        signed_update.update.previous_root, signed_update.update.new_root,
                    );
                    self.update_full(local_root, signed_update.update.new_root)
                        .await?;
                } else if !local_root.is_zero() && self.db.update_by_new_root(local_root)?.is_none()
                {
                    bail!(ProverSyncError::InvalidLocalRoot { local_root });
                }
                // kludge
                sleep(Duration::from_millis(100)).await;
            }
        })
        .instrument(span)
    }
pub fn spawn ( mut self ) -> Instrumented < JoinHandle < Result < ( ) > > > { let span = info_span ! ( " " self self ) ; tokio :: spawn ( async move { loop { let local_root = self . local_root ( ) ; let signed_update_opt = self . db . update_by_previous_root ( local_root ) ? ; // This if block is somewhat ugly. // First we check if there is a signed update with the local root. //   If so we start ingesting messages under the new root. // Otherwise, if there is no update, //   We ignore the initial root //   We ensure that an update produced the local root. //      If no update produced the local root, we error. if let Some ( signed_update ) = signed_update_opt { info ! ( " " signed_update update previous_root signed_update update new_root ) ; self . update_full ( local_root , signed_update . update . new_root ) . await ? ; } else if ! local_root . is_zero ( ) && self . db . update_by_new_root ( local_root ) ? . is_none ( ) { bail ! ( ProverSyncError InvalidLocalRoot { local_root } ) ; } // kludge sleep ( Duration :: from_millis ( 100 ) ) . await ; } } ) . instrument ( span ) }
Consume self and poll for signed updates at regular interval.
Consume self and poll for signed updates at regular interval .
mut self
mut self