Remove competitor and market options objects from the blockchain

This commit is contained in:
Eric Frias 2017-07-06 11:57:45 -04:00
parent 21661eb12c
commit cd2940c8a8
26 changed files with 43 additions and 413 deletions

View file

@ -351,7 +351,6 @@ namespace graphene { namespace app {
break;
}
case sport_object_type:
case competitor_object_type:
case event_group_object_type:
case event_object_type:
case betting_market_group_object_type:

View file

@ -204,7 +204,6 @@ struct get_impacted_account_visitor
}
void operator()( const sport_create_operation& op ) {}
void operator()( const competitor_create_operation& op ) {}
void operator()( const event_group_create_operation& op ) {}
void operator()( const event_create_operation& op ) {}
void operator()( const betting_market_group_create_operation& op ) {}

View file

@ -93,8 +93,6 @@ add_library( graphene_chain
protocol/sport.cpp
sport_evaluator.cpp
protocol/competitor.cpp
competitor_evaluator.cpp
protocol/event_group.cpp
event_group_evaluator.cpp
protocol/event.cpp

View file

@ -46,8 +46,6 @@ void_result betting_market_group_create_evaluator::do_evaluate(const betting_mar
"event_id must refer to a event_id_type");
event_id = resolved_event_id;
FC_ASSERT( db().find_object(event_id), "Invalid event specified" );
// TODO: should we prevent creating multiple identical betting market groups for an event (same type & options)?
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
@ -56,7 +54,7 @@ object_id_type betting_market_group_create_evaluator::do_apply(const betting_mar
const betting_market_group_object& new_betting_market_group =
db().create<betting_market_group_object>( [&]( betting_market_group_object& betting_market_group_obj ) {
betting_market_group_obj.event_id = event_id;
betting_market_group_obj.options = op.options;
betting_market_group_obj.description = op.description;
});
return new_betting_market_group.id;
} FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -1,63 +0,0 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <graphene/chain/competitor_evaluator.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/sport_object.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/is_authorized_asset.hpp>
namespace graphene { namespace chain {
void_result competitor_create_evaluator::do_evaluate(const competitor_create_operation& op)
{ try {
FC_ASSERT(trx_state->_is_proposed_trx);
// the sport id in the operation can be a relative id. If it is,
// resolve it and verify that it is truly a sport
object_id_type resolved_id = op.sport_id;
if (is_relative(op.sport_id))
resolved_id = get_relative_id(op.sport_id);
FC_ASSERT(resolved_id.space() == sport_id_type::space_id &&
resolved_id.type() == sport_id_type::type_id, "sport_id must refer to a sport_id_type");
sport_id = resolved_id;
FC_ASSERT( db().find_object(sport_id), "Invalid sport specified" );
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
object_id_type competitor_create_evaluator::do_apply(const competitor_create_operation& op)
{ try {
const competitor_object& new_competitor =
db().create<competitor_object>( [&]( competitor_object& competitor_obj ) {
competitor_obj.name = op.name;
competitor_obj.sport_id = sport_id;
});
return new_competitor.id;
} FC_CAPTURE_AND_RETHROW( (op) ) }
} } // graphene::chain

View file

@ -49,7 +49,6 @@
#include <graphene/chain/sport_object.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
@ -70,7 +69,6 @@
#include <graphene/chain/witness_evaluator.hpp>
#include <graphene/chain/worker_evaluator.hpp>
#include <graphene/chain/sport_evaluator.hpp>
#include <graphene/chain/competitor_evaluator.hpp>
#include <graphene/chain/event_group_evaluator.hpp>
#include <graphene/chain/event_evaluator.hpp>
#include <graphene/chain/betting_market_evaluator.hpp>
@ -142,9 +140,6 @@ const uint8_t worker_object::type_id;
const uint8_t sport_object::space_id;
const uint8_t sport_object::type_id;
const uint8_t competitor_object::space_id;
const uint8_t competitor_object::type_id;
const uint8_t event_group_object::space_id;
const uint8_t event_group_object::type_id;
@ -212,7 +207,6 @@ void database::initialize_evaluators()
register_evaluator<blind_transfer_evaluator>();
register_evaluator<asset_claim_fees_evaluator>();
register_evaluator<sport_create_evaluator>();
register_evaluator<competitor_create_evaluator>();
register_evaluator<event_group_create_evaluator>();
register_evaluator<event_create_evaluator>();
register_evaluator<betting_market_group_create_evaluator>();
@ -248,7 +242,6 @@ void database::initialize_indexes()
add_index< primary_index<balance_index> >();
add_index< primary_index<blinded_balance_index> >();
add_index< primary_index<sport_object_index > >();
add_index< primary_index<competitor_object_index > >();
add_index< primary_index<event_group_object_index > >();
add_index< primary_index<event_object_index > >();
add_index< primary_index<betting_market_group_object_index > >();

View file

@ -186,7 +186,6 @@ struct get_impacted_account_visitor
_impacted.insert( op.account_id );
}
void operator()(const sport_create_operation&){}
void operator()(const competitor_create_operation&){}
void operator()(const event_group_create_operation&){}
void operator()(const event_create_operation&){}
void operator()(const betting_market_group_create_operation&){}

View file

@ -24,7 +24,6 @@
#include <graphene/chain/event_evaluator.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
@ -51,23 +50,6 @@ void_result event_create_evaluator::do_evaluate(const event_create_operation& op
event_group_id = resolved_event_group_id;
const event_group_object& event_group = event_group_id(d);
// Likewise for each competitor in the list
for (const object_id_type& raw_competitor_id : op.competitors)
{
object_id_type resolved_competitor_id = raw_competitor_id;
if (is_relative(raw_competitor_id))
resolved_competitor_id = get_relative_id(raw_competitor_id);
FC_ASSERT(resolved_competitor_id.space() == competitor_id_type::space_id &&
resolved_competitor_id.type() == competitor_id_type::type_id,
"competitor must refer to a competitor_id_type");
competitor_id_type competitor_id = resolved_competitor_id;
const competitor_object& competitor = competitor_id(d);
FC_ASSERT(competitor.sport_id == event_group.sport_id,
"competitor must compete in the same sport as the event they're competing in");
competitors.push_back(competitor_id);
}
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
@ -80,9 +62,6 @@ object_id_type event_create_evaluator::do_apply(const event_create_operation& op
event_obj.season = op.season;
event_obj.start_time = op.start_time;
event_obj.event_group_id = event_group_id;
event_obj.competitors = competitors;
// There should be exactly one score for each competitor (score is initially just an empty string).
event_obj.scores.resize( competitors.size() );
});
//increment number of active events in global betting statistics object
const global_betting_statistics_object& betting_statistics = global_betting_statistics_id_type()(d);
@ -99,8 +78,6 @@ void_result event_update_status_evaluator::do_evaluate(const event_update_status
database& d = db();
//check that the event to update exists
_event_to_update = &op.event_id(d);
//if scores are reported, there must be a score for every competitor
FC_ASSERT( op.scores.empty() || _event_to_update->scores.size() == op.scores.size() );
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -43,9 +43,9 @@ class betting_market_group_object : public graphene::db::abstract_object< bettin
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = betting_market_group_object_type;
event_id_type event_id;
internationalized_string_type description;
betting_market_options_type options;
event_id_type event_id;
};
class betting_market_object : public graphene::db::abstract_object< betting_market_object >
@ -56,6 +56,8 @@ class betting_market_object : public graphene::db::abstract_object< betting_mark
betting_market_group_id_type group_id;
internationalized_string_type description;
internationalized_string_type payout_condition;
asset_id_type asset_id;
@ -402,8 +404,8 @@ typedef multi_index_container<
typedef generic_index<betting_market_position_object, betting_market_position_multi_index_type> betting_market_position_index;
} } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (event_id)(options) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(payout_condition)(asset_id) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (event_id)(description) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition)(asset_id) )
FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(amount_reserved_for_fees)(back_or_lay) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) )

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class competitor_create_evaluator : public evaluator<competitor_create_evaluator>
{
public:
typedef competitor_create_operation operation_type;
void_result do_evaluate( const competitor_create_operation& o );
object_id_type do_apply( const competitor_create_operation& o );
private:
sport_id_type sport_id;
};
} } // graphene::chain

View file

@ -1,52 +0,0 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
namespace graphene { namespace chain {
class database;
class competitor_object : public graphene::db::abstract_object< competitor_object >
{
public:
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = competitor_object_type;
internationalized_string_type name;
sport_id_type sport_id;
};
typedef multi_index_container<
competitor_object,
indexed_by<
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > > > > competitor_object_multi_index_type;
typedef generic_index<competitor_object, competitor_object_multi_index_type> competitor_object_index;
} } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::competitor_object, (graphene::db::object), (name)(sport_id) )

View file

@ -38,7 +38,6 @@ namespace graphene { namespace chain {
object_id_type do_apply( const event_create_operation& o );
private:
event_group_id_type event_group_id;
vector<competitor_id_type> competitors;
};
class event_update_status_evaluator : public evaluator<event_update_status_evaluator>

View file

@ -45,8 +45,6 @@ class event_object : public graphene::db::abstract_object< event_object >
event_group_id_type event_group_id;
vector<competitor_id_type> competitors;
event_status status;
vector<string> scores;
};
@ -59,4 +57,4 @@ typedef multi_index_container<
typedef generic_index<event_object, event_object_multi_index_type> event_object_index;
} } // graphene::chain
FC_REFLECT_DERIVED( graphene::chain::event_object, (graphene::db::object), (name)(season)(start_time)(event_group_id)(status)(competitors)(scores) )
FC_REFLECT_DERIVED( graphene::chain::event_object, (graphene::db::object), (name)(season)(start_time)(event_group_id)(status)(scores) )

View file

@ -28,39 +28,23 @@
namespace graphene { namespace chain {
enum class betting_market_type {
moneyline,
spread,
over_under,
BETTING_MARKET_TYPE_COUNT
};
struct moneyline_market_options {};
struct spread_market_options {
int32_t margin;
};
struct over_under_market_options {
uint32_t score;
};
typedef static_variant<moneyline_market_options, spread_market_options, over_under_market_options> betting_market_options_type;
struct betting_market_group_create_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
/**
* A description of the betting market, like "Moneyline", "Over/Under 180",
* used for display
*/
internationalized_string_type description;
/**
* This can be a event_id_type, or a
* relative object id that resolves to a event_id_type
*/
object_id_type event_id;
betting_market_options_type options;
extensions_type extensions;
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
@ -262,16 +246,9 @@ struct bet_canceled_operation : public base_operation
} }
FC_REFLECT_ENUM( graphene::chain::betting_market_type, (moneyline)(spread)(over_under)(BETTING_MARKET_TYPE_COUNT) )
FC_REFLECT( graphene::chain::moneyline_market_options, )
FC_REFLECT( graphene::chain::spread_market_options, (margin) )
FC_REFLECT( graphene::chain::over_under_market_options, (score) )
FC_REFLECT_TYPENAME( graphene::chain::betting_market_options_type )
FC_REFLECT( graphene::chain::betting_market_group_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::betting_market_group_create_operation,
(fee)(event_id)(options)(extensions) )
(fee)(description)(event_id)(extensions) )
FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::betting_market_create_operation,

View file

@ -1,57 +0,0 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/base.hpp>
namespace graphene { namespace chain {
struct competitor_create_operation : public base_operation
{
struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; };
asset fee;
/**
* The name of the competitor
*/
internationalized_string_type name;
/**
* The sport the competitor, um, competes in. This can be a sport_id_type, or a
* relative object id that resolves to a sport_id_type
*/
object_id_type sport_id;
extensions_type extensions;
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
void validate()const;
};
} }
FC_REFLECT( graphene::chain::competitor_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::competitor_create_operation,
(fee)(name)(sport_id)(extensions) )

View file

@ -48,12 +48,6 @@ struct event_create_operation : public base_operation
*/
object_id_type event_group_id;
/**
* Each entry in this vector can be a competitor_id_type, or a relative object id that
* resolves to a competitor_id_type
*/
vector<object_id_type> competitors;
extensions_type extensions;
account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; }
@ -96,7 +90,7 @@ struct event_update_status_operation : public base_operation
event_status status;
/*
* scores for each ompetitor stored in same order as competitors in event_object
* scores for each competitor stored in same order as competitors in event_object
*/
vector<string> scores;
@ -110,7 +104,7 @@ struct event_update_status_operation : public base_operation
FC_REFLECT( graphene::chain::event_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::event_create_operation,
(fee)(name)(season)(start_time)(event_group_id)(competitors)(extensions) )
(fee)(name)(season)(start_time)(event_group_id)(extensions) )
FC_REFLECT_ENUM( graphene::chain::event_status, (upcoming)(in_progress)(completed)(canceled)(STATUS_COUNT) )
FC_REFLECT( graphene::chain::event_update_status_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::event_update_status_operation,

View file

@ -39,7 +39,6 @@
#include <graphene/chain/protocol/witness.hpp>
#include <graphene/chain/protocol/worker.hpp>
#include <graphene/chain/protocol/sport.hpp>
#include <graphene/chain/protocol/competitor.hpp>
#include <graphene/chain/protocol/event_group.hpp>
#include <graphene/chain/protocol/event.hpp>
#include <graphene/chain/protocol/betting_market.hpp>
@ -98,7 +97,6 @@ namespace graphene { namespace chain {
asset_claim_fees_operation,
fba_distribute_operation, // VIRTUAL
sport_create_operation,
competitor_create_operation,
event_group_create_operation,
event_create_operation,
betting_market_group_create_operation,

View file

@ -135,7 +135,6 @@ namespace graphene { namespace chain {
worker_object_type,
balance_object_type,
sport_object_type,
competitor_object_type,
event_group_object_type,
event_object_type,
betting_market_group_object_type,
@ -185,7 +184,6 @@ namespace graphene { namespace chain {
class balance_object;
class blinded_balance_object;
class sport_object;
class competitor_object;
class event_group_object;
class event_object;
class betting_market_group_object;
@ -207,7 +205,6 @@ namespace graphene { namespace chain {
typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type;
typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type;
typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type;
typedef object_id< protocol_ids, competitor_object_type, competitor_object> competitor_id_type;
typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type;
typedef object_id< protocol_ids, event_object_type, event_object> event_id_type;
typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type;
@ -372,7 +369,6 @@ FC_REFLECT_ENUM( graphene::chain::object_type,
(worker_object_type)
(balance_object_type)
(sport_object_type)
(competitor_object_type)
(event_group_object_type)
(event_object_type)
(betting_market_group_object_type)
@ -419,7 +415,6 @@ FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type )
FC_REFLECT_TYPENAME( graphene::chain::worker_id_type )
FC_REFLECT_TYPENAME( graphene::chain::balance_id_type )
FC_REFLECT_TYPENAME( graphene::chain::sport_id_type )
FC_REFLECT_TYPENAME( graphene::chain::competitor_id_type )
FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type )
FC_REFLECT_TYPENAME( graphene::chain::event_id_type )
FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type )

View file

@ -68,8 +68,6 @@ class persistent_event_object : public graphene::db::abstract_object<event_objec
event_group_id_type event_group_id;
vector<competitor_id_type> competitors;
event_status status;
vector<string> scores;
};
@ -84,7 +82,7 @@ typedef multi_index_container<
typedef generic_index<persistent_event_object, persistent_event_object_multi_index_type> persistent_event_object_index;
#if 0 // we no longer have competitors, just leaving this here as an example of how to do a secondary index
class events_by_competitor_index : public secondary_index
{
public:
@ -121,7 +119,7 @@ void events_by_competitor_index::object_modified( const object& after )
{
object_inserted(after);
}
#endif
class bookie_plugin_impl
{
@ -193,7 +191,6 @@ void bookie_plugin_impl::on_objects_changed(const vector<object_id_type>& change
saved_event_obj.season = new_event_obj->season;
saved_event_obj.start_time = new_event_obj->start_time;;
saved_event_obj.event_group_id = new_event_obj->event_group_id;
saved_event_obj.competitors = new_event_obj->competitors;
saved_event_obj.status = new_event_obj->status;
saved_event_obj.scores = new_event_obj->scores;
});
@ -207,7 +204,6 @@ void bookie_plugin_impl::on_objects_changed(const vector<object_id_type>& change
saved_event_obj.season = new_event_obj->season;
saved_event_obj.start_time = new_event_obj->start_time;;
saved_event_obj.event_group_id = new_event_obj->event_group_id;
saved_event_obj.competitors = new_event_obj->competitors;
saved_event_obj.status = new_event_obj->status;
saved_event_obj.scores = new_event_obj->scores;
});
@ -323,7 +319,7 @@ void bookie_plugin::plugin_initialize(const boost::program_options::variables_ma
database().applied_block.connect( [&]( const signed_block& b){ my->on_block_applied(b); } );
database().changed_objects.connect([&](const vector<object_id_type>& changed_object_ids, const fc::flat_set<graphene::chain::account_id_type>& impacted_accounts){ my->on_objects_changed(changed_object_ids); });
auto event_index = database().add_index<primary_index<detail::persistent_event_object_index> >();
event_index->add_secondary_index<detail::events_by_competitor_index>();
//event_index->add_secondary_index<detail::events_by_competitor_index>();
LOAD_VALUE_SET(options, "tracked-accounts", my->_tracked_accounts, graphene::chain::account_id_type);
}
@ -338,5 +334,5 @@ flat_set<account_id_type> bookie_plugin::tracked_accounts() const
}
} }
FC_REFLECT_DERIVED( graphene::bookie::detail::persistent_event_object, (graphene::db::object), (event_object_id)(name)(season)(start_time)(event_group_id)(status)(competitors)(scores) )
FC_REFLECT_DERIVED( graphene::bookie::detail::persistent_event_object, (graphene::db::object), (event_object_id)(name)(season)(start_time)(event_group_id)(status)(scores) )

View file

@ -62,7 +62,7 @@ struct static_variant_map_visitor
template< typename T >
result_type operator()( const T& dummy )
{
assert( which == m.which_to_name.size() );
assert( which == static_cast<int>(m.which_to_name.size()) );
std::string name = clean_name( fc::get_typename<T>::name() );
m.name_to_which[ name ] = which;
m.which_to_name.push_back( name );

View file

@ -1513,13 +1513,6 @@ class wallet_api
internationalized_string_type name,
bool broadcast = false);
signed_transaction propose_create_competitor(
const string& proposing_account,
fc::time_point_sec expiration_time,
internationalized_string_type name,
sport_id_type sport_id,
bool broadcast = false);
signed_transaction propose_create_event_group(
const string& proposing_account,
fc::time_point_sec expiration_time,
@ -1532,14 +1525,13 @@ class wallet_api
fc::time_point_sec expiration_time,
internationalized_string_type season,
event_group_id_type event_group_id,
vector<competitor_id_type> competitors,
bool broadcast = false);
signed_transaction propose_create_betting_market_group(
const string& proposing_account,
fc::time_point_sec expiration_time,
internationalized_string_type description,
event_id_type event_id,
betting_market_options_type options,
bool broadcast = false);
signed_transaction propose_create_betting_market(
@ -1773,7 +1765,6 @@ FC_API( graphene::wallet::wallet_api,
(list_betting_markets)
(get_global_betting_statistics)
(propose_create_sport)
(propose_create_competitor)
(propose_create_event_group)
(propose_create_event)
(propose_create_betting_market_group)

View file

@ -4400,35 +4400,6 @@ signed_transaction wallet_api::propose_create_sport(
return my->sign_transaction(tx, broadcast);
}
signed_transaction wallet_api::propose_create_competitor(
const string& proposing_account,
fc::time_point_sec expiration_time,
internationalized_string_type name,
sport_id_type sport_id,
bool broadcast /*= false*/)
{
FC_ASSERT( !is_locked() );
const chain_parameters& current_params = get_global_properties().parameters;
competitor_create_operation competitor_create_op;
competitor_create_op.name = name;
competitor_create_op.sport_id = sport_id;
proposal_create_operation prop_op;
prop_op.expiration_time = expiration_time;
prop_op.review_period_seconds = current_params.committee_proposal_review_period;
prop_op.fee_paying_account = get_account(proposing_account).id;
prop_op.proposed_ops.emplace_back( competitor_create_op );
current_params.current_fees->set_fee( prop_op.proposed_ops.back().op );
signed_transaction tx;
tx.operations.push_back(prop_op);
my->set_operation_fees(tx, current_params.current_fees);
tx.validate();
return my->sign_transaction(tx, broadcast);
}
signed_transaction wallet_api::propose_create_event_group(
const string& proposing_account,
fc::time_point_sec expiration_time,
@ -4463,7 +4434,6 @@ signed_transaction wallet_api::propose_create_event(
fc::time_point_sec expiration_time,
internationalized_string_type season,
event_group_id_type event_group_id,
vector<competitor_id_type> competitors,
bool broadcast /*= false*/)
{
FC_ASSERT( !is_locked() );
@ -4472,7 +4442,6 @@ signed_transaction wallet_api::propose_create_event(
event_create_operation event_create_op;
event_create_op.season = season;
event_create_op.event_group_id = event_group_id;
event_create_op.competitors.assign(competitors.begin(), competitors.end());
proposal_create_operation prop_op;
prop_op.expiration_time = expiration_time;
@ -4492,16 +4461,16 @@ signed_transaction wallet_api::propose_create_event(
signed_transaction wallet_api::propose_create_betting_market_group(
const string& proposing_account,
fc::time_point_sec expiration_time,
internationalized_string_type description,
event_id_type event_id,
betting_market_options_type options,
bool broadcast /*= false*/)
{
FC_ASSERT( !is_locked() );
const chain_parameters& current_params = get_global_properties().parameters;
betting_market_group_create_operation betting_market_group_create_op;
betting_market_group_create_op.description = description;
betting_market_group_create_op.event_id = event_id;
betting_market_group_create_op.options = options;
proposal_create_operation prop_op;
prop_op.expiration_time = expiration_time;

View file

@ -37,7 +37,6 @@
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/sport_object.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/betting_market_object.hpp>

View file

@ -34,7 +34,6 @@
#include <graphene/chain/sport_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
@ -48,15 +47,12 @@ BOOST_FIXTURE_TEST_SUITE( betting_tests, database_fixture )
#define CREATE_ICE_HOCKEY_BETTING_MARKET() \
const sport_object& ice_hockey = create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \
const competitor_object& capitals = create_competitor({{"en", "Washington Capitals"}, {"zh_Hans", "華盛頓首都隊"}, {"ja", "ワシントン・キャピタルズ"}}, ice_hockey.id); \
const competitor_object& blackhawks = create_competitor({{"en", "Chicago Blackhawks"}, {"zh_Hans", "芝加哥黑鷹"}, {"ja", "シカゴ・ブラックホークス"}}, ice_hockey.id); \
const event_group_object& nhl = create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \
const event_object& capitals_vs_blackhawks = create_event({{"en", "2016-17"}}, nhl.id, {capitals.id, blackhawks.id}); \
const betting_market_group_object& moneyline_betting_markets = create_betting_market_group(capitals_vs_blackhawks.id, moneyline_market_options{}); \
const event_object& capitals_vs_blackhawks = create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \
const betting_market_group_object& moneyline_betting_markets = create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id); \
const betting_market_object& capitals_win_market = create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}, asset_id_type()); \
const betting_market_object& blackhawks_win_market = create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}, asset_id_type());
#if 0
BOOST_AUTO_TEST_CASE(generate_block)
{
@ -142,49 +138,33 @@ BOOST_AUTO_TEST_CASE( chained_market_create_test )
sport_create_op.name.insert(internationalized_string_type::value_type("ja", "アイスホッケー"));
// operation 1
competitor_create_operation competitor1_create_op;
competitor1_create_op.sport_id = object_id_type(relative_protocol_ids, 0, 0);
competitor1_create_op.name.insert(internationalized_string_type::value_type("en", "Washington Capitals"));
competitor1_create_op.name.insert(internationalized_string_type::value_type("zh_Hans", "華盛頓首都隊"));
competitor1_create_op.name.insert(internationalized_string_type::value_type("ja", "ワシントン・キャピタルズ"));
//BOOST_TEST_MESSAGE("Just constructed competitor_create_operation " << fc::json::to_pretty_string(competitor1_create_op));
// operation 2
competitor_create_operation competitor2_create_op;
competitor2_create_op.sport_id = object_id_type(relative_protocol_ids, 0, 0);
competitor2_create_op.name.insert(internationalized_string_type::value_type("en", "Chicago Blackhawks"));
competitor2_create_op.name.insert(internationalized_string_type::value_type("zh_Hans", "芝加哥黑鷹"));
competitor2_create_op.name.insert(internationalized_string_type::value_type("ja", "シカゴ・ブラックホークス"));
// operation 3
event_group_create_operation event_group_create_op;
event_group_create_op.name.insert(internationalized_string_type::value_type("en", "NHL"));
event_group_create_op.name.insert(internationalized_string_type::value_type("zh_Hans", "國家冰球聯盟"));
event_group_create_op.name.insert(internationalized_string_type::value_type("ja", "ナショナルホッケーリーグ"));
event_group_create_op.sport_id = object_id_type(relative_protocol_ids, 0, 0);
// operation 4
// operation 2
// leave name and start time blank
event_create_operation event_create_op;
event_create_op.name = {{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}};
event_create_op.season.insert(internationalized_string_type::value_type("en", "2016-17"));
event_create_op.event_group_id = object_id_type(relative_protocol_ids, 0, 3);
event_create_op.competitors.push_back(object_id_type(relative_protocol_ids, 0, 1));
event_create_op.competitors.push_back(object_id_type(relative_protocol_ids, 0, 2));
// operation 5
// operation 3
betting_market_group_create_operation betting_market_group_create_op;
betting_market_group_create_op.event_id = object_id_type(relative_protocol_ids, 0, 4);
betting_market_group_create_op.options = moneyline_market_options{};
betting_market_group_create_op.description = {{"en", "Moneyline"}};
betting_market_group_create_op.event_id = object_id_type(relative_protocol_ids, 0, 2);
// operation 6
// operation 4
betting_market_create_operation caps_win_betting_market_create_op;
caps_win_betting_market_create_op.group_id = object_id_type(relative_protocol_ids, 0, 5);
caps_win_betting_market_create_op.group_id = object_id_type(relative_protocol_ids, 0, 3);
caps_win_betting_market_create_op.payout_condition.insert(internationalized_string_type::value_type("en", "Washington Capitals win"));
caps_win_betting_market_create_op.asset_id = asset_id_type();
// operation 7
// operation 5
betting_market_create_operation blackhawks_win_betting_market_create_op;
blackhawks_win_betting_market_create_op.group_id = object_id_type(relative_protocol_ids, 0, 5);
blackhawks_win_betting_market_create_op.group_id = object_id_type(relative_protocol_ids, 0, 4);
blackhawks_win_betting_market_create_op.payout_condition.insert(internationalized_string_type::value_type("en", "Chicago Blackhawks win"));
blackhawks_win_betting_market_create_op.asset_id = asset_id_type();
@ -192,8 +172,6 @@ BOOST_AUTO_TEST_CASE( chained_market_create_test )
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = (*active_witnesses.begin())(db).witness_account;
proposal_op.proposed_ops.emplace_back(sport_create_op);
proposal_op.proposed_ops.emplace_back(competitor1_create_op);
proposal_op.proposed_ops.emplace_back(competitor2_create_op);
proposal_op.proposed_ops.emplace_back(event_group_create_op);
proposal_op.proposed_ops.emplace_back(event_create_op);
proposal_op.proposed_ops.emplace_back(betting_market_group_create_op);
@ -233,10 +211,8 @@ BOOST_AUTO_TEST_CASE( chained_market_create_test )
db.push_transaction(tx, ~0);
if (db.get_index_type<sport_object_index>().indices().size() == 1)
{
BOOST_REQUIRE_EQUAL(db.get_index_type<competitor_object_index>().indices().size(), 2);
//BOOST_TEST_MESSAGE("The sport creation operation has been approved, new sport object on the blockchain is " << fc::json::to_pretty_string(*db.get_index_type<sport_object_index>().indices().rbegin()));
//BOOST_TEST_MESSAGE("The first competitor object on the blockchain is " << fc::json::to_pretty_string(*db.get_index_type<competitor_object_index>().indices().begin()));
break;
break;
}
}
}

View file

@ -40,7 +40,6 @@
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/sport_object.hpp>
#include <graphene/chain/competitor_object.hpp>
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
@ -1130,16 +1129,6 @@ const sport_object& database_fixture::create_sport(internationalized_string_type
return *sport_index.rbegin();
} FC_CAPTURE_AND_RETHROW( (name) ) }
const competitor_object& database_fixture::create_competitor(internationalized_string_type name, sport_id_type sport_id)
{ try {
competitor_create_operation competitor_create_op;
competitor_create_op.name = name;
competitor_create_op.sport_id = sport_id;
process_operation_by_witnesses(competitor_create_op);
const auto& competitor_index = db.get_index_type<competitor_object_index>().indices().get<by_id>();
return *competitor_index.rbegin();
} FC_CAPTURE_AND_RETHROW( (name) ) }
const event_group_object& database_fixture::create_event_group(internationalized_string_type name, sport_id_type sport_id)
{ try {
event_group_create_operation event_group_create_op;
@ -1150,22 +1139,22 @@ const event_group_object& database_fixture::create_event_group(internationalized
return *event_group_index.rbegin();
} FC_CAPTURE_AND_RETHROW( (name) ) }
const event_object& database_fixture::create_event(internationalized_string_type season, event_group_id_type event_group_id, vector<competitor_id_type> competitors)
const event_object& database_fixture::create_event(internationalized_string_type name, internationalized_string_type season, event_group_id_type event_group_id)
{ try {
event_create_operation event_create_op;
event_create_op.name = name;
event_create_op.season = season;
event_create_op.event_group_id = event_group_id;
event_create_op.competitors.assign(competitors.begin(), competitors.end());
process_operation_by_witnesses(event_create_op);
const auto& event_index = db.get_index_type<event_object_index>().indices().get<by_id>();
return *event_index.rbegin();
} FC_CAPTURE_AND_RETHROW( (event_group_id) ) }
const betting_market_group_object& database_fixture::create_betting_market_group(event_id_type event_id, betting_market_options_type options)
const betting_market_group_object& database_fixture::create_betting_market_group(internationalized_string_type description, event_id_type event_id)
{ try {
betting_market_group_create_operation betting_market_group_create_op;
betting_market_group_create_op.description = description;
betting_market_group_create_op.event_id = event_id;
betting_market_group_create_op.options = options;
process_operation_by_witnesses(betting_market_group_create_op);
const auto& betting_market_group_index = db.get_index_type<betting_market_group_object_index>().indices().get<by_id>();
return *betting_market_group_index.rbegin();

View file

@ -283,10 +283,9 @@ struct database_fixture {
vector< operation_history_object > get_operation_history( account_id_type account_id )const;
void process_operation_by_witnesses(operation op);
const sport_object& create_sport(internationalized_string_type name);
const competitor_object& create_competitor(internationalized_string_type name, sport_id_type sport_id);
const event_group_object& create_event_group(internationalized_string_type name, sport_id_type sport_id);
const event_object& create_event(internationalized_string_type season, event_group_id_type event_group_id, vector<competitor_id_type> competitors);
const betting_market_group_object& create_betting_market_group(event_id_type event_id, betting_market_options_type options);
const event_object& create_event(internationalized_string_type name, internationalized_string_type season, event_group_id_type event_group_id);
const betting_market_group_object& create_betting_market_group(internationalized_string_type description, event_id_type event_id);
const betting_market_object& create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition, asset_id_type asset_id);
void place_bet(account_id_type bettor_id, betting_market_id_type betting_market_id, bet_type back_or_lay, asset amount_to_bet, bet_multiplier_type backer_multiplier, share_type amount_reserved_for_fees);