Skip to content

Commit

Permalink
#551 pay miners and runner up witnesses 5x the top 19 per block produced
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemaster committed Nov 5, 2016
1 parent 45874e3 commit 318a461
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 18 additions & 2 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ void database::update_witness_schedule4()
/// Add the highest voted witnesses
flat_set< witness_id_type > selected_voted;
selected_voted.reserve( STEEMIT_MAX_VOTED_WITNESSES );

share_type vote_threshold = 0;
const auto& widx = get_index<witness_index>().indices().get<by_vote_name>();
for( auto itr = widx.begin();
itr != widx.end() && selected_voted.size() < STEEMIT_MAX_VOTED_WITNESSES;
Expand All @@ -1089,6 +1091,7 @@ void database::update_witness_schedule4()
continue;
selected_voted.insert( itr->id );
active_witnesses.push_back( itr->owner) ;
vote_threshold = itr->votes;
}

/// Add miners from the top of the mining queue
Expand Down Expand Up @@ -1246,6 +1249,8 @@ void database::update_witness_schedule4()

modify( wso, [&]( witness_schedule_object& _wso )
{
_wso.vote_threshold = vote_threshold;

// active witnesses has exactly STEEMIT_MAX_WITNESSES elements, asserted above
for( int i = 0; i < active_witnesses.size(); i++ )
{
Expand Down Expand Up @@ -2106,17 +2111,28 @@ void database::process_funds()
auto new_steem = (props.virtual_supply.amount * 95) / (1000 * STEEMIT_BLOCKS_PER_DAY *365);
auto content_reward = (new_steem * 75)/100; /// 75% to content creator
auto vesting_reward = (new_steem * 15)/100; /// 15% to content creator

auto witness_reward = new_steem - content_reward - vesting_reward;

const auto& cwit = get_witness( props.current_witness );
const witness_schedule_object& wso = get_witness_schedule_object();

if( wso.vote_threshold <= cwit.votes ) {
witness_reward = (5 * witness_reward * 19) / 29;
} else {
witness_reward = (1 * witness_reward * 19) / 29;
}
new_steem = content_reward + vesting_reward + witness_reward;

modify( props, [&]( dynamic_global_property_object& p ){
p.total_vesting_fund_steem += asset( vesting_reward, STEEM_SYMBOL );
p.total_reward_fund_steem += asset( content_reward, STEEM_SYMBOL );
p.current_supply += asset( new_steem, STEEM_SYMBOL );
p.virtual_supply += asset( new_steem, STEEM_SYMBOL );
});

const auto& cw = get_account( props.current_witness );
modify( cw, [&]( account_object& w ) {
const auto& cwa = get_account( props.current_witness );
modify( cwa, [&]( account_object& w ) {
w.balance += asset( witness_reward, STEEM_SYMBOL );
});
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/steemit/chain/witness_objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace steemit { namespace chain {
uint8_t num_scheduled_witnesses = 1;
chain_properties median_props;
version majority_version;
share_type vote_threshold; ///< threshold for top 19
};


Expand Down Expand Up @@ -233,6 +234,6 @@ CHAINBASE_SET_INDEX_TYPE( steemit::chain::witness_vote_object, steemit::chain::w

FC_REFLECT( steemit::chain::witness_schedule_object,
(id)(current_virtual_time)(next_shuffle_block_num)(current_shuffled_witnesses)(num_scheduled_witnesses)(median_props)
(majority_version)
(majority_version)(vote_threshold)
)
CHAINBASE_SET_INDEX_TYPE( steemit::chain::witness_schedule_object, steemit::chain::witness_schedule_index )

0 comments on commit 318a461

Please sign in to comment.