#280 Delete FC_REFLECT_TEMPLATE from votes #656
4 changed files with 22 additions and 30 deletions
|
|
@ -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_info_object<committee_member_id_type>> votes_for_committee_members;
|
||||
vector<votes_info_object> votes_for_committee_members;
|
||||
votes_for_committee_members.reserve(committee_ids.size());
|
||||
for (const auto &committee : committee_ids) {
|
||||
const auto &committee_obj = committee.as<committee_member_object>(2);
|
||||
votes_for_committee_members.emplace_back(votes_info_object<committee_member_id_type>{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_info_object<witness_id_type>> votes_for_witnesses;
|
||||
vector<votes_info_object> votes_for_witnesses;
|
||||
votes_for_witnesses.reserve(witness_ids.size());
|
||||
for (const auto &witness : witness_ids) {
|
||||
const auto &witness_obj = witness.as<witness_object>(2);
|
||||
votes_for_witnesses.emplace_back(votes_info_object<witness_id_type>{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_info_object<worker_id_type>> votes_for_workers;
|
||||
vector<votes_info_object> 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<worker_object>(2);
|
||||
votes_for_workers.emplace_back(votes_info_object<worker_id_type>{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_info_object<worker_id_type>> votes_against_workers;
|
||||
vector<votes_info_object> 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<worker_object>(2);
|
||||
votes_against_workers.emplace_back(votes_info_object<worker_id_type>{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_info_object<son_id_type>> votes_for_sons;
|
||||
vector<votes_info_object> votes_for_sons;
|
||||
votes_for_sons.reserve(son_ids.size());
|
||||
for (const auto &son : son_ids) {
|
||||
const auto &son_obj = son.as<son_object>(6);
|
||||
votes_for_sons.emplace_back(votes_info_object<son_id_type>{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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,11 @@ namespace graphene { namespace chain {
|
|||
|
||||
/**
|
||||
* @class votes_info_object
|
||||
* @tparam IdType id type of the object
|
||||
* @ingroup object
|
||||
*/
|
||||
template<typename IdType>
|
||||
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<committee_member_id_type> > > votes_for_committee_members;
|
||||
optional< vector< votes_info_object<witness_id_type> > > votes_for_witnesses;
|
||||
optional< vector< votes_info_object<worker_id_type> > > votes_for_workers;
|
||||
optional< vector< votes_info_object<worker_id_type> > > votes_against_workers;
|
||||
optional< vector< votes_info_object<son_id_type> > > 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<IdType>,
|
||||
FC_REFLECT( graphene::chain::votes_info_object,
|
||||
(vote_id)
|
||||
(id) )
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue