fn execute_function_in_module(
    state_view: &dyn StateView,
    module: VerifiedModule,
    idx: FunctionDefinitionIndex,
    args: Vec<Value>,
) -> VMResult<()> {
    let module_id = module.as_inner().self_id();
    let entry_name = {
        let entry_func_idx = module.function_def_at(idx).function;
        let entry_name_idx = module.function_handle_at(entry_func_idx).name;
        module.identifier_at(entry_name_idx)
    };
    {
        let arena = Arena::new();
        let config = VMConfig {
            publishing_options: VMPublishingOption::Open,
        };
        let mut runtime = VMRuntime::new(&arena, &config);
        runtime.cache_module(module.clone());

        let mut data_cache = BlockDataCache::new(state_view);
        let gas_schedule = runtime.load_gas_schedule(&mut data_cache, state_view)?;
        let mut txn_executor =
            TransactionExecutor::new(&gas_schedule, &data_cache, TransactionMetadata::default());
        txn_executor.execute_function(&runtime, state_view, &module_id, &entry_name, args)
    }
}
/// Execute the first function in a module
Execute the first function in a module
Execute the first function in a module
fn execute_function_in_module(
    state_view: &dyn StateView,
    module: VerifiedModule,
    idx: FunctionDefinitionIndex,
    args: Vec<Value>,
) -> VMResult<()> {
    let module_id = module.as_inner().self_id();
    let entry_name = {
        let entry_func_idx = module.function_def_at(idx).function;
        let entry_name_idx = module.function_handle_at(entry_func_idx).name;
        module.identifier_at(entry_name_idx)
    };
    {
        let arena = Arena::new();
        let config = VMConfig {
            publishing_options: VMPublishingOption::Open,
        };
        let mut runtime = VMRuntime::new(&arena, &config);
        runtime.cache_module(module.clone());
        let mut data_cache = BlockDataCache::new(state_view);
        let gas_schedule = runtime.load_gas_schedule(&mut data_cache, state_view)?;
        let mut txn_executor =
            TransactionExecutor::new(&gas_schedule, &data_cache, TransactionMetadata::default());
        txn_executor.execute_function(&runtime, state_view, &module_id, &entry_name, args)
    }
}
fn execute_function_in_module ( state_view : & dyn StateView , module : VerifiedModule , idx : FunctionDefinitionIndex , args : Vec < Value > , ) -> VMResult < ( ) > { let module_id = module . as_inner ( ) . self_id ( ) ; let entry_name = { let entry_func_idx = module . function_def_at ( idx ) . function ; let entry_name_idx = module . function_handle_at ( entry_func_idx ) . name ; module . identifier_at ( entry_name_idx ) } ; { let arena = Arena :: new ( ) ; let config = VMConfig { publishing_options : VMPublishingOption :: Open , } ; let mut runtime = VMRuntime :: new ( & arena , & config ) ; runtime . cache_module ( module . clone ( ) ) ; let mut data_cache = BlockDataCache :: new ( state_view ) ; let gas_schedule = runtime . load_gas_schedule ( & mut data_cache , state_view ) ? ; let mut txn_executor = TransactionExecutor :: new ( & gas_schedule , & data_cache , TransactionMetadata :: default ( ) ) ; txn_executor . execute_function ( & runtime , state_view , & module_id , & entry_name , args ) } }
Execute the first function in a module
Execute the first function in a module
state_view
&dyn StateView
module
VerifiedModule
idx
FunctionDefinitionIndex
args
Vec<Value>
state_view
&dyn StateView
module
VerifiedModule
idx
FunctionDefinitionIndex
args
Vec<Value>