From a267741fd13ae670cb006c389d8ea36b04bc7448 Mon Sep 17 00:00:00 2001 From: SynaptiCAD User Date: Wed, 22 Mar 2017 14:47:52 -0400 Subject: [PATCH] added global_betting_statistics implementation object. Object is created, but nothing talks to it yet. --- libraries/app/api.cpp | 2 + libraries/chain/db_init.cpp | 8 +++ .../global_betting_statistics_object.hpp | 52 +++++++++++++++++++ .../include/graphene/chain/protocol/types.hpp | 6 ++- 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c6408bf4..3624beed 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -366,6 +366,8 @@ namespace graphene { namespace app { break; case impl_betting_market_position_object_type: break; + case impl_global_betting_statistics_object_type: + break; } } return result; diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 56e698ae..b85dcc07 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -162,6 +163,9 @@ const uint8_t bet_object::type_id; const uint8_t betting_market_position_object::space_id; const uint8_t betting_market_position_object::type_id; +const uint8_t global_betting_statistics_object::space_id; +const uint8_t global_betting_statistics_object::type_id; + void database::initialize_evaluators() { @@ -267,6 +271,7 @@ void database::initialize_indexes() add_index< primary_index< simple_index< fba_accumulator_object > > >(); add_index< primary_index< betting_market_position_multi_index > >(); + add_index< primary_index< global_betting_statistics_object_index > >(); } void database::init_genesis(const genesis_state_type& genesis_state) @@ -446,6 +451,9 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.witness_budget = 0; p.recent_slots_filled = fc::uint128::max_value(); }); + create([&](global_betting_statistics_object& betting_statistics) { + betting_statistics.number_of_active_events = 0; + }); FC_ASSERT( (genesis_state.immutable_parameters.min_witness_count & 1) == 1, "min_witness_count must be odd" ); FC_ASSERT( (genesis_state.immutable_parameters.min_committee_member_count & 1) == 1, "min_committee_member_count must be odd" ); diff --git a/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp new file mode 100644 index 00000000..9d59cb66 --- /dev/null +++ b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp @@ -0,0 +1,52 @@ +/* + * 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 global_betting_statistics_object : public graphene::db::abstract_object< global_betting_statistics_object > +{ + public: + static const uint8_t space_id = implementation_ids; + static const uint8_t type_id = impl_global_betting_statistics_object_type; + + uint32_t number_of_active_events; + map total_amount_staked; +}; + +typedef multi_index_container< + global_betting_statistics_object, + indexed_by< + ordered_unique< tag, member< object, object_id_type, &object::id > > > > global_betting_statistics_object_multi_index_type; +typedef generic_index global_betting_statistics_object_index; + +} } // graphene::chain + +FC_REFLECT_DERIVED( graphene::chain::global_betting_statistics_object, (graphene::db::object), (number_of_active_events)(total_amount_staked) ) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 4c7a0501..2d544509 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -163,7 +163,8 @@ namespace graphene { namespace chain { impl_special_authority_object_type, impl_buyback_object_type, impl_fba_accumulator_object_type, - impl_betting_market_position_object_type + impl_betting_market_position_object_type, + impl_global_betting_statistics_object_type }; //typedef fc::unsigned_int object_id_type; @@ -230,6 +231,7 @@ namespace graphene { namespace chain { class buyback_object; class fba_accumulator_object; class betting_market_position_object; + class global_betting_statistics_object; typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; @@ -251,6 +253,7 @@ namespace graphene { namespace chain { typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; + typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; typedef fc::array symbol_type; typedef fc::ripemd160 block_id_type; @@ -396,6 +399,7 @@ FC_REFLECT_ENUM( graphene::chain::impl_object_type, (impl_buyback_object_type) (impl_fba_accumulator_object_type) (impl_betting_market_position_object_type) + (impl_global_betting_statistics_object_type) ) FC_REFLECT_TYPENAME( graphene::chain::share_type )