fn handle_vm_result(
        &self,
        sender: AccountAddress,
        cost_strategy: CostStrategy,
        gas_meta: Gas,
        result: Result<TransactionEffects, VMError>,
        dry_run: bool,
    ) -> VmResult {
        let gas_used = GasUnits::new(gas_meta.max_gas_amount)
            .sub(cost_strategy.remaining_gas())
            .get();

        if dry_run {
            return match result {
                Ok(_) => VmResult::new(StatusCode::EXECUTED, None, gas_used),
                Err(err) => VmResult::new(err.major_status(), err.sub_status(), gas_used),
            };
        }

        match result.and_then(|e| self.handle_tx_effects(e)) {
            Ok(_) => VmResult::new(StatusCode::EXECUTED, None, gas_used),
            Err(err) => {
                let status = err.major_status();
                let sub_status = err.sub_status();
                if let Err(err) = self.emit_vm_status_event(sender, err.into_vm_status()) {
                    VmResult::new(status, sub_status, gas_used);
                    log::warn!("Failed to emit vm status event:{:?}", err);
                }

                VmResult::new(status, sub_status, gas_used)
            }
        }
    }
/// Handle vm result and return transaction status code.
Handle vm result and return transaction status code.
Handle vm result and return transaction status code .
fn handle_vm_result(
        &self,
        sender: AccountAddress,
        cost_strategy: CostStrategy,
        gas_meta: Gas,
        result: Result<TransactionEffects, VMError>,
        dry_run: bool,
    ) -> VmResult {
        let gas_used = GasUnits::new(gas_meta.max_gas_amount)
            .sub(cost_strategy.remaining_gas())
            .get();
        if dry_run {
            return match result {
                Ok(_) => VmResult::new(StatusCode::EXECUTED, None, gas_used),
                Err(err) => VmResult::new(err.major_status(), err.sub_status(), gas_used),
            };
        }
        match result.and_then(|e| self.handle_tx_effects(e)) {
            Ok(_) => VmResult::new(StatusCode::EXECUTED, None, gas_used),
            Err(err) => {
                let status = err.major_status();
                let sub_status = err.sub_status();
                if let Err(err) = self.emit_vm_status_event(sender, err.into_vm_status()) {
                    VmResult::new(status, sub_status, gas_used);
                    log::warn!("Failed to emit vm status event:{:?}", err);
                }
                VmResult::new(status, sub_status, gas_used)
            }
        }
    }
fn handle_vm_result ( & self , sender : AccountAddress , cost_strategy : CostStrategy , gas_meta : Gas , result : Result < TransactionEffects , VMError > , dry_run : bool , ) -> VmResult { let gas_used = GasUnits :: new ( gas_meta . max_gas_amount ) . sub ( cost_strategy . remaining_gas ( ) ) . get ( ) ; if dry_run { return match result { Ok ( _ ) => VmResult :: new ( StatusCode :: EXECUTED , None , gas_used ) , Err ( err ) => VmResult :: new ( err . major_status ( ) , err . sub_status ( ) , gas_used ) , } ; } match result . and_then ( | e | self . handle_tx_effects ( e ) ) { Ok ( _ ) => VmResult :: new ( StatusCode :: EXECUTED , None , gas_used ) , Err ( err ) => { let status = err . major_status ( ) ; let sub_status = err . sub_status ( ) ; if let Err ( err ) = self . emit_vm_status_event ( sender , err . into_vm_status ( ) ) { VmResult :: new ( status , sub_status , gas_used ) ; log :: warn ! ( " " err ) ; } VmResult :: new ( status , sub_status , gas_used ) } } }
Handle vm result and return transaction status code.
Handle vm result and return transaction status code .
&self
sender
AccountAddress
cost_strategy
CostStrategy
gas_meta
Gas
result
Result<TransactionEffects, VMError>
dry_run
bool
&self
sender
AccountAddress
cost_strategy
CostStrategy
gas_meta
Gas
result
Result<TransactionEffects, VMError>
dry_run
bool