Skip to content

Commit

Permalink
Merge pull request #2158 from oxarbitrage/issue2021
Browse files Browse the repository at this point in the history
Add market history plugin asserts
  • Loading branch information
abitmore authored Jun 4, 2020
2 parents be708d3 + a272ee7 commit fbbc691
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,11 @@ namespace graphene { namespace app {
return *_custom_operations_api;
}

vector<order_history_object> history_api::get_fill_order_history( std::string asset_a, std::string asset_b, uint32_t limit )const
vector<order_history_object> history_api::get_fill_order_history( std::string asset_a, std::string asset_b,
uint32_t limit )const
{
auto market_hist_plugin = _app.get_plugin<market_history_plugin>( "market_history" );
FC_ASSERT( market_hist_plugin, "Market history plugin is not enabled" );
FC_ASSERT(_app.chain_database());
const auto& db = *_app.chain_database();
asset_id_type a = database_api.get_asset_id_from_string( asset_a );
Expand Down Expand Up @@ -476,9 +479,9 @@ namespace graphene { namespace app {

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();
auto market_hist_plugin = _app.get_plugin<market_history_plugin>( "market_history" );
FC_ASSERT( market_hist_plugin, "Market history plugin is not enabled" );
return market_hist_plugin->tracked_buckets();
}

history_operation_detail history_api::get_account_history_by_operations( const std::string account_id_or_name,
Expand Down Expand Up @@ -514,7 +517,11 @@ namespace graphene { namespace app {
uint32_t bucket_seconds,
fc::time_point_sec start, fc::time_point_sec end )const
{ try {

auto market_hist_plugin = _app.get_plugin<market_history_plugin>( "market_history" );
FC_ASSERT( market_hist_plugin, "Market history plugin is not enabled" );
FC_ASSERT(_app.chain_database());

const auto& db = *_app.chain_database();
asset_id_type a = database_api.get_asset_id_from_string( asset_a );
asset_id_type b = database_api.get_asset_id_from_string( asset_b );
Expand Down

0 comments on commit fbbc691

Please sign in to comment.