added global_betting_statistics implementation object. Object is created, but nothing talks to it yet.

This commit is contained in:
SynaptiCAD User 2017-03-22 14:47:52 -04:00
parent 3feea69a4c
commit a267741fd1
4 changed files with 67 additions and 1 deletions

View file

@ -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;

View file

@ -53,6 +53,7 @@
#include <graphene/chain/event_group_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/global_betting_statistics_object.hpp>
#include <graphene/chain/account_evaluator.hpp>
#include <graphene/chain/asset_evaluator.hpp>
@ -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>([&](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" );

View file

@ -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 <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
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<asset_id_type, share_type> total_amount_staked;
};
typedef multi_index_container<
global_betting_statistics_object,
indexed_by<
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > > > > global_betting_statistics_object_multi_index_type;
typedef generic_index<global_betting_statistics_object, global_betting_statistics_object_multi_index_type> 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) )

View file

@ -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<char, GRAPHENE_MAX_ASSET_SYMBOL_LENGTH> 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 )