Added sweeps parameters to parameter_extension
This commit is contained in:
parent
8f43ff91ae
commit
59e48a1833
2 changed files with 23 additions and 20 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 )
|
for( auto t = tickets.begin(); t != tickets.begin() + holders.size(); ++t )
|
||||||
*t += percents_to_distribute / holders.size();
|
*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 ) {
|
for( int c = 0; c < winner_numbers.size(); ++c ) {
|
||||||
auto winner_num = winner_numbers[c];
|
auto winner_num = winner_numbers[c];
|
||||||
lottery_reward_operation reward_op;
|
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& 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;
|
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;
|
uint64_t holders_sum = 0;
|
||||||
for( const account_balance_object& holder_balance : boost::make_iterator_range( range.first, range.second ) )
|
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;
|
holders_sum += holder_part;
|
||||||
}
|
}
|
||||||
uint64_t balance_rest = db.get_balance( get_id() ).amount.value * SWEEPS_VESTING_BALANCE_MULTIPLIER - holders_sum;
|
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() ) );
|
db.adjust_balance( get_id(), -db.get_balance( get_id() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,23 +30,18 @@
|
||||||
namespace graphene { namespace chain { struct fee_schedule; } }
|
namespace graphene { namespace chain { struct fee_schedule; } }
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
struct bet_parameter_extension
|
struct parameter_extension
|
||||||
{
|
{
|
||||||
optional< bet_multiplier_type > min_bet_multiplier;
|
optional< bet_multiplier_type > min_bet_multiplier;
|
||||||
optional< bet_multiplier_type > max_bet_multiplier;
|
optional< bet_multiplier_type > max_bet_multiplier;
|
||||||
optional< uint16_t > betting_rake_fee_percentage;
|
optional< uint16_t > betting_rake_fee_percentage;
|
||||||
optional< flat_map<bet_multiplier_type, bet_multiplier_type> > permitted_betting_odds_increments;
|
optional< flat_map<bet_multiplier_type, bet_multiplier_type> > permitted_betting_odds_increments;
|
||||||
optional< uint16_t > live_betting_delay_time;
|
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
|
struct chain_parameters
|
||||||
{
|
{
|
||||||
/** using a smart ref breaks the circular dependency created between operations and the fee schedule */
|
/** using a smart ref breaks the circular dependency created between operations and the fee schedule */
|
||||||
|
|
@ -98,7 +93,7 @@ namespace graphene { namespace chain {
|
||||||
uint16_t sweeps_distribution_percentage = SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE;
|
uint16_t sweeps_distribution_percentage = SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE;
|
||||||
asset_id_type sweeps_distribution_asset = SWEEPS_DEFAULT_DISTRIBUTION_ASSET;
|
asset_id_type sweeps_distribution_asset = SWEEPS_DEFAULT_DISTRIBUTION_ASSET;
|
||||||
|
|
||||||
extension<parameter_extension> extensions = sweeps_parameters_extension();
|
extension<parameter_extension> extensions;
|
||||||
|
|
||||||
/** defined in fee_schedule.cpp */
|
/** defined in fee_schedule.cpp */
|
||||||
void validate()const;
|
void validate()const;
|
||||||
|
|
@ -118,22 +113,30 @@ namespace graphene { namespace chain {
|
||||||
inline uint16_t live_betting_delay_time()const {
|
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;
|
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
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::bet_parameter_extension,
|
FC_REFLECT( graphene::chain::parameter_extension,
|
||||||
(min_bet_multiplier)
|
(min_bet_multiplier)
|
||||||
(max_bet_multiplier)
|
(max_bet_multiplier)
|
||||||
(betting_rake_fee_percentage)
|
(betting_rake_fee_percentage)
|
||||||
(permitted_betting_odds_increments)
|
(permitted_betting_odds_increments)
|
||||||
(live_betting_delay_time)
|
(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,
|
FC_REFLECT( graphene::chain::chain_parameters,
|
||||||
(current_fees)
|
(current_fees)
|
||||||
(block_interval)
|
(block_interval)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue