diff --git a/libraries/chain/chain_controller.cpp b/libraries/chain/chain_controller.cpp index 4e88f25b1a1..ecc34c6e189 100644 --- a/libraries/chain/chain_controller.cpp +++ b/libraries/chain/chain_controller.cpp @@ -1486,21 +1486,25 @@ void chain_controller::update_global_properties(const signed_block& b) { try { } }); - - uint32_t authority_threshold = EOS_PERCENT_CEIL(gpo.active_producers.producers.size(), config::producers_authority_threshold_pct); - auto active_producers_authority = authority(authority_threshold, {}, {}); - for(auto& name : gpo.active_producers.producers ) { - active_producers_authority.accounts.push_back({{name.producer_name, config::active_name}, 1}); - } - - auto& po = _db.get( boost::make_tuple(config::producers_account_name, - config::active_name ) ); - _db.modify(po,[active_producers_authority] (permission_object& po) { - po.auth = active_producers_authority; - }); + _update_producers_authority(); } } FC_CAPTURE_AND_RETHROW() } +void chain_controller::_update_producers_authority() { + const auto& gpo = get_global_properties(); + uint32_t authority_threshold = EOS_PERCENT_CEIL(gpo.active_producers.producers.size(), config::producers_authority_threshold_pct); + auto active_producers_authority = authority(authority_threshold, {}, {}); + for(auto& name : gpo.active_producers.producers ) { + active_producers_authority.accounts.push_back({{name.producer_name, config::active_name}, 1}); + } + + auto& po = _db.get( boost::make_tuple(config::producers_account_name, + config::active_name ) ); + _db.modify(po,[active_producers_authority] (permission_object& po) { + po.auth = active_producers_authority; + }); +} + void chain_controller::add_checkpoints( const flat_map& checkpts ) { for (const auto& i : checkpts) _checkpoints[i.first] = i.second; @@ -1607,6 +1611,7 @@ void chain_controller::_initialize_chain(contracts::chain_initializer& starter) _db.create([&](block_summary_object&) {}); starter.prepare_database(*this, _db); + _update_producers_authority(); }); } } FC_CAPTURE_AND_RETHROW() } diff --git a/libraries/chain/include/eosio/chain/chain_controller.hpp b/libraries/chain/include/eosio/chain/chain_controller.hpp index 8cab8787197..5f33d6fd61f 100644 --- a/libraries/chain/include/eosio/chain/chain_controller.hpp +++ b/libraries/chain/include/eosio/chain/chain_controller.hpp @@ -345,6 +345,7 @@ namespace eosio { namespace chain { /// Reset the object graph in-memory void _initialize_indexes(); void _initialize_chain(contracts::chain_initializer& starter); + void _update_producers_authority(); producer_schedule_type _calculate_producer_schedule()const; const shared_producer_schedule_type& _head_producer_schedule()const;