Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add market history plugin asserts #2158

Merged
merged 2 commits into from
Jun 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 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 @@ -464,9 +467,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, vector<uint16_t> operation_types, uint32_t start, unsigned limit)
Expand All @@ -486,9 +489,14 @@ namespace graphene { namespace app {
}

vector<bucket_object> history_api::get_market_history( std::string asset_a, std::string asset_b,
uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end )const
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