diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index bb1e725f..47ac4625 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -446,4 +446,22 @@ namespace graphene { namespace app { return result; } + /** TODO: add secondary index that will accelerate this process */ + vector database_api::get_proposed_transactions( account_id_type id )const + { + const auto& idx = _db.get_index_type(); + vector result; + + idx.inspect_all_objects( [&](const object& obj){ + const proposal_object& p = static_cast(obj); + if( p.required_active_approvals.find( id ) != p.required_active_approvals.end() ) + result.push_back(p); + else if ( p.required_owner_approvals.find( id ) != p.required_owner_approvals.end() ) + result.push_back(p); + else if ( p.available_active_approvals.find( id ) != p.available_active_approvals.end() ) + result.push_back(p); + }); + return result; + } + } } // graphene::app diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index e1b2e3c9..b0513b45 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -226,6 +227,13 @@ namespace graphene { namespace app { /// @brief Get a hexdump of the serialized binary form of a transaction std::string get_transaction_hex(const signed_transaction& trx)const; + + /** + * @return the set of proposed transactions relevant to the specified account id. + */ + vector get_proposed_transactions( 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); @@ -362,6 +370,7 @@ FC_API(graphene::app::database_api, (unsubscribe_from_market) (cancel_all_subscriptions) (get_transaction_hex) + (get_proposed_transactions) ) FC_API(graphene::app::history_api, (get_account_history)) FC_API(graphene::app::network_api, (broadcast_transaction)(add_node)(get_connected_peers))