/// Executes transaction with the specified ID with fork isolation.
Executes transaction with the specified ID with fork isolation.
Executes transaction with the specified ID with fork isolation .
pub(crate) fn execute(
        &self,
        fork: &mut Fork,
        tx_id: Hash,
        tx_index: u32,
        tx: &Verified<AnyTx>,
    ) -> Result<(), ExecutionError> {
        let call_info = &tx.as_ref().call_info;
        let (runtime_id, runtime) = self
            .runtime_for_service(call_info.instance_id)
            .ok_or(CoreError::IncorrectInstanceId)?;
        let instance = self
            .get_service(call_info.instance_id)
            .ok_or(CoreError::IncorrectInstanceId)?;
        let mut should_rollback = false;
        let context = ExecutionContext::for_transaction(
            self,
            fork,
            &mut should_rollback,
            instance,
            tx.author(),
            tx_id,
        );
        let mut res = runtime.execute(context, call_info.method_id, &tx.as_ref().arguments);
        if should_rollback && res.is_ok() {
            res = Err(CoreError::IncorrectCall.into());
        }
        if let Err(ref mut err) = res {
            fork.rollback();
            err.set_runtime_id(runtime_id)
                .set_call_site(|| CallSite::from_call_info(call_info, ""));
            Self::report_error(err, fork, CallInBlock::transaction(tx_index));
        } else {
            fork.flush();
        }
        res
    }
pub ( crate ) fn execute ( & self , fork : & mut Fork , tx_id : Hash , tx_index : u32 , tx : & Verified < AnyTx > , ) -> Result < ( ) , ExecutionError > { let call_info = & tx . as_ref ( ) . call_info ; let ( runtime_id , runtime ) = self . runtime_for_service ( call_info . instance_id ) . ok_or ( CoreError :: IncorrectInstanceId ) ? ; let instance = self . get_service ( call_info . instance_id ) . ok_or ( CoreError :: IncorrectInstanceId ) ? ; let mut should_rollback = false ; let context = ExecutionContext :: for_transaction ( self , fork , & mut should_rollback , instance , tx . author ( ) , tx_id , ) ; let mut res = runtime . execute ( context , call_info . method_id , & tx . as_ref ( ) . arguments ) ; if should_rollback && res . is_ok ( ) { res = Err ( CoreError :: IncorrectCall . into ( ) ) ; } if let Err ( ref mut err ) = res { fork . rollback ( ) ; err . set_runtime_id ( runtime_id ) . set_call_site ( | | CallSite :: from_call_info ( call_info , " " ) ) ; Self :: report_error ( err , fork , CallInBlock :: transaction ( tx_index ) ) ; } else { fork . flush ( ) ; } res }
Executes transaction with the specified ID with fork isolation.
Executes transaction with the specified ID with fork isolation .
&self
fork
&mut Fork
tx_id
Hash
tx_index
u32
tx
&Verified<AnyTx>