Scorum
create_game_evaluator.cpp
Go to the documentation of this file.
6 
9 
10 #include <scorum/utils/collect_range_adaptor.hpp>
11 
12 namespace scorum {
13 namespace chain {
14 create_game_evaluator::create_game_evaluator(data_service_factory_i& services,
17  : evaluator_impl<data_service_factory_i, create_game_evaluator>(services)
18  , _account_service(services.account_service())
19  , _dprops_service(services.dynamic_global_property_service())
20  , _betting_service(betting_service)
21  , _game_svc(services.game_service())
22  , _uuid_hist_dba(uuid_hist_dba)
23 {
24 }
25 
27 {
28  FC_ASSERT(op.start_time > _dprops_service.head_block_time(), "Game should start after head block time");
29  FC_ASSERT(!_uuid_hist_dba.is_exists_by<by_uuid>(op.uuid), "Game with uuid '${g}' already exists", ("g", op.uuid));
30 
31  _account_service.check_account_existence(op.moderator);
32  FC_ASSERT(_betting_service.is_betting_moderator(op.moderator), "User ${u} isn't a betting moderator",
33  ("u", op.moderator));
34 
35  FC_ASSERT(op.auto_resolve_delay_sec > 0, "Auto resolve delay is not set.");
36 
37  fc::flat_set<market_type> markets(op.markets.begin(), op.markets.end());
38 
39  _game_svc.create_game(op.uuid, op.json_metadata, op.start_time, op.auto_resolve_delay_sec, op.game, markets);
40 }
41 }
42 }
create_game_evaluator(data_service_factory_i &, betting_service_i &, dba::db_accessor< game_uuid_history_object > &)
void do_apply(const operation_type &op)
Definition: asset.cpp:15
virtual void check_account_existence(const account_name_type &, const optional< const char * > &context_type_name=optional< const char * >()) const =0
virtual bool is_betting_moderator(const account_name_type &account_name) const =0
virtual fc::time_point_sec head_block_time() const =0
virtual const game_object & create_game(const uuid_type &uuid, const std::string &json_metadata, fc::time_point_sec start, uint32_t auto_resolve_delay_sec, const game_type &game, const fc::flat_set< market_type > &markets)=0
This operation creates game object.
game_type game
game type (soccer, hockey, etc ...)
std::vector< market_type > markets
list of markets
uuid_type uuid
Universal Unique Identifier which is unique for each game.
account_name_type moderator
moderator account name
time_point_sec start_time
game start time
uint32_t auto_resolve_delay_sec
delay starting from start after which all bets are automatically resolved if game results weren't pro...