First implementation of get_account_history api changes.
This commit is contained in:
parent
7f4b40f57d
commit
c89d60ba92
6 changed files with 87 additions and 28 deletions
|
|
@ -11,7 +11,7 @@ add_library( graphene_app
|
||||||
${EGENESIS_HEADERS}
|
${EGENESIS_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries( graphene_app graphene_market_history graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities )
|
target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities )
|
||||||
target_include_directories( graphene_app
|
target_include_directories( graphene_app
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
|
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,28 @@ namespace graphene { namespace app {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<operation_history_object> history_api::get_relative_account_history( account_id_type account, uint32_t stop, unsigned limit, uint32_t start) const
|
||||||
|
{
|
||||||
|
FC_ASSERT(_app.chain_database());
|
||||||
|
const auto& db = *_app.chain_database();
|
||||||
|
FC_ASSERT(limit <= 100);
|
||||||
|
vector<operation_history_object> result;
|
||||||
|
if (start == 0)
|
||||||
|
start = account(db).statistics(db).total_ops;
|
||||||
|
const auto& hist_idx = db.get_index_type<account_transaction_history_index>();
|
||||||
|
const auto& by_seq_idx = hist_idx.indices().get<by_seq>();
|
||||||
|
|
||||||
|
auto itr = by_seq_idx.upper_bound( boost::make_tuple( account, start ) );
|
||||||
|
|
||||||
|
while ( itr != by_seq_idx.end() && itr->sequence > stop && result.size() < limit )
|
||||||
|
{
|
||||||
|
result.push_back( itr->operation_id(db) );
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
flat_set<uint32_t> history_api::get_market_history_buckets()const
|
flat_set<uint32_t> history_api::get_market_history_buckets()const
|
||||||
{
|
{
|
||||||
auto hist = _app.get_plugin<market_history_plugin>( "market_history" );
|
auto hist = _app.get_plugin<market_history_plugin>( "market_history" );
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ namespace graphene { namespace app {
|
||||||
unsigned limit = 100,
|
unsigned limit = 100,
|
||||||
operation_history_id_type start = operation_history_id_type())const;
|
operation_history_id_type start = operation_history_id_type())const;
|
||||||
|
|
||||||
|
vector<operation_history_object> get_relative_account_history( account_id_type account,
|
||||||
|
uint32_t stop = 0,
|
||||||
|
unsigned limit = 100,
|
||||||
|
uint32_t start = 0) const;
|
||||||
|
|
||||||
vector<order_history_object> get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const;
|
vector<order_history_object> get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const;
|
||||||
vector<bucket_object> get_market_history( asset_id_type a, asset_id_type b, uint32_t bucket_seconds,
|
vector<bucket_object> get_market_history( asset_id_type a, asset_id_type b, uint32_t bucket_seconds,
|
||||||
fc::time_point_sec start, fc::time_point_sec end )const;
|
fc::time_point_sec start, fc::time_point_sec end )const;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <graphene/chain/protocol/operations.hpp>
|
#include <graphene/chain/protocol/operations.hpp>
|
||||||
#include <graphene/db/object.hpp>
|
#include <graphene/db/object.hpp>
|
||||||
|
#include <boost/multi_index/composite_key.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
|
|
@ -91,9 +92,35 @@ namespace graphene { namespace chain {
|
||||||
uint32_t sequence = 0; /// the operation position within the given account
|
uint32_t sequence = 0; /// the operation position within the given account
|
||||||
account_transaction_history_id_type next;
|
account_transaction_history_id_type next;
|
||||||
|
|
||||||
std::pair<account_id_type,operation_history_id_type> account_op()const { return std::tie( account, operation_id ); }
|
//std::pair<account_id_type,operation_history_id_type> account_op()const { return std::tie( account, operation_id ); }
|
||||||
std::pair<account_id_type,uint32_t> account_seq()const { return std::tie( account, sequence ); }
|
//std::pair<account_id_type,uint32_t> account_seq()const { return std::tie( account, sequence ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct by_id;
|
||||||
|
struct by_seq;
|
||||||
|
struct by_op;
|
||||||
|
typedef multi_index_container<
|
||||||
|
account_transaction_history_object,
|
||||||
|
indexed_by<
|
||||||
|
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
|
||||||
|
ordered_unique< tag<by_seq>,
|
||||||
|
composite_key< account_transaction_history_object,
|
||||||
|
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
||||||
|
member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence>
|
||||||
|
>
|
||||||
|
>,
|
||||||
|
ordered_unique< tag<by_op>,
|
||||||
|
composite_key< account_transaction_history_object,
|
||||||
|
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
||||||
|
member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
> account_transaction_history_multi_index_type;
|
||||||
|
|
||||||
|
typedef generic_index<account_transaction_history_object, account_transaction_history_multi_index_type> account_transaction_history_index;
|
||||||
|
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::operation_history_object, (graphene::chain::object),
|
FC_REFLECT_DERIVED( graphene::chain::operation_history_object, (graphene::chain::object),
|
||||||
|
|
|
||||||
|
|
@ -138,30 +138,6 @@ void account_history_plugin_impl::update_account_histories( const signed_block&
|
||||||
} // end namespace detail
|
} // end namespace detail
|
||||||
|
|
||||||
|
|
||||||
struct by_id;
|
|
||||||
struct by_seq;
|
|
||||||
struct by_op;
|
|
||||||
typedef multi_index_container<
|
|
||||||
account_transaction_history_object,
|
|
||||||
indexed_by<
|
|
||||||
ordered_unique< tag<by_id>,
|
|
||||||
member< object, object_id_type, &object::id > >,
|
|
||||||
ordered_unique< tag<by_seq>,
|
|
||||||
composite_key< account_transaction_history_object,
|
|
||||||
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
|
||||||
member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence>
|
|
||||||
>
|
|
||||||
>,
|
|
||||||
ordered_unique< tag<by_op>,
|
|
||||||
composite_key< account_transaction_history_object,
|
|
||||||
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
|
||||||
member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id>
|
|
||||||
>
|
|
||||||
>
|
|
||||||
>
|
|
||||||
> account_transaction_history_multi_index_type;
|
|
||||||
|
|
||||||
typedef generic_index<account_transaction_history_object, account_transaction_history_multi_index_type> account_transaction_history_index;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,15 @@
|
||||||
#include <graphene/app/plugin.hpp>
|
#include <graphene/app/plugin.hpp>
|
||||||
#include <graphene/chain/database.hpp>
|
#include <graphene/chain/database.hpp>
|
||||||
|
|
||||||
|
#include <graphene/chain/operation_history_object.hpp>
|
||||||
|
|
||||||
#include <fc/thread/future.hpp>
|
#include <fc/thread/future.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace account_history {
|
namespace graphene { namespace account_history {
|
||||||
using namespace chain;
|
using namespace chain;
|
||||||
|
//using namespace graphene::db;
|
||||||
|
//using boost::multi_index_container;
|
||||||
|
//using namespace boost::multi_index;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plugins should #define their SPACE_ID's so plugins with
|
// Plugins should #define their SPACE_ID's so plugins with
|
||||||
|
|
@ -75,3 +80,27 @@ class account_history_plugin : public graphene::app::plugin
|
||||||
|
|
||||||
} } //graphene::account_history
|
} } //graphene::account_history
|
||||||
|
|
||||||
|
/*struct by_id;
|
||||||
|
struct by_seq;
|
||||||
|
struct by_op;
|
||||||
|
typedef boost::multi_index_container<
|
||||||
|
graphene::chain::account_transaction_history_object,
|
||||||
|
boost::multi_index::indexed_by<
|
||||||
|
boost::multi_index::ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
|
||||||
|
boost::multi_index::ordered_unique< tag<by_seq>,
|
||||||
|
composite_key< account_transaction_history_object,
|
||||||
|
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
||||||
|
member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence>
|
||||||
|
>
|
||||||
|
>,
|
||||||
|
boost::multi_index::ordered_unique< tag<by_op>,
|
||||||
|
composite_key< account_transaction_history_object,
|
||||||
|
member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>,
|
||||||
|
member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
>
|
||||||
|
> account_transaction_history_multi_index_type;
|
||||||
|
|
||||||
|
typedef graphene::account_history::generic_index<graphene::chain::account_transaction_history_object, account_transaction_history_multi_index_type> account_transaction_history_index;
|
||||||
|
*/
|
||||||
Loading…
Reference in a new issue