cancel all the betting markets of a canceled event
This commit is contained in:
parent
e74a505622
commit
e609764df3
3 changed files with 26 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/betting_market_object.hpp>
|
||||
#include <graphene/chain/event_object.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
|
|
@ -32,6 +33,26 @@ void database::cancel_all_unmatched_bets_on_betting_market(const betting_market_
|
|||
}
|
||||
}
|
||||
|
||||
void database::cancel_all_betting_markets_for_event(const event_object& event_obj)
|
||||
{
|
||||
//for each betting market group of event
|
||||
auto& betting_market_group_index = get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
|
||||
auto betting_market_group_itr = betting_market_group_index.lower_bound(event_obj.id);
|
||||
while (betting_market_group_itr != betting_market_group_index.end() &&
|
||||
betting_market_group_itr->event_id == event_obj.id)
|
||||
{
|
||||
//for each betting market in the betting market group
|
||||
auto& betting_market_index = get_index_type<betting_market_object_index>().indices().get<by_betting_market_group_id>();
|
||||
auto betting_market_itr = betting_market_index.lower_bound(betting_market_group_itr->id);
|
||||
while (betting_market_itr != betting_market_index.end() &&
|
||||
betting_market_itr->group_id == betting_market_group_itr->id)
|
||||
{
|
||||
resolve_betting_market(*betting_market_itr, betting_market_resolution_type::cancel);
|
||||
++betting_market_itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void database::resolve_betting_market(const betting_market_object& betting_market,
|
||||
betting_market_resolution_type resolution)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,7 +108,10 @@ void_result event_update_status_evaluator::do_evaluate(const event_update_status
|
|||
void_result event_update_status_evaluator::do_apply(const event_update_status_operation& op)
|
||||
{ try {
|
||||
database& d = db();
|
||||
//TODO: cancel_all_betting_markets_for_event() //should we put this in event or just here in evaluator?
|
||||
//if event is canceled, first cancel all associated betting markets
|
||||
if (op.status == event_status::canceled)
|
||||
d.cancel_all_betting_markets_for_event(*_event_to_update);
|
||||
//update event
|
||||
d.modify( *_event_to_update, [&]( event_object& event_obj) {
|
||||
event_obj.scores = op.scores;
|
||||
event_obj.status = op.status;
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ namespace graphene { namespace chain {
|
|||
/// @{ @group Betting Market Helpers
|
||||
void cancel_bet(const bet_object& bet, bool create_virtual_op = true);
|
||||
void cancel_all_unmatched_bets_on_betting_market(const betting_market_object& betting_market);
|
||||
void cancel_all_betting_markets_for_event(const event_object&);
|
||||
void resolve_betting_market(const betting_market_object& betting_market,
|
||||
betting_market_resolution_type resolution);
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue