提交 e3f22656 编写于 作者: B Bart Wyatt

Make the scheduler potentially vary per produced block, controlled by the producer plugin

上级 d0828b2b
......@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include <eos/chain/block_schedule.hpp>
#include <eos/chain/block.hpp>
namespace eos { namespace chain {
......
......@@ -26,7 +26,6 @@
#include <eos/chain/exceptions.hpp>
#include <eos/chain/block_summary_object.hpp>
#include <eos/chain/block_schedule.hpp>
#include <eos/chain/global_property_object.hpp>
#include <eos/chain/key_value_object.hpp>
#include <eos/chain/action_objects.hpp>
......@@ -263,12 +262,13 @@ signed_block chain_controller::generate_block(
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_conflits */
uint32_t skip /* = 0 */
)
{ try {
return with_skip_flags( skip, [&](){
auto b = _db.with_write_lock( [&](){
return _generate_block( when, producer, block_signing_private_key );
return _generate_block( when, producer, block_signing_private_key, scheduler );
});
push_block(b, skip);
return b;
......@@ -278,7 +278,8 @@ signed_block chain_controller::generate_block(
signed_block chain_controller::_generate_block(
fc::time_point_sec when,
const AccountName& producer,
const fc::ecc::private_key& block_signing_private_key
const fc::ecc::private_key& block_signing_private_key,
block_schedule::factory scheduler
)
{
try {
......@@ -306,7 +307,7 @@ signed_block chain_controller::_generate_block(
pending.emplace_back(pending_transaction {&st});
}
auto schedule = block_schedule::by_threading_conflicts(pending, get_global_properties());
auto schedule = scheduler(pending, get_global_properties());
//
// The following code throws away existing pending_tx_session and
......
......@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <eos/chain/chain_controller.hpp>
#include <eos/chain/global_property_object.hpp>
#include <eos/chain/transaction.hpp>
namespace eos { namespace chain {
......@@ -40,6 +40,7 @@ namespace eos { namespace chain {
*/
struct block_schedule
{
typedef block_schedule (*factory)(vector<pending_transaction> const &, const global_property_object&);
vector<cycle_schedule> cycles;
// Algorithms
......
......@@ -32,6 +32,7 @@
#include <boost/signals2/signal.hpp>
#include <eos/chain/block_schedule.hpp>
#include <eos/chain/protocol.hpp>
#include <eos/chain/message_handling_contexts.hpp>
#include <eos/chain/chain_initializer_interface.hpp>
......@@ -152,12 +153,14 @@ namespace eos { namespace chain {
fc::time_point_sec when,
const AccountName& producer,
const fc::ecc::private_key& block_signing_private_key,
uint32_t skip
block_schedule::factory scheduler = block_schedule::by_threading_conflicts,
uint32_t skip = skip_nothing
);
signed_block _generate_block(
fc::time_point_sec when,
const AccountName& producer,
const fc::ecc::private_key& block_signing_private_key
const fc::ecc::private_key& block_signing_private_key,
block_schedule::factory scheduler
);
......
......@@ -54,6 +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;
std::map<chain::public_key_type, fc::ecc::private_key> _private_keys;
std::set<types::AccountName> _producers;
......@@ -301,6 +302,7 @@ block_production_condition::block_production_condition_enum producer_plugin_impl
scheduled_time,
scheduled_producer,
private_key_itr->second,
_production_scheduler,
_production_skip_flags
);
capture("n", block.block_num())("t", block.timestamp)("c", now);
......
......@@ -107,7 +107,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, 0);
generate_block(get_slot_time(slot), producer.owner, private_key);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册