fn apply_priority_op(
        &mut self,
        priority_op: PriorityOp,
    ) -> Result<ExecutedOperations, PriorityOp> {
        let chunks_needed = priority_op.data.chunks();
        if self.pending_block.chunks_left < chunks_needed {
            return Err(priority_op);
        }

        // Check if adding this transaction to the block won't make the contract operations
        // too expensive.
        let non_executed_op = self
            .state
            .priority_op_to_franklin_op(priority_op.data.clone());
        if self
            .pending_block
            .gas_counter
            .add_op(&non_executed_op)
            .is_err()
        {
            // We've reached the gas limit, seal the block.
            // This transaction will go into the next one.
            return Err(priority_op);
        }

        let OpSuccess {
            fee,
            mut updates,
            executed_op,
        } = self.state.execute_priority_op(priority_op.data.clone());

        self.pending_block.chunks_left -= chunks_needed;
        self.pending_block.account_updates.append(&mut updates);
        if let Some(fee) = fee {
            let fee_updates = self.state.collect_fee(&[fee], self.fee_account_id);
            self.pending_block
                .account_updates
                .extend(fee_updates.into_iter());
        }
        let block_index = self.pending_block.pending_op_block_index;
        self.pending_block.pending_op_block_index += 1;

        let exec_result = ExecutedOperations::PriorityOp(Box::new(ExecutedPriorityOp {
            op: executed_op,
            priority_op,
            block_index,
            created_at: chrono::Utc::now(),
        }));
        self.pending_block
            .success_operations
            .push(exec_result.clone());
        self.current_unprocessed_priority_op += 1;
        Ok(exec_result)
    }
// Err if there is no space in current block
Err if there is no space in current block
Err if there is no space in current block
fn apply_priority_op(
        &mut self,
        priority_op: PriorityOp,
    ) -> Result<ExecutedOperations, PriorityOp> {
        let chunks_needed = priority_op.data.chunks();
        if self.pending_block.chunks_left < chunks_needed {
            return Err(priority_op);
        }
        // Check if adding this transaction to the block won't make the contract operations
        // too expensive.
        let non_executed_op = self
            .state
            .priority_op_to_franklin_op(priority_op.data.clone());
        if self
            .pending_block
            .gas_counter
            .add_op(&non_executed_op)
            .is_err()
        {
            // We've reached the gas limit, seal the block.
            // This transaction will go into the next one.
            return Err(priority_op);
        }
        let OpSuccess {
            fee,
            mut updates,
            executed_op,
        } = self.state.execute_priority_op(priority_op.data.clone());
        self.pending_block.chunks_left -= chunks_needed;
        self.pending_block.account_updates.append(&mut updates);
        if let Some(fee) = fee {
            let fee_updates = self.state.collect_fee(&[fee], self.fee_account_id);
            self.pending_block
                .account_updates
                .extend(fee_updates.into_iter());
        }
        let block_index = self.pending_block.pending_op_block_index;
        self.pending_block.pending_op_block_index += 1;
        let exec_result = ExecutedOperations::PriorityOp(Box::new(ExecutedPriorityOp {
            op: executed_op,
            priority_op,
            block_index,
            created_at: chrono::Utc::now(),
        }));
        self.pending_block
            .success_operations
            .push(exec_result.clone());
        self.current_unprocessed_priority_op += 1;
        Ok(exec_result)
    }
fn apply_priority_op ( & mut self , priority_op : PriorityOp , ) -> Result < ExecutedOperations , PriorityOp > { let chunks_needed = priority_op . data . chunks ( ) ; if self . pending_block . chunks_left < chunks_needed { return Err ( priority_op ) ; } // Check if adding this transaction to the block won't make the contract operations // too expensive. let non_executed_op = self . state . priority_op_to_franklin_op ( priority_op . data . clone ( ) ) ; if self . pending_block . gas_counter . add_op ( & non_executed_op ) . is_err ( ) { // We've reached the gas limit, seal the block. // This transaction will go into the next one. return Err ( priority_op ) ; } let OpSuccess { fee , mut updates , executed_op , } = self . state . execute_priority_op ( priority_op . data . clone ( ) ) ; self . pending_block . chunks_left -= chunks_needed ; self . pending_block . account_updates . append ( & mut updates ) ; if let Some ( fee ) = fee { let fee_updates = self . state . collect_fee ( & [ fee ] , self . fee_account_id ) ; self . pending_block . account_updates . extend ( fee_updates . into_iter ( ) ) ; } let block_index = self . pending_block . pending_op_block_index ; self . pending_block . pending_op_block_index += 1 ; let exec_result = ExecutedOperations :: PriorityOp ( Box :: new ( ExecutedPriorityOp { op : executed_op , priority_op , block_index , created_at : chrono :: Utc :: now ( ) , } ) ) ; self . pending_block . success_operations . push ( exec_result . clone ( ) ) ; self . current_unprocessed_priority_op += 1 ; Ok ( exec_result ) }
Err if there is no space in current block
Err if there is no space in current block
&mut self
priority_op
PriorityOp