Commit bf01fcf2 authored by Michael Vandeberg's avatar Michael Vandeberg

Add absolute vote change limit #22

parent e8ec57ed
......@@ -122,6 +122,7 @@ namespace steemit { namespace chain {
int64_t rshares = 0; ///< The number of rshares this vote is responsible for
int16_t vote_percent = 0; ///< The percent weight of the vote
time_point_sec last_update; ///< The time of the last update of the vote
uint8_t num_changes = 0;
};
struct by_comment_voter;
......
......@@ -70,6 +70,7 @@
#define STEEMIT_VESTING_WITHDRAW_INTERVALS 104
#define STEEMIT_VESTING_WITHDRAW_INTERVAL_SECONDS (60*60*24*7) /// 1 week per interval
#define STEEMIT_VOTE_REGENERATION_SECONDS (60*60*24) // 1 day
#define STEEMIT_MAX_VOTE_CHANGES 5
#define STEEMIT_MAX_ACCOUNT_WITNESS_VOTES 30
......
......@@ -626,8 +626,8 @@ void vote_evaluator::do_apply( const vote_operation& o )
}
else
{
FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_5__22 ), "Cannot change votes until hardfork 0_5_0" );
FC_ASSERT( db().has_hardfork( STEEMIT_HARDFORK_0_5__22 ), "Cannot change votes until hardfork 0_5" );
FC_ASSERT( itr->num_changes < STEEMIT_MAX_VOTE_CHANGES, "Cannot change vote again" );
auto elapsed_seconds = (db().head_block_time() - voter.last_vote_time).to_seconds();
auto regenerated_power = ((STEEMIT_100_PERCENT - voter.voting_power) * elapsed_seconds) / STEEMIT_VOTE_REGENERATION_SECONDS;
......@@ -686,6 +686,7 @@ void vote_evaluator::do_apply( const vote_operation& o )
cv.vote_percent = o.weight;
cv.last_update = db().head_block_time();
cv.weight = 0;
cv.num_changes += 1;
});
db().adjust_rshares2( comment, old_rshares, new_rshares );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment