Added sweeps parameters to parameter_extension
This commit is contained in:
parent
4829c3dd93
commit
3db62bbe46
2 changed files with 22 additions and 19 deletions
|
|
@ -223,7 +223,7 @@ map< account_id_type, vector< uint16_t > > asset_object::distribute_winners_part
|
|||
for( auto t = tickets.begin(); t != tickets.begin() + holders.size(); ++t )
|
||||
*t += percents_to_distribute / holders.size();
|
||||
}
|
||||
auto sweeps_distribution_percentage = db.get_global_properties().parameters.extensions.get<sweeps_parameters_extension>().sweeps_distribution_percentage;
|
||||
auto sweeps_distribution_percentage = db.get_global_properties().parameters.sweeps_distribution_percentage();
|
||||
for( int c = 0; c < winner_numbers.size(); ++c ) {
|
||||
auto winner_num = winner_numbers[c];
|
||||
lottery_reward_operation reward_op;
|
||||
|
|
@ -244,9 +244,9 @@ void asset_object::distribute_sweeps_holders_part( database& db )
|
|||
|
||||
auto& asset_bal_idx = db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
|
||||
|
||||
auto sweeps_params = db.get_global_properties().parameters.extensions.get<sweeps_parameters_extension>();
|
||||
auto sweeps_params = db.get_global_properties().parameters;
|
||||
uint64_t distribution_asset_supply = sweeps_params.sweeps_distribution_asset( db ).dynamic_data( db ).current_supply.value;
|
||||
const auto range = asset_bal_idx.equal_range( boost::make_tuple( sweeps_params.sweeps_distribution_asset ) );
|
||||
const auto range = asset_bal_idx.equal_range( boost::make_tuple( sweeps_params.sweeps_distribution_asset() ) );
|
||||
|
||||
uint64_t holders_sum = 0;
|
||||
for( const account_balance_object& holder_balance : boost::make_iterator_range( range.first, range.second ) )
|
||||
|
|
@ -256,7 +256,7 @@ void asset_object::distribute_sweeps_holders_part( database& db )
|
|||
holders_sum += holder_part;
|
||||
}
|
||||
uint64_t balance_rest = db.get_balance( get_id() ).amount.value * SWEEPS_VESTING_BALANCE_MULTIPLIER - holders_sum;
|
||||
db.adjust_sweeps_vesting_balance( sweeps_params.sweeps_vesting_accumulator_account, balance_rest );
|
||||
db.adjust_sweeps_vesting_balance( sweeps_params.sweeps_vesting_accumulator_account(), balance_rest );
|
||||
db.adjust_balance( get_id(), -db.get_balance( get_id() ) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,23 +36,18 @@ namespace fc {
|
|||
*/
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
struct bet_parameter_extension
|
||||
struct parameter_extension
|
||||
{
|
||||
optional< bet_multiplier_type > min_bet_multiplier;
|
||||
optional< bet_multiplier_type > max_bet_multiplier;
|
||||
optional< uint16_t > betting_rake_fee_percentage;
|
||||
optional< flat_map<bet_multiplier_type, bet_multiplier_type> > permitted_betting_odds_increments;
|
||||
optional< uint16_t > live_betting_delay_time;
|
||||
optional< uint16_t > sweeps_distribution_percentage;
|
||||
optional< asset_id_type > sweeps_distribution_asset;
|
||||
optional< account_id_type > sweeps_vesting_accumulator_account;
|
||||
};
|
||||
|
||||
struct sweeps_parameters_extension {
|
||||
uint16_t sweeps_distribution_percentage = SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE;
|
||||
asset_id_type sweeps_distribution_asset = SWEEPS_DEFAULT_DISTRIBUTION_ASSET;
|
||||
account_id_type sweeps_vesting_accumulator_account = SWEEPS_ACCUMULATOR_ACCOUNT;
|
||||
};
|
||||
|
||||
typedef static_variant<void_t,sweeps_parameters_extension,bet_parameter_extension> parameter_extension;
|
||||
|
||||
struct chain_parameters
|
||||
{
|
||||
/** using a smart ref breaks the circular dependency created between operations and the fee schedule */
|
||||
|
|
@ -101,7 +96,7 @@ namespace graphene { namespace chain {
|
|||
uint32_t maximum_tournament_start_delay = TOURNAMENT_MAX_START_DELAY;
|
||||
uint16_t maximum_tournament_number_of_wins = TOURNAMENT_MAX_NUMBER_OF_WINS;
|
||||
|
||||
parameter_extension extensions = sweeps_parameters_extension();
|
||||
extension<parameter_extension> extensions;
|
||||
|
||||
/** defined in fee_schedule.cpp */
|
||||
void validate()const;
|
||||
|
|
@ -121,22 +116,30 @@ namespace graphene { namespace chain {
|
|||
inline uint16_t live_betting_delay_time()const {
|
||||
return extensions.value.live_betting_delay_time.valid() ? *extensions.value.live_betting_delay_time : GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME;
|
||||
}
|
||||
inline uint16_t sweeps_distribution_percentage()const {
|
||||
return extensions.value.sweeps_distribution_percentage.valid() ? *extensions.value.sweeps_distribution_percentage : SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE;
|
||||
}
|
||||
inline uint16_t sweeps_distribution_asset()const {
|
||||
return extensions.value.sweeps_distribution_asset.valid() ? *extensions.value.sweeps_distribution_asset : SWEEPS_DEFAULT_DISTRIBUTION_ASSET;
|
||||
}
|
||||
inline uint16_t sweeps_vesting_accumulator_account()const {
|
||||
return extensions.value.sweeps_vesting_accumulator_account.valid() ? *extensions.value.sweeps_vesting_accumulator_account : SWEEPS_ACCUMULATOR_ACCOUNT;
|
||||
}
|
||||
};
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT( graphene::chain::bet_parameter_extension,
|
||||
FC_REFLECT( graphene::chain::parameter_extension,
|
||||
(min_bet_multiplier)
|
||||
(max_bet_multiplier)
|
||||
(betting_rake_fee_percentage)
|
||||
(permitted_betting_odds_increments)
|
||||
(live_betting_delay_time)
|
||||
(sweeps_distribution_percentage)
|
||||
(sweeps_distribution_asset)
|
||||
(sweeps_vesting_accumulator_account)
|
||||
)
|
||||
|
||||
FC_REFLECT( graphene::chain::sweeps_parameters_extension,
|
||||
(sweeps_distribution_percentage)
|
||||
(sweeps_distribution_asset) )
|
||||
|
||||
FC_REFLECT( graphene::chain::chain_parameters,
|
||||
(current_fees)
|
||||
(block_interval)
|
||||
|
|
|
|||
Loading…
Reference in a new issue