votable objects now keep track of their most recent vote count
This commit is contained in:
parent
03175707ff
commit
c0c36ca639
7 changed files with 41 additions and 4 deletions
2
docs
2
docs
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3910642c234595beb88beaf9cae71913b6c81ded
|
Subproject commit cdc8ea8133a999afef8051700a4ce8edb0988ec4
|
||||||
|
|
@ -82,6 +82,19 @@ struct worker_pay_visitor
|
||||||
worker.pay_worker(pay, db);
|
worker.pay_worker(pay, db);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
void database::update_worker_votes()
|
||||||
|
{
|
||||||
|
auto& idx = get_index_type<worker_index>();
|
||||||
|
auto itr = idx.begin();
|
||||||
|
while( itr != idx.end() )
|
||||||
|
{
|
||||||
|
modify( **itr, [&]( worker_object& obj ){
|
||||||
|
obj.total_votes_for = _vote_tally_buffer[obj.vote_for];
|
||||||
|
obj.total_votes_against = _vote_tally_buffer[obj.vote_against];
|
||||||
|
});
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void database::pay_workers( share_type& budget )
|
void database::pay_workers( share_type& budget )
|
||||||
{
|
{
|
||||||
|
|
@ -140,6 +153,13 @@ void database::update_active_witnesses()
|
||||||
auto wits = sort_votable_objects<witness_index>(std::max(witness_count*2+1, (size_t)GRAPHENE_MIN_WITNESS_COUNT));
|
auto wits = sort_votable_objects<witness_index>(std::max(witness_count*2+1, (size_t)GRAPHENE_MIN_WITNESS_COUNT));
|
||||||
const global_property_object& gpo = get_global_properties();
|
const global_property_object& gpo = get_global_properties();
|
||||||
|
|
||||||
|
for( const witness_object& wit : wits )
|
||||||
|
{
|
||||||
|
modify( wit, [&]( witness_object& obj ){
|
||||||
|
obj.total_votes = _vote_tally_buffer[wit.vote_id];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Update witness authority
|
// Update witness authority
|
||||||
modify( get(GRAPHENE_WITNESS_ACCOUNT), [&]( account_object& a ) {
|
modify( get(GRAPHENE_WITNESS_ACCOUNT), [&]( account_object& a ) {
|
||||||
uint64_t total_votes = 0;
|
uint64_t total_votes = 0;
|
||||||
|
|
@ -205,6 +225,13 @@ void database::update_active_committee_members()
|
||||||
|
|
||||||
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT));
|
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT));
|
||||||
|
|
||||||
|
for( const committee_member_object& del : committee_members )
|
||||||
|
{
|
||||||
|
modify( del, [&]( committee_member_object& obj ){
|
||||||
|
obj.total_votes = _vote_tally_buffer[del.vote_id];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Update committee authorities
|
// Update committee authorities
|
||||||
if( !committee_members.empty() )
|
if( !committee_members.empty() )
|
||||||
{
|
{
|
||||||
|
|
@ -459,6 +486,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
||||||
|
|
||||||
update_active_witnesses();
|
update_active_witnesses();
|
||||||
update_active_committee_members();
|
update_active_committee_members();
|
||||||
|
update_worker_votes();
|
||||||
|
|
||||||
modify(gpo, [this](global_property_object& p) {
|
modify(gpo, [this](global_property_object& p) {
|
||||||
// Remove scaling of account registration fee
|
// Remove scaling of account registration fee
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
account_id_type committee_member_account;
|
account_id_type committee_member_account;
|
||||||
vote_id_type vote_id;
|
vote_id_type vote_id;
|
||||||
|
uint64_t total_votes = 0;
|
||||||
string url;
|
string url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -67,4 +68,4 @@ namespace graphene { namespace chain {
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object),
|
||||||
(committee_member_account)(vote_id)(url) )
|
(committee_member_account)(vote_id)(total_votes)(url) )
|
||||||
|
|
|
||||||
|
|
@ -465,6 +465,7 @@ namespace graphene { namespace chain {
|
||||||
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
|
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
|
||||||
void update_active_witnesses();
|
void update_active_witnesses();
|
||||||
void update_active_committee_members();
|
void update_active_committee_members();
|
||||||
|
void update_worker_votes();
|
||||||
|
|
||||||
template<class... Types>
|
template<class... Types>
|
||||||
void perform_account_maintenance(std::tuple<Types...> helpers);
|
void perform_account_maintenance(std::tuple<Types...> helpers);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ namespace graphene { namespace chain {
|
||||||
secret_hash_type previous_secret;
|
secret_hash_type previous_secret;
|
||||||
optional< vesting_balance_id_type > pay_vb;
|
optional< vesting_balance_id_type > pay_vb;
|
||||||
vote_id_type vote_id;
|
vote_id_type vote_id;
|
||||||
|
uint64_t total_votes = 0;
|
||||||
string url;
|
string url;
|
||||||
|
|
||||||
witness_object() : vote_id(vote_id_type::witness) {}
|
witness_object() : vote_id(vote_id_type::witness) {}
|
||||||
|
|
@ -68,4 +69,5 @@ FC_REFLECT_DERIVED( graphene::chain::witness_object, (graphene::db::object),
|
||||||
(previous_secret)
|
(previous_secret)
|
||||||
(pay_vb)
|
(pay_vb)
|
||||||
(vote_id)
|
(vote_id)
|
||||||
|
(total_votes)
|
||||||
(url) )
|
(url) )
|
||||||
|
|
|
||||||
|
|
@ -121,11 +121,14 @@ namespace graphene { namespace chain {
|
||||||
/// Voting ID which represents disapproval of this worker
|
/// Voting ID which represents disapproval of this worker
|
||||||
vote_id_type vote_against;
|
vote_id_type vote_against;
|
||||||
|
|
||||||
|
uint64_t total_votes_for = 0;
|
||||||
|
uint64_t total_votes_against = 0;
|
||||||
|
|
||||||
bool is_active(fc::time_point_sec now)const {
|
bool is_active(fc::time_point_sec now)const {
|
||||||
return now >= work_begin_date && now <= work_end_date;
|
return now >= work_begin_date && now <= work_end_date;
|
||||||
}
|
}
|
||||||
share_type approving_stake(const vector<uint64_t>& stake_vote_tallies)const {
|
share_type approving_stake(const vector<uint64_t>& stake_vote_tallies)const {
|
||||||
return stake_vote_tallies[vote_for] - stake_vote_tallies[vote_against];
|
return total_votes_for - total_votes_against;// stake_vote_tallies[vote_for] - stake_vote_tallies[vote_against];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -155,6 +158,8 @@ FC_REFLECT_DERIVED( graphene::chain::worker_object, (graphene::db::object),
|
||||||
(worker)
|
(worker)
|
||||||
(vote_for)
|
(vote_for)
|
||||||
(vote_against)
|
(vote_against)
|
||||||
|
(total_votes_for)
|
||||||
|
(total_votes_against)
|
||||||
(name)
|
(name)
|
||||||
(url)
|
(url)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9c868b3927a7c0aad3f628ad0071c92f11a0923c
|
Subproject commit 458b601774c36b702e2d4712320b5d53c6b2ee1c
|
||||||
Loading…
Reference in a new issue