EOS合约执行流程

in 区块链 with 0 comment
 void transaction_context::dispatch_action
 void apply_context::exec
 void apply_context::exec_one
 wasm_interface::apply(

首先接收到一个action后,通过 transaction_context::dispatch_action
分发给 apply_context::exec 执行
先执行合约action自己
然后执行所有的通知
再执行_cfa_inline_actions
最后执行_inline_actions

inline和通知一样都是添加到一个变量里面
等action执行完在开始执行。上面的东西都会递归,inline会判断深度。配置里面是4

void apply_context::exec( action_trace& trace )
{
   _notified.push_back(receiver);
   exec_one( trace );
   for( uint32_t i = 1; i < _notified.size(); ++i ) {
      receiver = _notified[i];
      trace.inline_traces.emplace_back( );
      exec_one( trace.inline_traces.back() );
   }

   if( _cfa_inline_actions.size() > 0 || _inline_actions.size() > 0 ) {
      EOS_ASSERT( recurse_depth < control.get_global_properties().configuration.max_inline_action_depth,
                  transaction_exception, "max inline action depth per transaction reached" );
   }

   for( const auto& inline_action : _cfa_inline_actions ) {
      trace.inline_traces.emplace_back();
      trx_context.dispatch_action( trace.inline_traces.back(), inline_action, inline_action.account, true, recurse_depth + 1 );
   }

   for( const auto& inline_action : _inline_actions ) {
      trace.inline_traces.emplace_back();
      trx_context.dispatch_action( trace.inline_traces.back(), inline_action, inline_action.account, false, recurse_depth + 1 );
   }

} /// exec()
Comments are closed.