pub async fn sync_up(
        &mut self,
        sync_info: &SyncInfo,
        author: Author,
        help_remote: bool,
    ) -> anyhow::Result<()> {
        let local_sync_info = self.block_store.sync_info();
        if help_remote && local_sync_info.has_newer_certificates(&sync_info) {
            counters::SYNC_INFO_MSGS_SENT_COUNT.inc();
            debug!(
                "Peer {} has stale state {}, send it back {}",
                author.short_str(),
                sync_info,
                local_sync_info,
            );
            self.network.send_sync_info(local_sync_info.clone(), author);
        }
        if sync_info.has_newer_certificates(&local_sync_info) {
            debug!(
                "Local state {} is stale than peer {} remote state {}",
                local_sync_info,
                author.short_str(),
                sync_info
            );
            // Some information in SyncInfo is ahead of what we have locally.
            // First verify the SyncInfo (didn't verify it in the yet).
            sync_info
                .verify(&self.epoch_state().verifier)
                .map_err(|e| {
                    security_log(SecurityEvent::InvalidSyncInfoMsg)
                        .error(&e)
                        .data(&sync_info)
                        .log();
                    e
                })?;
            self.block_store
                .add_certs(&sync_info, self.create_block_retriever(author))
                .await
                .map_err(|e| {
                    warn!("Fail to sync up to {}: {:?}", sync_info, e);
                    e
                })?;

            // Update safety rules and round_state and potentially start a new round.
            self.process_certificates().await?;
        }
        Ok(())
    }
/// The function makes sure that it brings the missing dependencies from the QC and LedgerInfo
/// of the given sync info and update the round_state with the certificates if succeed.
/// Returns Error in case sync mgr failed to bring the missing dependencies.
/// We'll try to help the remote if the SyncInfo lags behind and the flag is set.
The function makes sure that it brings the missing dependencies from the QC and LedgerInfo
of the given sync info and update the round_state with the certificates if succeed.
Returns Error in case sync mgr failed to bring the missing dependencies.
We'll try to help the remote if the SyncInfo lags behind and the flag is set.
The function makes sure that it brings the missing dependencies from the QC and LedgerInfo of the given sync info and update the round_state with the certificates if succeed . Returns Error in case sync mgr failed to bring the missing dependencies . We ' ll try to help the remote if the SyncInfo lags behind and the flag is set .
pub async fn sync_up(
        &mut self,
        sync_info: &SyncInfo,
        author: Author,
        help_remote: bool,
    ) -> anyhow::Result<()> {
        let local_sync_info = self.block_store.sync_info();
        if help_remote && local_sync_info.has_newer_certificates(&sync_info) {
            counters::SYNC_INFO_MSGS_SENT_COUNT.inc();
            debug!(
                "Peer {} has stale state {}, send it back {}",
                author.short_str(),
                sync_info,
                local_sync_info,
            );
            self.network.send_sync_info(local_sync_info.clone(), author);
        }
        if sync_info.has_newer_certificates(&local_sync_info) {
            debug!(
                "Local state {} is stale than peer {} remote state {}",
                local_sync_info,
                author.short_str(),
                sync_info
            );
            // Some information in SyncInfo is ahead of what we have locally.
            // First verify the SyncInfo (didn't verify it in the yet).
            sync_info
                .verify(&self.epoch_state().verifier)
                .map_err(|e| {
                    security_log(SecurityEvent::InvalidSyncInfoMsg)
                        .error(&e)
                        .data(&sync_info)
                        .log();
                    e
                })?;
            self.block_store
                .add_certs(&sync_info, self.create_block_retriever(author))
                .await
                .map_err(|e| {
                    warn!("Fail to sync up to {}: {:?}", sync_info, e);
                    e
                })?;
            // Update safety rules and round_state and potentially start a new round.
            self.process_certificates().await?;
        }
        Ok(())
    }
pub async fn sync_up ( & mut self , sync_info : & SyncInfo , author : Author , help_remote : bool , ) -> anyhow :: Result < ( ) > { let local_sync_info = self . block_store . sync_info ( ) ; if help_remote && local_sync_info . has_newer_certificates ( & sync_info ) { counters :: SYNC_INFO_MSGS_SENT_COUNT . inc ( ) ; debug ! ( " " author short_str ( ) sync_info local_sync_info ) ; self . network . send_sync_info ( local_sync_info . clone ( ) , author ) ; } if sync_info . has_newer_certificates ( & local_sync_info ) { debug ! ( " " local_sync_info author short_str ( ) sync_info ) ; // Some information in SyncInfo is ahead of what we have locally. // First verify the SyncInfo (didn't verify it in the yet). sync_info . verify ( & self . epoch_state ( ) . verifier ) . map_err ( | e | { security_log ( SecurityEvent :: InvalidSyncInfoMsg ) . error ( & e ) . data ( & sync_info ) . log ( ) ; e } ) ? ; self . block_store . add_certs ( & sync_info , self . create_block_retriever ( author ) ) . await . map_err ( | e | { warn ! ( " " sync_info e ) ; e } ) ? ; // Update safety rules and round_state and potentially start a new round. self . process_certificates ( ) . await ? ; } Ok ( ( ) ) }
The function makes sure that it brings the missing dependencies from the QC and LedgerInfo
of the given sync info and update the round_state with the certificates if succeed.
The function makes sure that it brings the missing dependencies from the QC and LedgerInfo of the given sync info and update the round_state with the certificates if succeed .
&mut self
sync_info
&SyncInfo
author
Author
help_remote
bool
&mut self
sync_info
&SyncInfo
author
Author
help_remote
bool