From c4b2bb443ba623b4b4ad07020a00f60c75df3ce1 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 24 Jun 2015 16:08:36 -0400 Subject: [PATCH] #85 - changing key_object from simple_index to multi_index --- libraries/chain/db_init.cpp | 9 ++++++++- .../chain/include/graphene/chain/address.hpp | 1 + .../include/graphene/chain/key_object.hpp | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 4d087481..2d0763ed 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -103,11 +103,18 @@ void database::initialize_indexes() //Protocol object indexes add_index< primary_index >(); add_index< primary_index >(); + auto acnt_index = add_index< primary_index >(); acnt_index->add_secondary_index(); acnt_index->add_secondary_index(); - add_index< primary_index> >(); + // this is the fast effecient version for validation only + // add_index< primary_index> >(); + + // this is the slower version designed to aid GUI use. We will + // default to the "slow" version until we need a faster version. + add_index< primary_index >(); + add_index< primary_index >(); add_index< primary_index >(); add_index< primary_index >(); diff --git a/libraries/chain/include/graphene/chain/address.hpp b/libraries/chain/include/graphene/chain/address.hpp index 33357828..39f80800 100644 --- a/libraries/chain/include/graphene/chain/address.hpp +++ b/libraries/chain/include/graphene/chain/address.hpp @@ -56,6 +56,7 @@ namespace graphene { namespace chain { explicit operator std::string()const; ///< converts to base58 + checksum + friend size_t hash_value( const address& v ) { return *((size_t*)&v.addr._hash[2]); } fc::ripemd160 addr; }; inline bool operator == ( const address& a, const address& b ) { return a.addr == b.addr; } diff --git a/libraries/chain/include/graphene/chain/key_object.hpp b/libraries/chain/include/graphene/chain/key_object.hpp index 7daaa5ab..cb928f2c 100644 --- a/libraries/chain/include/graphene/chain/key_object.hpp +++ b/libraries/chain/include/graphene/chain/key_object.hpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include namespace graphene { namespace chain { typedef static_variant address_or_key; @@ -42,6 +44,23 @@ namespace graphene { namespace chain { address_or_key key_data; }; + + struct by_address; + + /** + * @ingroup object_index + */ + typedef multi_index_container< + key_object, + indexed_by< + hashed_unique< tag, member< object, object_id_type, &object::id > >, + hashed_non_unique< tag, const_mem_fun > + > + > key_multi_index_type; + /** + * @ingroup object_index + */ + typedef generic_index key_index; } } FC_REFLECT_TYPENAME( graphene::chain::address_or_key )