Reserve witness ID 0
This commit is contained in:
parent
b236d46027
commit
dd9dbca38c
5 changed files with 14 additions and 4 deletions
|
|
@ -549,6 +549,11 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
|
||||
// TODO: Assert that bitasset debt = supply
|
||||
|
||||
// Create special witness account
|
||||
const witness_object& wit = create<witness_object>([&](witness_object& w) {});
|
||||
FC_ASSERT( wit.id == GRAPHENE_NULL_WITNESS );
|
||||
remove(wit);
|
||||
|
||||
// Create initial witnesses
|
||||
std::for_each(genesis_state.initial_witness_candidates.begin(), genesis_state.initial_witness_candidates.end(),
|
||||
[&](const genesis_state_type::initial_witness_type& witness) {
|
||||
|
|
@ -583,7 +588,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
|
||||
// Set active witnesses
|
||||
modify(get_global_properties(), [&](global_property_object& p) {
|
||||
for( int i = 0; i < genesis_state.initial_active_witnesses; ++i )
|
||||
for( int i = 1; i <= genesis_state.initial_active_witnesses; ++i )
|
||||
{
|
||||
p.active_witnesses.insert(i);
|
||||
p.witness_accounts.insert(get(witness_id_type(i)).witness_account);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ witness_id_type database::get_scheduled_witness( uint32_t slot_num )const
|
|||
// [1] https://en.wikipedia.org/wiki/Xorshift#Xorshift.2A
|
||||
//
|
||||
|
||||
if( slot_num == 0 )
|
||||
return GRAPHENE_NULL_WITNESS;
|
||||
|
||||
const flat_set< witness_id_type >& active_witnesses = get_global_properties().active_witnesses;
|
||||
uint32_t n = active_witnesses.size();
|
||||
uint64_t min_witness_separation;
|
||||
|
|
|
|||
|
|
@ -154,4 +154,6 @@
|
|||
#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4))
|
||||
/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy)
|
||||
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5))
|
||||
/// Sentinel value used in the scheduler.
|
||||
#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0))
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ namespace graphene { namespace chain {
|
|||
* Use the get_slot_time() and get_slot_at_time() functions
|
||||
* to convert between slot_num and timestamp.
|
||||
*
|
||||
* Passing slot_num == 0 returns witness_id_type()
|
||||
* Passing slot_num == 0 returns GRAPHENE_NULL_WITNESS
|
||||
*/
|
||||
witness_id_type get_scheduled_witness(uint32_t slot_num)const;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void witness_plugin::plugin_set_program_options(
|
|||
boost::program_options::options_description& config_file_options)
|
||||
{
|
||||
auto default_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(std::string("nathan")));
|
||||
string witness_id_example = fc::json::to_string(chain::witness_id_type());
|
||||
string witness_id_example = fc::json::to_string(chain::witness_id_type(5));
|
||||
command_line_options.add_options()
|
||||
("enable-stale-production", bpo::bool_switch()->notifier([this](bool e){_production_enabled = e;}), "Enable block production, even if the chain is stale.")
|
||||
("required-participation", bpo::bool_switch()->notifier([this](int e){_required_witness_participation = uint32_t(e*GRAPHENE_1_PERCENT);}), "Percent of witnesses (0-99) that must be participating in order to produce blocks")
|
||||
|
|
@ -226,7 +226,7 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc
|
|||
elog("Not producing block because node didn't wake up within 500ms of the slot time.");
|
||||
break;
|
||||
case block_production_condition::consecutive:
|
||||
elog("Not producting block because the last block was generated by the same witness.\nThis node is probably disconnected from the network so block production has been disabled.\nDisable this check with --allow-consecutive option.");
|
||||
elog("Not producing block because the last block was generated by the same witness.\nThis node is probably disconnected from the network so block production has been disabled.\nDisable this check with --allow-consecutive option.");
|
||||
break;
|
||||
case block_production_condition::exception_producing_block:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue