diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 22fbfb6a..a9ea9774 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2139,51 +2139,51 @@ votes_info database_api_impl::get_votes(const string &account_name_or_id) const //! Fill votes info if (!committee_ids.empty()) { - vector> votes_for_committee_members; + vector votes_for_committee_members; votes_for_committee_members.reserve(committee_ids.size()); for (const auto &committee : committee_ids) { const auto &committee_obj = committee.as(2); - votes_for_committee_members.emplace_back(votes_info_object{committee_obj.vote_id, committee_obj.id.instance()}); + votes_for_committee_members.emplace_back(votes_info_object{committee_obj.vote_id, committee_obj.id}); } result.votes_for_committee_members = std::move(votes_for_committee_members); } if (!witness_ids.empty()) { - vector> votes_for_witnesses; + vector votes_for_witnesses; votes_for_witnesses.reserve(witness_ids.size()); for (const auto &witness : witness_ids) { const auto &witness_obj = witness.as(2); - votes_for_witnesses.emplace_back(votes_info_object{witness_obj.vote_id, witness_obj.id.instance()}); + votes_for_witnesses.emplace_back(votes_info_object{witness_obj.vote_id, witness_obj.id}); } result.votes_for_witnesses = std::move(votes_for_witnesses); } if (!for_worker_ids.empty()) { - vector> votes_for_workers; + vector votes_for_workers; votes_for_workers.reserve(for_worker_ids.size()); for (const auto &for_worker : for_worker_ids) { const auto &for_worker_obj = for_worker.as(2); - votes_for_workers.emplace_back(votes_info_object{for_worker_obj.vote_for, for_worker_obj.id.instance()}); + votes_for_workers.emplace_back(votes_info_object{for_worker_obj.vote_for, for_worker_obj.id}); } result.votes_for_workers = std::move(votes_for_workers); } if (!against_worker_ids.empty()) { - vector> votes_against_workers; + vector votes_against_workers; votes_against_workers.reserve(against_worker_ids.size()); for (const auto &against_worker : against_worker_ids) { const auto &against_worker_obj = against_worker.as(2); - votes_against_workers.emplace_back(votes_info_object{against_worker_obj.vote_against, against_worker_obj.id.instance()}); + votes_against_workers.emplace_back(votes_info_object{against_worker_obj.vote_against, against_worker_obj.id}); } result.votes_against_workers = std::move(votes_against_workers); } if (!son_ids.empty()) { - vector> votes_for_sons; + vector votes_for_sons; votes_for_sons.reserve(son_ids.size()); for (const auto &son : son_ids) { const auto &son_obj = son.as(6); - votes_for_sons.emplace_back(votes_info_object{son_obj.vote_id, son_obj.id.instance()}); + votes_for_sons.emplace_back(votes_info_object{son_obj.vote_id, son_obj.id}); } result.votes_for_sons = std::move(votes_for_sons); } diff --git a/libraries/chain/include/graphene/chain/votes_info.hpp b/libraries/chain/include/graphene/chain/votes_info.hpp index b802a020..0a515589 100644 --- a/libraries/chain/include/graphene/chain/votes_info.hpp +++ b/libraries/chain/include/graphene/chain/votes_info.hpp @@ -6,19 +6,11 @@ namespace graphene { namespace chain { /** * @class votes_info_object - * @tparam IdType id type of the object * @ingroup object */ - template struct votes_info_object { - votes_info_object() = default; - votes_info_object(const vote_id_type& vote_id_, uint64_t id_) - : vote_id{vote_id_} - , id{id_} - {} - vote_id_type vote_id; - IdType id; + object_id_type id; }; /** @@ -27,16 +19,16 @@ namespace graphene { namespace chain { * @ingroup object */ struct votes_info { - optional< vector< votes_info_object > > votes_for_committee_members; - optional< vector< votes_info_object > > votes_for_witnesses; - optional< vector< votes_info_object > > votes_for_workers; - optional< vector< votes_info_object > > votes_against_workers; - optional< vector< votes_info_object > > votes_for_sons; + optional< vector< votes_info_object > > votes_for_committee_members; + optional< vector< votes_info_object > > votes_for_witnesses; + optional< vector< votes_info_object > > votes_for_workers; + optional< vector< votes_info_object > > votes_against_workers; + optional< vector< votes_info_object > > votes_for_sons; }; } } // graphene::chain -FC_REFLECT_TEMPLATE( (typename IdType), graphene::chain::votes_info_object, +FC_REFLECT( graphene::chain::votes_info_object, (vote_id) (id) ) diff --git a/tests/cli/son.cpp b/tests/cli/son.cpp index b2dba7b4..a8d06c2c 100644 --- a/tests/cli/son.cpp +++ b/tests/cli/son.cpp @@ -263,8 +263,8 @@ BOOST_AUTO_TEST_CASE( son_voting ) auto nathan_votes = con.wallet_api_ptr->get_votes("nathan"); BOOST_REQUIRE(nathan_votes.votes_for_sons); BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->size(), 2); - BOOST_CHECK_EQUAL((uint32_t)nathan_votes.votes_for_sons->at(0).id.instance, son1_obj.id.instance()); - BOOST_CHECK_EQUAL((uint32_t)nathan_votes.votes_for_sons->at(1).id.instance, son2_obj.id.instance()); + BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(0).id.instance(), son1_obj.id.instance()); + BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(1).id.instance(), son2_obj.id.instance()); // Withdraw vote for a son1account BOOST_TEST_MESSAGE("Withdraw vote for a son1account"); @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE( son_voting ) nathan_votes = con.wallet_api_ptr->get_votes("nathan"); BOOST_REQUIRE(nathan_votes.votes_for_sons); BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->size(), 1); - BOOST_CHECK_EQUAL((uint32_t)nathan_votes.votes_for_sons->at(0).id.instance, son2_obj.id.instance()); + BOOST_CHECK_EQUAL(nathan_votes.votes_for_sons->at(0).id.instance(), son2_obj.id.instance()); // Withdraw vote for a son2account BOOST_TEST_MESSAGE("Withdraw vote for a son2account"); diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index 2003534a..ad6c3ee7 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -332,7 +332,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_enabled) const auto account_votes = db_api1.get_votes("1.2.18"); BOOST_REQUIRE(account_votes.votes_for_witnesses); BOOST_CHECK_EQUAL(account_votes.votes_for_witnesses->size(), 1); - BOOST_CHECK_EQUAL((uint32_t)account_votes.votes_for_witnesses->at(0).id.instance, witness1_object->id.instance()); + BOOST_CHECK_EQUAL(account_votes.votes_for_witnesses->at(0).id.instance(), witness1_object->id.instance()); } FC_LOG_AND_RETHROW() } @@ -522,7 +522,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_enabled) //! Check votes of account const auto account_votes = db_api1.get_votes("1.2.18"); BOOST_REQUIRE(account_votes.votes_for_committee_members); - BOOST_CHECK_EQUAL((uint32_t)account_votes.votes_for_committee_members->back().id.instance, committee1_object->id.instance()); + BOOST_CHECK_EQUAL(account_votes.votes_for_committee_members->back().id.instance(), committee1_object->id.instance()); } FC_LOG_AND_RETHROW() }