#47 Adding API to get the available history buckets based upon the configuration

This commit is contained in:
Daniel Larimer 2015-06-24 12:46:03 -04:00
parent 44313ac8a4
commit af812a7b51
5 changed files with 34 additions and 23 deletions

2
docs

@ -1 +1 @@
Subproject commit 94ec061b91edbe9d1ebae576e641f921998428c8
Subproject commit 71ed2984b71d57cab13cdf12074cff150edc1d3d

View file

@ -445,7 +445,17 @@ namespace graphene { namespace app {
}
return result;
}
vector<bucket_object> history_api::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
flat_set<uint32_t> history_api::get_market_history_buckets()const
{
auto hist = _app.get_plugin<market_history_plugin>( "market_history" );
FC_ASSERT( hist );
return hist->tracked_buckets();
}
vector<bucket_object> history_api::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
{ try {
FC_ASSERT(_app.chain_database());
const auto& db = *_app.chain_database();

View file

@ -258,25 +258,27 @@ namespace graphene { namespace app {
*/
class history_api
{
public:
history_api(application& app):_app(app){}
public:
history_api(application& app):_app(app){}
/**
* @brief Get operations relevant to the specificed account
* @param account The account whose history should be queried
* @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest.
*/
vector<operation_history_object> get_account_history(account_id_type account,
operation_history_id_type stop = operation_history_id_type(),
int limit = 100,
operation_history_id_type start = operation_history_id_type())const;
/**
* @brief Get operations relevant to the specificed account
* @param account The account whose history should be queried
* @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest.
*/
vector<operation_history_object> get_account_history(account_id_type account,
operation_history_id_type stop = operation_history_id_type(),
int limit = 100,
operation_history_id_type start = operation_history_id_type())const;
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;
private:
application& _app;
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;
flat_set<uint32_t> get_market_history_buckets()const;
private:
application& _app;
};
/**
@ -377,7 +379,7 @@ FC_API(graphene::app::database_api,
(get_transaction_hex)
(get_proposed_transactions)
)
FC_API(graphene::app::history_api, (get_account_history)(get_market_history))
FC_API(graphene::app::history_api, (get_account_history)(get_market_history)(get_market_history_buckets))
FC_API(graphene::app::network_api, (broadcast_transaction)(add_node)(get_connected_peers))
FC_API(graphene::app::login_api,
(login)

@ -1 +1 @@
Subproject commit 701b9ac00c46234ee7cc6385027f5942590debc9
Subproject commit c09035dba0cdab7fcb2c11bf81aaeaffaa981f66

View file

@ -117,8 +117,7 @@ class market_history_plugin : public graphene::app::plugin
const boost::program_options::variables_map& options) override;
virtual void plugin_startup() override;
vector<bucket_object> get_history( const bucket_key& start, const bucket_key& end )const;
const flat_set<uint32_t>& tracked_buckets()const;
const flat_set<uint32_t>& tracked_buckets()const;
private:
friend class detail::market_history_plugin_impl;