Skip to content

Commit

Permalink
Merge pull request EOSIO#3170 from wanderingbort/feature/3161-produce…
Browse files Browse the repository at this point in the history
…r-loop-to-expiration

Producing vs Speculating refactor (was: producer loop to expiration)
  • Loading branch information
b1bart authored May 22, 2018
2 parents 2d1844c + 691041e commit f93d5ae
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace eosio { namespace chain { namespace plugin_interface {
namespace methods {
// synchronously push a block/trx to a single provider
using block_sync = method_decl<chain_plugin_interface, void(const signed_block_ptr&), first_provider_policy>;
using transaction_sync = method_decl<chain_plugin_interface, transaction_trace_ptr(const packed_transaction_ptr&), first_provider_policy>;
using transaction_sync = method_decl<chain_plugin_interface, transaction_trace_ptr(const packed_transaction_ptr&, bool), first_provider_policy>;
}
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ void chain_plugin::accept_block(const signed_block_ptr& block ) {
my->incoming_block_sync_method(block);
}

void chain_plugin::accept_transaction(const packed_transaction& trx) {
my->incoming_transaction_sync_method(std::make_shared<packed_transaction>(trx));
chain::transaction_trace_ptr chain_plugin::accept_transaction(const packed_transaction& trx) {
return my->incoming_transaction_sync_method(std::make_shared<packed_transaction>(trx) , false);
}

bool chain_plugin::block_is_on_preferred_chain(const block_id_type& block_id) {
Expand Down Expand Up @@ -544,7 +544,7 @@ read_write::push_transaction_results read_write::push_transaction(const read_wri
abi_serializer::from_variant(params, *pretty_input, resolver);
} EOS_RETHROW_EXCEPTIONS(chain::packed_transaction_type_exception, "Invalid packed transaction")

auto trx_trace_ptr = app().get_method<incoming::methods::transaction_sync>()(pretty_input);
auto trx_trace_ptr = app().get_method<incoming::methods::transaction_sync>()(pretty_input, true);

pretty_output = db.to_variant_with_abi( *trx_trace_ptr );;
//abi_serializer::to_variant(*trx_trace_ptr, pretty_output, resolver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class chain_plugin : public plugin<chain_plugin> {
chain_apis::read_write get_read_write_api();

void accept_block( const chain::signed_block_ptr& block );
void accept_transaction(const chain::packed_transaction& trx);
chain::transaction_trace_ptr accept_transaction(const chain::packed_transaction& trx);

bool block_is_on_preferred_chain(const chain::block_id_type& block_id);

Expand Down
15 changes: 11 additions & 4 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2441,10 +2441,17 @@ namespace eosio {
dispatcher->recv_transaction(c, tid);
uint64_t code = 0;
try {
chain_plug->accept_transaction( msg);
fc_dlog(logger, "chain accepted transaction" );
dispatcher->bcast_transaction(msg);
return;
auto trace = chain_plug->accept_transaction( msg);
if (!trace->except) {
fc_dlog(logger, "chain accepted transaction");
dispatcher->bcast_transaction(msg);
return;
}

// if accept didn't throw but there was an exception on the trace
// it means that this was non-fatally rejected from the chain.
// we will mark it as "rejected" and hope someone sends it to us later
// when we are able to accept it.
}
catch( const fc::exception &ex) {
code = ex.code();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@

namespace eosio {

namespace block_production_condition {
enum block_production_condition_enum
{
produced = 0,
not_synced = 1,
not_my_turn = 2,
not_time_yet = 3,
no_private_key = 4,
low_participation = 5,
lag = 6,
exception_producing_block = 7,
fork_below_watermark = 8,
};
}

using boost::signals2::signal;

class producer_plugin : public appbase::plugin<producer_plugin> {
Expand Down
Loading

0 comments on commit f93d5ae

Please sign in to comment.