diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 679de33bc4..4715b28842 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -102,6 +102,8 @@ struct txn_test_gen_plugin_impl { name newaccountA; name newaccountB; name newaccountT; + fc::microseconds trx_expiration{3600}; + bool stop_on_trx_failed{true}; void push_next_transaction(const std::shared_ptr>& trxs, const std::function& next ) { chain_plugin& cp = app().get_plugin(); @@ -333,7 +335,7 @@ struct txn_test_gen_plugin_impl { send_transaction([this](const fc::exception_ptr& e){ if (e) { elog("pushing transaction failed: ${e}", ("e", e->to_detail_string())); - if(running) + if(running && stop_on_trx_failed) stop_generation(); } }, nonce_prefix++); @@ -376,7 +378,7 @@ struct txn_test_gen_plugin_impl { trx.actions.push_back(act_a_to_b); trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) ))); trx.set_reference_block(reference_block_id); - trx.expiration = cc.head_block_time() + fc::seconds(30); + trx.expiration = cc.head_block_time() + trx_expiration; trx.max_net_usage_words = 100; trx.sign(a_priv_key, chainid); trxs.emplace_back(std::move(trx)); @@ -387,7 +389,7 @@ struct txn_test_gen_plugin_impl { trx.actions.push_back(act_b_to_a); trx.context_free_actions.emplace_back(action({}, config::null_account_name, name("nonce"), fc::raw::pack( std::to_string(nonce_prefix)+std::to_string(nonce++) ))); trx.set_reference_block(reference_block_id); - trx.expiration = cc.head_block_time() + fc::seconds(30); + trx.expiration = cc.head_block_time() + trx_expiration; trx.max_net_usage_words = 100; trx.sign(b_priv_key, chainid); trxs.emplace_back(std::move(trx)); @@ -442,6 +444,8 @@ void txn_test_gen_plugin::set_program_options(options_description&, options_desc ("txn-reference-block-lag", bpo::value()->default_value(0), "Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block)") ("txn-test-gen-threads", bpo::value()->default_value(2), "Number of worker threads in txn_test_gen thread pool") ("txn-test-gen-account-prefix", bpo::value()->default_value("txn.test."), "Prefix to use for accounts generated and used by this plugin") + ("txn-test-gen-expiration-seconds", bpo::value()->default_value(30), "expiration in seconds for transactions generated by this plugin") + ("txn-test-gen-stop-on-push-failed", bpo::value()->default_value(true), "stop generation when pushed transaction failed") ; } @@ -454,6 +458,11 @@ void txn_test_gen_plugin::plugin_initialize(const variables_map& options) { my->newaccountA = eosio::chain::name(thread_pool_account_prefix + "a"); my->newaccountB = eosio::chain::name(thread_pool_account_prefix + "b"); my->newaccountT = eosio::chain::name(thread_pool_account_prefix + "t"); + my->trx_expiration = fc::seconds(options.at("txn-test-gen-expiration-seconds").as()); + EOS_ASSERT(my->trx_expiration < fc::seconds(3600), chain::plugin_config_exception, + "txn-test-gen-expiration-seconds must be smaller than 3600"); + my->stop_on_trx_failed = options.at("txn-test-gen-stop-on-push-failed").as(); + EOS_ASSERT( my->thread_pool_size > 0, chain::plugin_config_exception, "txn-test-gen-threads ${num} must be greater than 0", ("num", my->thread_pool_size) ); } FC_LOG_AND_RETHROW()