提交 4d98e29a 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #265 from wanderingbort/feature/263-single-threaded

Add a single threaded scheduler and make it the default
......@@ -289,4 +289,23 @@ block_schedule block_schedule::by_cycling_conflicts(
return from_entries(schedule);
}
block_schedule block_schedule::in_single_thread(
const vector<pending_transaction>& transactions,
const global_property_object& properties
)
{
auto skipper = make_skipper(properties);
thread_schedule thread;
thread.transactions.reserve(transactions.size());
for(const auto& t: transactions) {
if (skipper.should_skip(t)) {
break;
}
thread.transactions.push_back(t);
}
return block_schedule { { { thread } } };
}
} /* namespace chain */ } /* namespace eos */
......@@ -60,6 +60,13 @@ namespace eos { namespace chain {
* @return the block scheduler
*/
static block_schedule by_cycling_conflicts(const vector<pending_transaction>& transactions, const global_property_object& properties);
/**
* A reference scheduler that puts all transactions in a single thread (FIFO)
* @return the block scheduler
*/
static block_schedule in_single_thread(const vector<pending_transaction>& transactions, const global_property_object& properties);
};
struct scope_extracting_visitor : public fc::visitor<std::set<AccountName>> {
......
......@@ -164,7 +164,7 @@ namespace eos { namespace chain {
fc::time_point_sec when,
const AccountName& producer,
const fc::ecc::private_key& block_signing_private_key,
block_schedule::factory scheduler = block_schedule::by_threading_conflicts,
block_schedule::factory scheduler = block_schedule::in_single_thread,
uint32_t skip = skip_nothing
);
signed_block _generate_block(
......
......@@ -54,7 +54,7 @@ public:
bool _production_enabled = false;
uint32_t _required_producer_participation = 33 * config::Percent1;
uint32_t _production_skip_flags = eos::chain::chain_controller::skip_nothing;
eos::chain::block_schedule::factory _production_scheduler = eos::chain::block_schedule::by_threading_conflicts;
eos::chain::block_schedule::factory _production_scheduler = eos::chain::block_schedule::in_single_thread;
std::map<chain::public_key_type, fc::ecc::private_key> _private_keys;
std::set<types::AccountName> _producers;
......
......@@ -116,7 +116,7 @@ void testing_blockchain::produce_blocks(uint32_t count, uint32_t blocks_to_miss)
auto slot = blocks_to_miss + 1;
auto producer = get_producer(get_scheduled_producer(slot));
auto private_key = fixture.get_private_key(producer.signing_key);
generate_block(get_slot_time(slot), producer.owner, private_key, block_schedule::by_threading_conflicts,
generate_block(get_slot_time(slot), producer.owner, private_key, block_schedule::in_single_thread,
skip_trx_sigs? chain_controller::skip_transaction_signatures : 0);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册