From cd2940c8a8b20baeb7ca64479855ab731554df15 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Thu, 6 Jul 2017 11:57:45 -0400 Subject: [PATCH] Remove competitor and market options objects from the blockchain --- libraries/app/api.cpp | 1 - libraries/app/impacted.cpp | 1 - libraries/chain/CMakeLists.txt | 2 - libraries/chain/betting_market_evaluator.cpp | 4 +- libraries/chain/competitor_evaluator.cpp | 63 ------------------- libraries/chain/db_init.cpp | 7 --- libraries/chain/db_notify.cpp | 1 - libraries/chain/event_evaluator.cpp | 23 ------- .../graphene/chain/betting_market_object.hpp | 10 +-- .../graphene/chain/competitor_evaluator.hpp | 43 ------------- .../graphene/chain/competitor_object.hpp | 52 --------------- .../graphene/chain/event_evaluator.hpp | 1 - .../include/graphene/chain/event_object.hpp | 4 +- .../chain/protocol/betting_market.hpp | 37 +++-------- .../graphene/chain/protocol/competitor.hpp | 57 ----------------- .../include/graphene/chain/protocol/event.hpp | 10 +-- .../graphene/chain/protocol/operations.hpp | 2 - .../include/graphene/chain/protocol/types.hpp | 5 -- libraries/plugins/bookie/bookie_plugin.cpp | 12 ++-- .../include/graphene/wallet/reflect_util.hpp | 2 +- .../wallet/include/graphene/wallet/wallet.hpp | 11 +--- libraries/wallet/wallet.cpp | 35 +---------- programs/js_operation_serializer/main.cpp | 1 - tests/betting/betting_tests.cpp | 48 ++++---------- tests/common/database_fixture.cpp | 19 ++---- tests/common/database_fixture.hpp | 5 +- 26 files changed, 43 insertions(+), 413 deletions(-) delete mode 100644 libraries/chain/competitor_evaluator.cpp delete mode 100644 libraries/chain/include/graphene/chain/competitor_evaluator.hpp delete mode 100644 libraries/chain/include/graphene/chain/competitor_object.hpp delete mode 100644 libraries/chain/include/graphene/chain/protocol/competitor.hpp diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 34e36cf3..a9b42fd8 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -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: diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index 3038c8f7..e2a22937 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -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 ) {} diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 90846a9b..207a8d09 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -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 diff --git a/libraries/chain/betting_market_evaluator.cpp b/libraries/chain/betting_market_evaluator.cpp index 98173cfe..fe19f7b4 100644 --- a/libraries/chain/betting_market_evaluator.cpp +++ b/libraries/chain/betting_market_evaluator.cpp @@ -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_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) ) } diff --git a/libraries/chain/competitor_evaluator.cpp b/libraries/chain/competitor_evaluator.cpp deleted file mode 100644 index 5156d95d..00000000 --- a/libraries/chain/competitor_evaluator.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include - -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_obj ) { - competitor_obj.name = op.name; - competitor_obj.sport_id = sport_id; - }); - return new_competitor.id; -} FC_CAPTURE_AND_RETHROW( (op) ) } - -} } // graphene::chain diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index e37578aa..a87d4f45 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -49,7 +49,6 @@ #include -#include #include #include #include @@ -70,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -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(); register_evaluator(); register_evaluator(); - register_evaluator(); register_evaluator(); register_evaluator(); register_evaluator(); @@ -248,7 +242,6 @@ void database::initialize_indexes() add_index< primary_index >(); add_index< primary_index >(); add_index< primary_index >(); - add_index< primary_index >(); add_index< primary_index >(); add_index< primary_index >(); add_index< primary_index >(); diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index a03c7c7b..dd0354ca 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -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&){} diff --git a/libraries/chain/event_evaluator.cpp b/libraries/chain/event_evaluator.cpp index 7c2034b4..a57fc793 100644 --- a/libraries/chain/event_evaluator.cpp +++ b/libraries/chain/event_evaluator.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -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) ) } diff --git a/libraries/chain/include/graphene/chain/betting_market_object.hpp b/libraries/chain/include/graphene/chain/betting_market_object.hpp index d234ac17..77bbc680 100644 --- a/libraries/chain/include/graphene/chain/betting_market_object.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_object.hpp @@ -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_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) ) diff --git a/libraries/chain/include/graphene/chain/competitor_evaluator.hpp b/libraries/chain/include/graphene/chain/competitor_evaluator.hpp deleted file mode 100644 index b8e977c7..00000000 --- a/libraries/chain/include/graphene/chain/competitor_evaluator.hpp +++ /dev/null @@ -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 -#include -#include - -namespace graphene { namespace chain { - - class competitor_create_evaluator : public 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 diff --git a/libraries/chain/include/graphene/chain/competitor_object.hpp b/libraries/chain/include/graphene/chain/competitor_object.hpp deleted file mode 100644 index 8ca495f0..00000000 --- a/libraries/chain/include/graphene/chain/competitor_object.hpp +++ /dev/null @@ -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 -#include -#include - -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, member< object, object_id_type, &object::id > > > > competitor_object_multi_index_type; - -typedef generic_index competitor_object_index; -} } // graphene::chain - -FC_REFLECT_DERIVED( graphene::chain::competitor_object, (graphene::db::object), (name)(sport_id) ) diff --git a/libraries/chain/include/graphene/chain/event_evaluator.hpp b/libraries/chain/include/graphene/chain/event_evaluator.hpp index 656b5d00..a4a7af59 100644 --- a/libraries/chain/include/graphene/chain/event_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/event_evaluator.hpp @@ -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 competitors; }; class event_update_status_evaluator : public evaluator diff --git a/libraries/chain/include/graphene/chain/event_object.hpp b/libraries/chain/include/graphene/chain/event_object.hpp index 74673e5a..3a69b974 100644 --- a/libraries/chain/include/graphene/chain/event_object.hpp +++ b/libraries/chain/include/graphene/chain/event_object.hpp @@ -45,8 +45,6 @@ class event_object : public graphene::db::abstract_object< event_object > event_group_id_type event_group_id; - vector competitors; - event_status status; vector scores; }; @@ -59,4 +57,4 @@ typedef multi_index_container< typedef generic_index 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp index 5bedf242..e35c1bd1 100644 --- a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp +++ b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp @@ -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 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, diff --git a/libraries/chain/include/graphene/chain/protocol/competitor.hpp b/libraries/chain/include/graphene/chain/protocol/competitor.hpp deleted file mode 100644 index 2da18c07..00000000 --- a/libraries/chain/include/graphene/chain/protocol/competitor.hpp +++ /dev/null @@ -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 -#include - -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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/event.hpp b/libraries/chain/include/graphene/chain/protocol/event.hpp index b02135e0..f736eefc 100644 --- a/libraries/chain/include/graphene/chain/protocol/event.hpp +++ b/libraries/chain/include/graphene/chain/protocol/event.hpp @@ -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 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 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, diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/chain/include/graphene/chain/protocol/operations.hpp index 8ba64fb7..f2cc8edc 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/chain/include/graphene/chain/protocol/operations.hpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -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, diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index b4d42d47..39327356 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -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 ) diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index a32b9656..0779e963 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -68,8 +68,6 @@ class persistent_event_object : public graphene::db::abstract_object competitors; - event_status status; vector scores; }; @@ -84,7 +82,7 @@ typedef multi_index_container< typedef generic_index 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& 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& 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& changed_object_ids, const fc::flat_set& impacted_accounts){ my->on_objects_changed(changed_object_ids); }); auto event_index = database().add_index >(); - event_index->add_secondary_index(); + //event_index->add_secondary_index(); LOAD_VALUE_SET(options, "tracked-accounts", my->_tracked_accounts, graphene::chain::account_id_type); } @@ -338,5 +334,5 @@ flat_set 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) ) diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 497303c5..7c5ea654 100644 --- a/libraries/wallet/include/graphene/wallet/reflect_util.hpp +++ b/libraries/wallet/include/graphene/wallet/reflect_util.hpp @@ -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(m.which_to_name.size()) ); std::string name = clean_name( fc::get_typename::name() ); m.name_to_which[ name ] = which; m.which_to_name.push_back( name ); diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 13d29f9f..72b2067c 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -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 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) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 0681c649..c09b8a8b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -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 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; diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index f81e907e..74eb573a 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 7ca41dac..6ab92ba1 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -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().indices().size() == 1) { - BOOST_REQUIRE_EQUAL(db.get_index_type().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().indices().rbegin())); - //BOOST_TEST_MESSAGE("The first competitor object on the blockchain is " << fc::json::to_pretty_string(*db.get_index_type().indices().begin())); - break; + break; } } } diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 308512d9..486324c1 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -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().indices().get(); - 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 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().indices().get(); 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().indices().get(); return *betting_market_group_index.rbegin(); diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index e7041eea..50d7ea30 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -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 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);