async fn process_chunk_response(
        &mut self,
        peer_id: &PeerId,
        mut response: GetChunkResponse,
    ) -> Result<()> {
        let txn_list_with_proof = response.take_txn_list_with_proof();

        if let Some(version) = txn_list_with_proof
            .first_transaction_version
            .clone()
            .map(|x| x.get_value())
            .into_option()
        {
            if version != self.known_version + 1 {
                return Err(format_err!(
                    "[state sync] non sequential chunk. Known version: {}, received: {}",
                    self.known_version,
                    version,
                ));
            }
        }

        let previous_version = self.known_version;
        let chunk_size = txn_list_with_proof.get_transactions().len();

        let result = self
            .validate_and_store_chunk(txn_list_with_proof, response)
            .await;
        let latest_version = self.executor_proxy.get_latest_version().await?;
        if latest_version <= previous_version {
            self.peer_manager
                .update_score(peer_id, PeerScoreUpdateType::InvalidChunk);
        }
        self.commit(latest_version).await;

        debug!(
            "[state sync] applied chunk. Previous version: {}, new version: {}, chunk size: {}",
            previous_version, self.known_version, chunk_size
        );

        result
    }
/// processes batch of transactions downloaded from peer
/// executes transactions, updates progress state, calls callback if some sync is finished
processes batch of transactions downloaded from peer
executes transactions, updates progress state, calls callback if some sync is finished
processes batch of transactions downloaded from peer executes transactions updates progress state calls callback if some sync is finished
async fn process_chunk_response(
        &mut self,
        peer_id: &PeerId,
        mut response: GetChunkResponse,
    ) -> Result<()> {
        let txn_list_with_proof = response.take_txn_list_with_proof();
        if let Some(version) = txn_list_with_proof
            .first_transaction_version
            .clone()
            .map(|x| x.get_value())
            .into_option()
        {
            if version != self.known_version + 1 {
                return Err(format_err!(
                    "[state sync] non sequential chunk. Known version: {}, received: {}",
                    self.known_version,
                    version,
                ));
            }
        }
        let previous_version = self.known_version;
        let chunk_size = txn_list_with_proof.get_transactions().len();
        let result = self
            .validate_and_store_chunk(txn_list_with_proof, response)
            .await;
        let latest_version = self.executor_proxy.get_latest_version().await?;
        if latest_version <= previous_version {
            self.peer_manager
                .update_score(peer_id, PeerScoreUpdateType::InvalidChunk);
        }
        self.commit(latest_version).await;
        debug!(
            "[state sync] applied chunk. Previous version: {}, new version: {}, chunk size: {}",
            previous_version, self.known_version, chunk_size
        );
        result
    }
async fn process_chunk_response ( & mut self , peer_id : & PeerId , mut response : GetChunkResponse , ) -> Result < ( ) > { let txn_list_with_proof = response . take_txn_list_with_proof ( ) ; if let Some ( version ) = txn_list_with_proof . first_transaction_version . clone ( ) . map ( | x | x . get_value ( ) ) . into_option ( ) { if version != self . known_version + 1 { return Err ( format_err ! ( " " self known_version version ) ) ; } } let previous_version = self . known_version ; let chunk_size = txn_list_with_proof . get_transactions ( ) . len ( ) ; let result = self . validate_and_store_chunk ( txn_list_with_proof , response ) . await ; let latest_version = self . executor_proxy . get_latest_version ( ) . await ? ; if latest_version <= previous_version { self . peer_manager . update_score ( peer_id , PeerScoreUpdateType :: InvalidChunk ) ; } self . commit ( latest_version ) . await ; debug ! ( " " previous_version self known_version chunk_size ) ; result }
processes batch of transactions downloaded from peer
executes transactions, updates progress state, calls callback if some sync is finished
processes batch of transactions downloaded from peer executes transactions updates progress state calls callback if some sync is finished
&mut self
peer_id
&PeerId
response
GetChunkResponse