Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Change ProducersAuthorityThreshold type to UInt32
Browse files Browse the repository at this point in the history
  • Loading branch information
elmato committed Jul 14, 2017
1 parent 4756d36 commit 1265a87
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/chain_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void chain_controller::update_global_properties(const signed_block& b) {
gpo.configuration = std::move(config);
});

auto active_producers_authority = types::Authority(uint32_t(gpo.active_producers.size()*config::ProducersAuthorityThreshold), {}, {});
auto active_producers_authority = types::Authority(config::ProducersAuthorityThreshold, {}, {});
for(auto& name : gpo.active_producers) {
active_producers_authority.accounts.push_back({{name, config::ActiveName}, 1});
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eos/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const static ShareType DefaultElectedPay = Asset(100).amount;
const static ShareType DefaultRunnerUpPay = Asset(75).amount;
const static ShareType DefaultMinEosBalance = Asset(100).amount;
const static UInt32 DefaultMaxTrxLifetime = 60*60;
const static double ProducersAuthorityThreshold = 2.0/3.0;
const static UInt32 ProducersAuthorityThreshold = 14;

const static int BlocksPerRound = 21;
const static int VotedProducersPerRound = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ std::vector<chain::Message> native_contract_chain_initializer::prepare_database(
};

auto empty_authority = types::Authority(0, {}, {});
auto active_producers_authority = types::Authority(uint32_t(genesis.initial_producers.size()*config::ProducersAuthorityThreshold), {}, {});
auto active_producers_authority = types::Authority(config::ProducersAuthorityThreshold, {}, {});
for(auto& p : genesis.initial_producers) {
active_producers_authority.accounts.push_back({{p.owner_name, config::ActiveName}, 1});
}
Expand Down
7 changes: 2 additions & 5 deletions tests/tests/special_accounts_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, testing_fixture)
BOOST_CHECK(producers != nullptr);

auto& gpo = chain_db.get<global_property_object>();
auto threshold = uint32_t(gpo.active_producers.size()*config::ProducersAuthorityThreshold);

const auto& producers_active_authority = chain_db.get<permission_object, by_owner>(boost::make_tuple(config::ProducersAccountName, config::ActiveName));
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, threshold);
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, config::ProducersAuthorityThreshold);
BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), gpo.active_producers.size());
BOOST_CHECK_EQUAL(producers_active_authority.auth.keys.size(), 0);

Expand Down Expand Up @@ -109,10 +108,8 @@ BOOST_FIXTURE_TEST_CASE(producers_authority, testing_fixture)
BOOST_REQUIRE(boost::find(gpo.active_producers, "newproducer2") != gpo.active_producers.end());
BOOST_REQUIRE(boost::find(gpo.active_producers, "newproducer3") != gpo.active_producers.end());

auto threshold = uint32_t(gpo.active_producers.size()*config::ProducersAuthorityThreshold);

const auto& producers_active_authority = chain_db.get<permission_object, by_owner>(boost::make_tuple(config::ProducersAccountName, config::ActiveName));
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, threshold);
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, config::ProducersAuthorityThreshold);
BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), gpo.active_producers.size());
BOOST_CHECK_EQUAL(producers_active_authority.auth.keys.size(), 0);

Expand Down

0 comments on commit 1265a87

Please sign in to comment.