added delay_bets to betting_market_group_object, live_betting_delay_time to chain parametrs .

This commit is contained in:
Roman Olearski 2017-08-10 21:29:26 +02:00
parent 1dce94f2dc
commit a2b83c668f
8 changed files with 46 additions and 14 deletions

View file

@ -112,6 +112,7 @@ object_id_type betting_market_group_create_evaluator::do_apply(const betting_mar
betting_market_group_obj.description = op.description; betting_market_group_obj.description = op.description;
betting_market_group_obj.asset_id = op.asset_id; betting_market_group_obj.asset_id = op.asset_id;
betting_market_group_obj.frozen = false; betting_market_group_obj.frozen = false;
betting_market_group_obj.delay_bets = false;
}); });
return new_betting_market_group.id; return new_betting_market_group.id;
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
@ -119,7 +120,11 @@ object_id_type betting_market_group_create_evaluator::do_apply(const betting_mar
void_result betting_market_group_update_evaluator::do_evaluate(const betting_market_group_update_operation& op) void_result betting_market_group_update_evaluator::do_evaluate(const betting_market_group_update_operation& op)
{ try { { try {
FC_ASSERT(trx_state->_is_proposed_trx); FC_ASSERT(trx_state->_is_proposed_trx);
FC_ASSERT(op.new_event_id.valid() || op.new_description.valid() || op.new_rules_id.valid() || op.freeze.valid(), "nothing to change"); FC_ASSERT(op.new_event_id.valid() ||
op.new_description.valid() ||
op.new_rules_id.valid() ||
op.freeze.valid() ||
op.delay_bets.valid(), "nothing to change");
// the event_id in the operation can be a relative id. If it is, // the event_id in the operation can be a relative id. If it is,
// resolve it and verify that it is truly an event // resolve it and verify that it is truly an event
@ -157,6 +162,11 @@ void_result betting_market_group_update_evaluator::do_evaluate(const betting_mar
FC_ASSERT(_betting_market_group->frozen != *op.freeze, "freeze would not change the state of the betting market group"); FC_ASSERT(_betting_market_group->frozen != *op.freeze, "freeze would not change the state of the betting market group");
} }
if (op.delay_bets.valid())
{
const auto& _betting_market_group = &op.betting_market_group_id(db());
FC_ASSERT(_betting_market_group->delay_bets != *op.delay_bets, "delay_bets would not change the state of the betting market group");
}
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
@ -175,6 +185,8 @@ void_result betting_market_group_update_evaluator::do_apply(const betting_market
bmgo.rules_id = rules_id; bmgo.rules_id = rules_id;
if( op.freeze.valid() ) if( op.freeze.valid() )
bmgo.frozen = *op.freeze; bmgo.frozen = *op.freeze;
if( op.delay_bets.valid() )
bmgo.delay_bets = *op.delay_bets;
}); });
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }
@ -306,7 +318,8 @@ object_id_type bet_place_evaluator::do_apply(const bet_place_operation& op)
d.adjust_balance(fee_paying_account->id, -op.amount_to_bet); d.adjust_balance(fee_paying_account->id, -op.amount_to_bet);
bool bet_matched = d.place_bet(new_bet); //bool bet_matched =
d.place_bet(new_bet);
return new_bet_id; return new_bet_id;
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -65,6 +65,8 @@ class betting_market_group_object : public graphene::db::abstract_object< bettin
share_type total_matched_bets_amount; share_type total_matched_bets_amount;
bool frozen; bool frozen;
bool delay_bets;
}; };
class betting_market_object : public graphene::db::abstract_object< betting_market_object > class betting_market_object : public graphene::db::abstract_object< betting_market_object >
@ -447,7 +449,7 @@ typedef generic_index<betting_market_position_object, betting_market_position_mu
} } // graphene::chain } } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description)(event_id)(rules_id)(asset_id)(frozen)(total_matched_bets_amount) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description)(event_id)(rules_id)(asset_id)(frozen)(delay_bets)(total_matched_bets_amount) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition) )
FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay) ) FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay) )

View file

@ -211,6 +211,7 @@
{ 1000000, 50000}, /* <= 100: 5.00 */ \ { 1000000, 50000}, /* <= 100: 5.00 */ \
{ 10000000, 100000} } /* <= 1000: 10.00 */ { 10000000, 100000} } /* <= 1000: 10.00 */
#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT) #define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT)
#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 10
#define TOURNAMENT_MIN_ROUND_DELAY 0 #define TOURNAMENT_MIN_ROUND_DELAY 0
#define TOURNAMENT_MAX_ROUND_DELAY 600 #define TOURNAMENT_MAX_ROUND_DELAY 600
#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0 #define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0

View file

@ -118,6 +118,8 @@ struct betting_market_group_update_operation : public base_operation
optional<bool> freeze; optional<bool> freeze;
optional<bool> delay_bets;
extensions_type extensions; extensions_type extensions;
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; } account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
@ -386,7 +388,7 @@ FC_REFLECT( graphene::chain::betting_market_group_create_operation,
FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::betting_market_group_update_operation, FC_REFLECT( graphene::chain::betting_market_group_update_operation,
(fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(freeze)(extensions) ) (fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(freeze)(delay_bets)(extensions) )
FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::betting_market_create_operation, FC_REFLECT( graphene::chain::betting_market_create_operation,

View file

@ -73,7 +73,8 @@ namespace graphene { namespace chain {
bet_multiplier_type min_bet_multiplier = GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER; bet_multiplier_type min_bet_multiplier = GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER;
bet_multiplier_type max_bet_multiplier = GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER; bet_multiplier_type max_bet_multiplier = GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER;
flat_map<bet_multiplier_type, bet_multiplier_type> permitted_betting_odds_increments = GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS; flat_map<bet_multiplier_type, bet_multiplier_type> permitted_betting_odds_increments = GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS;
//uint8_t witness_schedule_algorithm = GRAPHENE_WITNESS_SHUFFLED_ALGORITHM; ///< 0 shuffled, 1 scheduled uint16_t live_betting_delay_time = GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME; ///< delayed bets
//uint8_t witness_schedule_algorithm = GRAPHENE_WITNESS_SHUFFLED_ALGORITHM; ///< 0 shuffled, 1 scheduled
uint8_t witness_schedule_algorithm = GRAPHENE_WITNESS_SCHEDULED_ALGORITHM; ///< 0 shuffled, 1 scheduled uint8_t witness_schedule_algorithm = GRAPHENE_WITNESS_SCHEDULED_ALGORITHM; ///< 0 shuffled, 1 scheduled
/* rps tournament parameters constraints */ /* rps tournament parameters constraints */
uint32_t min_round_delay = TOURNAMENT_MIN_ROUND_DELAY; ///< miniaml delay between games uint32_t min_round_delay = TOURNAMENT_MIN_ROUND_DELAY; ///< miniaml delay between games
@ -131,6 +132,7 @@ FC_REFLECT( graphene::chain::chain_parameters,
(betting_rake_fee_percentage) (betting_rake_fee_percentage)
(permitted_betting_odds_increments) (permitted_betting_odds_increments)
(witness_schedule_algorithm) (witness_schedule_algorithm)
(live_betting_delay_time)
(min_round_delay) (min_round_delay)
(max_round_delay) (max_round_delay)
(min_time_per_commit_move) (min_time_per_commit_move)

View file

@ -783,12 +783,12 @@ BOOST_AUTO_TEST_CASE(betting_market_group_update_test)
const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}});
fc::optional<object_id_type> new_rule = new_betting_market_rules.id; fc::optional<object_id_type> new_rule = new_betting_market_rules.id;
fc::optional<bool> freeze; fc::optional<bool> empty_bool;
update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id, freeze); update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id, empty_bool, empty_bool);
update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id, freeze); update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id, empty_bool, empty_bool);
update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule, freeze); update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule, empty_bool, empty_bool);
update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule, freeze); update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule, empty_bool, empty_bool);
transfer(account_id_type(), bob_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000));
place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
@ -1038,10 +1038,18 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test )
BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market.id).as<std::string>()); BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market.id).as<std::string>());
BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market.id).as<std::string>()); BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market.id).as<std::string>());
betting_market_group_id_type moneyline_cilic_vs_federer_id = moneyline_cilic_vs_federer.id;
fc::optional<internationalized_string_type> empty_str;
fc::optional<object_id_type> empty_obj;
fc::optional<bool> empty_bool;
fc::optional<bool> true_bool = true;
update_betting_market_group(moneyline_cilic_vs_federer_id, empty_str,
empty_obj, empty_obj,
empty_bool, true_bool);
place_bet(alice_id, cilic_wins_final_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); place_bet(alice_id, cilic_wins_final_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
place_bet(bob_id, cilic_wins_final_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); place_bet(bob_id, cilic_wins_final_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION);
betting_market_group_id_type moneyline_cilic_vs_federer_id = moneyline_cilic_vs_federer.id;
auto cilic_wins_final_market_id = cilic_wins_final_market.id; auto cilic_wins_final_market_id = cilic_wins_final_market.id;
auto federer_wins_final_market_id = federer_wins_final_market.id; auto federer_wins_final_market_id = federer_wins_final_market.id;

View file

@ -1359,7 +1359,9 @@ void database_fixture::update_betting_market_group(betting_market_group_id_type
fc::optional<internationalized_string_type> description, fc::optional<internationalized_string_type> description,
fc::optional<object_id_type> event_id, fc::optional<object_id_type> event_id,
fc::optional<object_id_type> rules_id, fc::optional<object_id_type> rules_id,
fc::optional<bool> freeze) fc::optional<bool> freeze,
fc::optional<bool> delay_bets
)
{ try { { try {
betting_market_group_update_operation betting_market_group_update_op; betting_market_group_update_operation betting_market_group_update_op;
betting_market_group_update_op.betting_market_group_id = betting_market_group_id; betting_market_group_update_op.betting_market_group_id = betting_market_group_id;
@ -1367,8 +1369,9 @@ void database_fixture::update_betting_market_group(betting_market_group_id_type
betting_market_group_update_op.new_event_id = event_id; betting_market_group_update_op.new_event_id = event_id;
betting_market_group_update_op.new_rules_id = rules_id; betting_market_group_update_op.new_rules_id = rules_id;
betting_market_group_update_op.freeze = freeze; betting_market_group_update_op.freeze = freeze;
betting_market_group_update_op.delay_bets = delay_bets;
process_operation_by_witnesses(betting_market_group_update_op); process_operation_by_witnesses(betting_market_group_update_op);
} FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(description)(event_id)(rules_id)) } } FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(description)(event_id)(rules_id)(freeze)(delay_bets)) }
const betting_market_object& database_fixture::create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition) const betting_market_object& database_fixture::create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition)

View file

@ -311,7 +311,8 @@ struct database_fixture {
fc::optional<internationalized_string_type> description, fc::optional<internationalized_string_type> description,
fc::optional<object_id_type> event_id, fc::optional<object_id_type> event_id,
fc::optional<object_id_type> rules_id, fc::optional<object_id_type> rules_id,
fc::optional<bool> freeze); fc::optional<bool> freeze,
fc::optional<bool> delay_bets);
const betting_market_object& create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition); const betting_market_object& create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition);
void update_betting_market(betting_market_id_type betting_market_id, void update_betting_market(betting_market_id_type betting_market_id,