I am studying the source code of eos and I saw that in the cleos it has this function.

call(push_txn_func, packed_transaction(trx, compression));

I think this is used to push the transaction to the chain. So there must be somewhere in the nodeos to handle this transaction from cleos. I spent several days on it searching for that place. At first, I saw this function in net_plugin.

void handle_message( connection_ptr c, const packed_transaction &msg);

But I added logs there and found it's not the place. Then I found

void chain_plugin::accept_transaction(const chain::packed_transaction& trx, next_function<chain::transaction_trace_ptr> next) {
my->incoming_transaction_async_method(std::make_shared<packed_transaction>(trx), false, std::forward<decltype(next)>(next));}

in the chain_plugin. Again, no log output there. So it may not be the place. So my question is where is the place that nodeos handling the transaction from cleos?


Your method is right to find the answer of push_transaction by print logs,but the place is wrong.when we used command cleos push_transaction which call push_txn_func in cleos main.cpp,a better way to find this is:

1、find command in ../../cleos/main.cpp such as push_transaction

auto trx_result = call(push_txn_func, packed_transaction(trx, packed_transaction::none));

2、get the bind funtion in ../../cleos/httpc.hpp like this

const string push_txn_func = chain_func_base + "/push_transaction";

3、so we can get the info that this funtion located in chain_plugin,then we open chain_plugin.cpp we can find this funtion

void read_write::push_transaction(const read_write::push_transaction_params& params, next_function<read_write::push_transaction_results> next) {

   try {
      auto pretty_input = std::make_shared<packed_transaction>();
      auto resolver = make_resolver(this, abi_serializer_max_time);
      try {
         abi_serializer::from_variant(params, *pretty_input, resolver, abi_serializer_max_time);
      } EOS_RETHROW_EXCEPTIONS(chain::packed_transaction_type_exception, "Invalid packed transaction")

      app().get_method<incoming::methods::transaction_async>()(pretty_input, true, [this, next](const fc::static_variant<fc::exception_ptr, transaction_trace_ptr>& result) -> void{
         if (result.contains<fc::exception_ptr>()) {
         } else {
            auto trx_trace_ptr = result.get<transaction_trace_ptr>();

            try {
               fc::variant pretty_output;
               pretty_output = db.to_variant_with_abi(*trx_trace_ptr, abi_serializer_max_time);

               chain::transaction_id_type id = trx_trace_ptr->id;
               next(read_write::push_transaction_results{id, pretty_output});
            } CATCH_AND_CALL(next);

   } catch ( boost::interprocess::bad_alloc& ) {
   } CATCH_AND_CALL(next);

4、after find this funtion and add logs and use cleos command we can find nodeos print your log info.

  • You are right. Thanks, I managed to print the log. Aug 30 '18 at 14:34
  • As an eos fans in Hangzhou too,we can.communicate through wechat
    – fen chen
    Aug 30 '18 at 15:13
  • Cool. I bet you are in that wechat group started by eosiofans. Aug 31 '18 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.