From e7ec05f54598194ea5bb7324b58ea471e10035ba Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 24 Jun 2015 21:09:21 -0400 Subject: [PATCH] #74 Adding API call to get all call orders for a given account type --- libraries/app/api.cpp | 15 +++++++++++++++ libraries/app/include/graphene/app/api.hpp | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 2d2a5a02..d0deecc7 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -533,5 +533,20 @@ namespace graphene { namespace app { return result; } FC_CAPTURE_AND_RETHROW( (a) ) } + vector database_api::get_margin_positions( const account_id_type& id )const + { try { + const auto& idx = _db.get_index_type(); + const auto& aidx = idx.indices().get(); + auto start = aidx.lower_bound( boost::make_tuple( id, 0 ) ); + auto end = aidx.lower_bound( boost::make_tuple( id+1, 0 ) ); + vector result; + while( start != end ) + { + result.push_back(*start); + ++start; + } + return result; + } FC_CAPTURE_AND_RETHROW( (id) ) } + } } // graphene::app diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 024b0697..be3b1d5f 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -247,6 +247,11 @@ namespace graphene { namespace app { */ vector get_keys_for_address( const address& a )const; + /** + * @return all open margin positions for a given account id. + */ + vector get_margin_positions( const account_id_type& id )const; + private: /** called every time a block is applied to report the objects that were changed */ void on_objects_changed(const vector& ids); @@ -389,6 +394,7 @@ FC_API(graphene::app::database_api, (get_proposed_transactions) (get_account_references) (get_keys_for_address) + (get_margin_positions) ) 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))