diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 014b7385..105b948b 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -478,6 +478,25 @@ namespace graphene { namespace app { return result; } FC_CAPTURE_AND_RETHROW( (a)(b)(bucket_seconds)(start)(end) ) } + /** + * @return all accounts that referr to the key or account id in their owner or active authorities. + */ + vector database_api::get_account_references( object_id_type key_or_account_id )const + { + const auto& idx = _db.get_index_type(); + const auto& aidx = dynamic_cast&>(idx); + const auto& refs = aidx.get_secondary_index(); + auto itr = refs.account_to_memberships.find(key_or_account_id); + vector result; + + if( itr != refs.account_to_memberships.end() ) + { + result.reserve( itr->second.size() ); + for( auto item : itr->second ) result.push_back(item); + } + return result; + } + /** TODO: add secondary index that will accelerate this process */ vector database_api::get_proposed_transactions( account_id_type id )const { diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 21fbc2e7..c081ef17 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -237,6 +237,10 @@ namespace graphene { namespace app { */ vector get_proposed_transactions( account_id_type id )const; + /** + * @return all accounts that referr to the key or account id in their owner or active authorities. + */ + vector get_account_references( object_id_type key_or_account_id )const; private: /** called every time a block is applied to report the objects that were changed */ @@ -378,6 +382,7 @@ FC_API(graphene::app::database_api, (cancel_all_subscriptions) (get_transaction_hex) (get_proposed_transactions) + (get_account_references) ) 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))