fn prepare_next(&mut self) -> Result<(), String> {
        // When updating this method, be sure to not hold lock longer than necessary,
        // since it can cause provers to not be able to interact with the server.

        // Clone the queues to process them without holding the lock.
        let mut queue = {
            let pool = self.data.read().expect("failed to get write lock on data");

            pool.op_queue.clone()
        };

        // Create a storage for prepared data.
        let mut prepared = HashMap::new();

        // Go through queue, take the next operation to process, and build the
        // prover data for it.
        while !queue.is_empty() {
            assert_eq!(
                Some(self.next_block_number),
                queue.next_block_number(),
                "Blocks must be processed in order"
            );
            if let Some((op, has_proof)) = queue.take_next_operation() {
                let storage = self
                    .conn_pool
                    .access_storage()
                    .expect("failed to connect to db");
                let pd = self.build_prover_data(&storage, &op)?;
                // Always build prover data to update circuit tree to the next block, but store only
                // if there is no proof for the block.
                if !has_proof {
                    prepared.insert(op.block.block_number, pd);
                }
                self.next_block_number = op.block.block_number + 1;
            }
        }

        // Update the queue and prepared data in pool.
        // Since this structure is the only writer to the queue, it is guaranteed
        // to not contain data that will be overwritten by the assignment.
        // Prepared data is appended to the existing one, thus we can not worry about
        // synchronization as well.
        let mut pool = self.data.write().expect("failed to get write lock on data");
        pool.op_queue = queue;
        pool.prepared.extend(prepared);

        Ok(())
    }
/// Goes through existing queues of operations and builds a prover data for each of them.
Goes through existing queues of operations and builds a prover data for each of them.
Goes through existing queues of operations and builds a prover data for each of them .
fn prepare_next(&mut self) -> Result<(), String> {
        // When updating this method, be sure to not hold lock longer than necessary,
        // since it can cause provers to not be able to interact with the server.
        // Clone the queues to process them without holding the lock.
        let mut queue = {
            let pool = self.data.read().expect("failed to get write lock on data");
            pool.op_queue.clone()
        };
        // Create a storage for prepared data.
        let mut prepared = HashMap::new();
        // Go through queue, take the next operation to process, and build the
        // prover data for it.
        while !queue.is_empty() {
            assert_eq!(
                Some(self.next_block_number),
                queue.next_block_number(),
                "Blocks must be processed in order"
            );
            if let Some((op, has_proof)) = queue.take_next_operation() {
                let storage = self
                    .conn_pool
                    .access_storage()
                    .expect("failed to connect to db");
                let pd = self.build_prover_data(&storage, &op)?;
                // Always build prover data to update circuit tree to the next block, but store only
                // if there is no proof for the block.
                if !has_proof {
                    prepared.insert(op.block.block_number, pd);
                }
                self.next_block_number = op.block.block_number + 1;
            }
        }
        // Update the queue and prepared data in pool.
        // Since this structure is the only writer to the queue, it is guaranteed
        // to not contain data that will be overwritten by the assignment.
        // Prepared data is appended to the existing one, thus we can not worry about
        // synchronization as well.
        let mut pool = self.data.write().expect("failed to get write lock on data");
        pool.op_queue = queue;
        pool.prepared.extend(prepared);
        Ok(())
    }
fn prepare_next ( & mut self ) -> Result < ( ) , String > { // When updating this method, be sure to not hold lock longer than necessary, // since it can cause provers to not be able to interact with the server. // Clone the queues to process them without holding the lock. let mut queue = { let pool = self . data . read ( ) . expect ( " " ) ; pool . op_queue . clone ( ) } ; // Create a storage for prepared data. let mut prepared = HashMap :: new ( ) ; // Go through queue, take the next operation to process, and build the // prover data for it. while ! queue . is_empty ( ) { assert_eq ! ( Some ( self next_block_number ) queue next_block_number ( ) " " ) ; if let Some ( ( op , has_proof ) ) = queue . take_next_operation ( ) { let storage = self . conn_pool . access_storage ( ) . expect ( " " ) ; let pd = self . build_prover_data ( & storage , & op ) ? ; // Always build prover data to update circuit tree to the next block, but store only // if there is no proof for the block. if ! has_proof { prepared . insert ( op . block . block_number , pd ) ; } self . next_block_number = op . block . block_number + 1 ; } } // Update the queue and prepared data in pool. // Since this structure is the only writer to the queue, it is guaranteed // to not contain data that will be overwritten by the assignment. // Prepared data is appended to the existing one, thus we can not worry about // synchronization as well. let mut pool = self . data . write ( ) . expect ( " " ) ; pool . op_queue = queue ; pool . prepared . extend ( prepared ) ; Ok ( ( ) ) }
Goes through existing queues of operations and builds a prover data for each of them.
Goes through existing queues of operations and builds a prover data for each of them .
&mut self