Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Moved object and multi index definition to its own header file and ad…
Browse files Browse the repository at this point in the history
…ded type comment
  • Loading branch information
brianjohnson5972 committed Aug 8, 2017
1 parent 69f0bb1 commit 4a4026e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/include/eos/chain/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace eos { namespace chain {
transaction_object_type,
producer_object_type,
chain_property_object_type,
transaction_history_object_type,
transaction_history_object_type, ///< Defined by account history plugin library
balance_object_type, ///< Defined by native_contract library
staked_balance_object_type, ///< Defined by native_contract library
producer_votes_object_type, ///< Defined by native_contract library
Expand Down
27 changes: 3 additions & 24 deletions plugins/account_history_plugin/account_history_plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <eos/account_history_plugin/account_history_plugin.hpp>
#include <eos/account_history_plugin/account_history_object.hpp>
#include <eos/chain/chain_controller.hpp>
#include <eos/chain/config.hpp>
#include <eos/chain/exceptions.hpp>
Expand All @@ -13,6 +14,8 @@
#include <boost/multi_index/mem_fun.hpp>
#include <eos/chain/multi_index_includes.hpp>

namespace fc { class variant; }

namespace eos {

using chain::block_id_type;
Expand All @@ -22,26 +25,6 @@ using boost::multi_index_container;
using chain::transaction_id_type;
using namespace boost::multi_index;

class transaction_history_object : public chainbase::object<chain::transaction_history_object_type, transaction_history_object> {
OBJECT_CTOR(transaction_history_object)

id_type id;
block_id_type block_id;
transaction_id_type transaction_id;
};

struct by_id;
struct by_trx_id;
using transaction_history_multi_index = chainbase::shared_multi_index_container<
transaction_history_object,
indexed_by<
ordered_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_history_object::id_type, id)>,
hashed_unique<tag<by_trx_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, transaction_id), std::hash<transaction_id_type>>
>
>;

typedef chainbase::generic_index<transaction_history_multi_index> transaction_history_index;

class account_history_plugin_impl {
public:
ProcessedTransaction get_transaction(const chain::transaction_id_type& transaction_id) const;
Expand Down Expand Up @@ -151,7 +134,3 @@ read_only::get_transaction_results read_only::get_transaction(const read_only::g

} // namespace account_history_apis
} // namespace eos

CHAINBASE_SET_INDEX_TYPE( eos::transaction_history_object, eos::transaction_history_multi_index )

FC_REFLECT( eos::transaction_history_object, (block_id)(transaction_id) )
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <chainbase/chainbase.hpp>

namespace eos {
using chain::block_id_type;
using chain::transaction_id_type;
using namespace boost::multi_index;

class transaction_history_object : public chainbase::object<chain::transaction_history_object_type, transaction_history_object> {
OBJECT_CTOR(transaction_history_object)

id_type id;
block_id_type block_id;
transaction_id_type transaction_id;
};

struct by_id;
struct by_trx_id;
using transaction_history_multi_index = chainbase::shared_multi_index_container<
transaction_history_object,
indexed_by<
ordered_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_history_object::id_type, id)>,
hashed_unique<tag<by_trx_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, transaction_id), std::hash<transaction_id_type>>
>
>;

typedef chainbase::generic_index<transaction_history_multi_index> transaction_history_index;

}

CHAINBASE_SET_INDEX_TYPE( eos::transaction_history_object, eos::transaction_history_multi_index )

FC_REFLECT( eos::transaction_history_object, (block_id)(transaction_id) )

0 comments on commit 4a4026e

Please sign in to comment.