Disable negative voting on workers #607
This commit is contained in:
parent
241a7b0c3a
commit
14f7b520bd
3 changed files with 22 additions and 1 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include <graphene/chain/internal_exceptions.hpp>
|
||||
#include <graphene/chain/special_authority.hpp>
|
||||
#include <graphene/chain/special_authority_object.hpp>
|
||||
#include <graphene/chain/worker_object.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -69,10 +70,25 @@ void verify_account_votes( const database& db, const account_options& options )
|
|||
"Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) );
|
||||
|
||||
uint32_t max_vote_id = gpo.next_available_vote_id;
|
||||
bool has_worker_votes = false;
|
||||
for( auto id : options.votes )
|
||||
{
|
||||
FC_ASSERT( id < max_vote_id );
|
||||
has_worker_votes |= (id.type() == vote_id_type::worker);
|
||||
}
|
||||
|
||||
if( has_worker_votes && (db.head_block_time() >= HARDFORK_607_TIME) )
|
||||
{
|
||||
const auto& against_worker_idx = db.get_index_type<worker_index>().indices().get<by_vote_against>();
|
||||
for( auto id : options.votes )
|
||||
{
|
||||
if( id.type() == vote_id_type::worker )
|
||||
{
|
||||
FC_ASSERT( against_worker_idx.find( id ) == against_worker_idx.end() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -102,11 +102,12 @@ void database::update_worker_votes()
|
|||
{
|
||||
auto& idx = get_index_type<worker_index>();
|
||||
auto itr = idx.indices().get<by_account>().begin();
|
||||
bool allow_negative_votes = (head_block_time() < HARDFORK_607_TIME);
|
||||
while( itr != idx.indices().get<by_account>().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];
|
||||
obj.total_votes_against = allow_negative_votes ? _vote_tally_buffer[obj.vote_against] : 0;
|
||||
});
|
||||
++itr;
|
||||
}
|
||||
|
|
|
|||
4
libraries/chain/hardfork.d/607.hf
Normal file
4
libraries/chain/hardfork.d/607.hf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// #607 Disable negative voting on workers
|
||||
#ifndef HARDFORK_607_TIME
|
||||
#define HARDFORK_607_TIME (fc::time_point_sec( 1458061200 ))
|
||||
#endif
|
||||
Loading…
Reference in a new issue