diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index ffe52715d6..3a0dc2e770 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * Copyright (c) 2017 Cryptonomex, Inc., and contributors. * * The MIT License * @@ -208,7 +208,7 @@ 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 > >(); add_index< primary_index > >(); @@ -241,9 +241,6 @@ void database::init_genesis(const genesis_state_type& genesis_state) transaction_evaluation_state genesis_eval_state(this); - flat_index& bsi = get_mutable_index_type< flat_index >(); - bsi.resize(0xffff+1); - // Create blockchain accounts fc::ecc::private_key null_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); create([](account_balance_object& b) { @@ -404,7 +401,8 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.chain_id = chain_id; p.immutable_parameters = genesis_state.immutable_parameters; } ); - create([&](block_summary_object&) {}); + for (uint32_t i = 0; i <= 0x10000; i++) + create( [&]( block_summary_object&) {}); // Create initial accounts for( const auto& account : genesis_state.initial_accounts ) diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 05328a37e8..cec4c988b3 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * Copyright (c) 2017 Cryptonomex, Inc., and contributors. * * The MIT License * @@ -24,7 +24,6 @@ #pragma once #include #include -#include #include /** @@ -228,7 +227,6 @@ namespace graphene { namespace chain { > > > asset_bitasset_data_object_multi_index_type; - //typedef flat_index asset_bitasset_data_index; typedef generic_index asset_bitasset_data_index; struct by_symbol; diff --git a/libraries/chain/include/graphene/chain/worker_object.hpp b/libraries/chain/include/graphene/chain/worker_object.hpp index 1219fc1c6d..b1e2b7c107 100644 --- a/libraries/chain/include/graphene/chain/worker_object.hpp +++ b/libraries/chain/include/graphene/chain/worker_object.hpp @@ -153,7 +153,6 @@ typedef multi_index_container< > > worker_object_multi_index_type; -//typedef flat_index worker_index; using worker_index = generic_index; } } // graphene::chain diff --git a/libraries/db/include/graphene/db/flat_index.hpp b/libraries/db/include/graphene/db/flat_index.hpp deleted file mode 100644 index f1b7912ef7..0000000000 --- a/libraries/db/include/graphene/db/flat_index.hpp +++ /dev/null @@ -1,132 +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 - -namespace graphene { namespace db { - - /** - * @class flat_index - * @brief A flat index uses a vector to store data - * - * This index is preferred in situations where the data will never be - * removed from main memory and when lots of small objects that - * are accessed in order are required. - */ - template - class flat_index : public index - { - public: - typedef T object_type; - - virtual const object& create( const std::function& constructor ) override - { - auto id = get_next_id(); - auto instance = id.instance(); - if( instance >= _objects.size() ) _objects.resize( instance + 1 ); - _objects[instance].id = id; - constructor( _objects[instance] ); - use_next_id(); - return _objects[instance]; - } - - virtual void modify( const object& obj, const std::function& modify_callback ) override - { - assert( obj.id.instance() < _objects.size() ); - modify_callback( _objects[obj.id.instance()] ); - } - - virtual const object& insert( object&& obj )override - { - auto instance = obj.id.instance(); - assert( nullptr != dynamic_cast(&obj) ); - if( _objects.size() <= instance ) _objects.resize( instance+1 ); - _objects[instance] = std::move( static_cast(obj) ); - return _objects[instance]; - } - - virtual void remove( const object& obj ) override - { - assert( nullptr != dynamic_cast(&obj) ); - const auto instance = obj.id.instance(); - _objects[instance] = T(); - } - - virtual const object* find( object_id_type id )const override - { - assert( id.space() == T::space_id ); - assert( id.type() == T::type_id ); - - const auto instance = id.instance(); - if( instance >= _objects.size() ) return nullptr; - return &_objects[instance]; - } - - virtual void inspect_all_objects(std::function inspector)const override - { - try { - for( const auto& ptr : _objects ) - { - inspector(ptr); - } - } FC_CAPTURE_AND_RETHROW() - } - - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr.hash(); - - return result; - } - - class const_iterator - { - public: - const_iterator(){} - const_iterator( const typename vector::const_iterator& a ):_itr(a){} - friend bool operator==( const const_iterator& a, const const_iterator& b ) { return a._itr == b._itr; } - friend bool operator!=( const const_iterator& a, const const_iterator& b ) { return a._itr != b._itr; } - const T* operator*()const { return static_cast(&*_itr); } - const_iterator& operator++(int){ ++_itr; return *this; } - const_iterator& operator++() { ++_itr; return *this; } - private: - typename vector::const_iterator _itr; - }; - const_iterator begin()const { return const_iterator(_objects.begin()); } - const_iterator end()const { return const_iterator(_objects.end()); } - - size_t size()const{ return _objects.size(); } - - void resize( uint32_t s ) { - _objects.resize(s); - for( uint32_t i = 0; i < s; ++i ) - _objects[i].id = object_id_type(object_type::space_id,object_type::type_id,i); - } - - private: - vector< T > _objects; - }; - -} } // graphene::db