From d776506ba623c20a87bd6f6382f9016eefac768a Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Wed, 12 Feb 2020 17:23:36 -0800 Subject: [PATCH 01/10] WIP. Doesn't build #3610 --- .../apis/database_api/database_api.cpp | 363 +++++++++--------- libraries/plugins/apis/rc_api/CMakeLists.txt | 2 +- .../include/steem/plugins/rc_api/rc_api.hpp | 152 +++++++- libraries/plugins/apis/rc_api/rc_api.cpp | 158 +++++++- .../include/steem/plugins/rc/rc_objects.hpp | 7 + 5 files changed, 479 insertions(+), 203 deletions(-) diff --git a/libraries/plugins/apis/database_api/database_api.cpp b/libraries/plugins/apis/database_api/database_api.cpp index 7d04744304..cb42bb07b7 100644 --- a/libraries/plugins/apis/database_api/database_api.cpp +++ b/libraries/plugins/apis/database_api/database_api.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -17,7 +18,11 @@ namespace steem { namespace plugins { namespace database_api { +using namespace util; +//using util::iterate_results; +//using util::filter_default; +//using util::on_push_default; class database_api_impl { @@ -88,50 +93,6 @@ class database_api_impl (find_smt_token_balances) ) - template< typename ResultType > - static ResultType on_push_default( const ResultType& r ) { return r; } - - template< typename ValueType > - static bool filter_default( const ValueType& r ) { return true; } - - template - void iterate_results( - StartType start, - std::vector& result, - uint32_t limit, - OnPushType&& on_push, - FilterType&& filter, - order_direction_type direction = ascending ) - { - const auto& idx = _db.get_index< IndexType, OrderType >(); - if( direction == ascending ) - { - auto itr = idx.lower_bound( start ); - auto end = idx.end(); - - while( result.size() < limit && itr != end ) - { - if( filter( *itr ) ) - result.push_back( on_push( *itr ) ); - - ++itr; - } - } - else if( direction == descending ) - { - auto itr = boost::make_reverse_iterator( idx.lower_bound( start ) ); - auto end = idx.rend(); - - while( result.size() < limit && itr != end ) - { - if( filter( *itr ) ) - result.push_back( on_push( *itr ) ); - - ++itr; - } - } - } - chain::database& _db; }; @@ -236,35 +197,38 @@ DEFINE_API_IMPL( database_api_impl, list_witnesses ) { case( by_name ): { - iterate_results< chain::witness_index, chain::by_name >( + iterate_results( + _db.get_index< chain::witness_index, chain::by_name >(), args.start.as< protocol::account_name_type >(), result.witnesses, args.limit, [&]( const witness_object& w ){ return api_witness_object( w ); }, - &database_api_impl::filter_default< witness_object > ); + &filter_default< witness_object > ); break; } case( by_vote_name ): { auto key = args.start.as< std::pair< share_type, account_name_type > >(); - iterate_results< chain::witness_index, chain::by_vote_name >( + iterate_results( + _db.get_index< chain::witness_index, chain::by_vote_name >(), boost::make_tuple( key.first, key.second ), result.witnesses, args.limit, [&]( const witness_object& w ){ return api_witness_object( w ); }, - &database_api_impl::filter_default< witness_object > ); + &filter_default< witness_object > ); break; } case( by_schedule_time ): { auto key = args.start.as< std::pair< fc::uint128, account_name_type > >(); auto wit_id = _db.get< chain::witness_object, chain::by_name >( key.second ).id; - iterate_results< chain::witness_index, chain::by_schedule_time >( + iterate_results( + _db.get_index< chain::witness_index, chain::by_schedule_time >(), boost::make_tuple( key.first, wit_id ), result.witnesses, args.limit, [&]( const witness_object& w ){ return api_witness_object( w ); }, - &database_api_impl::filter_default< witness_object > ); + &filter_default< witness_object > ); break; } default: @@ -303,23 +267,25 @@ DEFINE_API_IMPL( database_api_impl, list_witness_votes ) case( by_account_witness ): { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); - iterate_results< chain::witness_vote_index, chain::by_account_witness >( + iterate_results( + _db.get_index< chain::witness_vote_index, chain::by_account_witness >(), boost::make_tuple( key.first, key.second ), result.votes, args.limit, [&]( const witness_vote_object& v ){ return api_witness_vote_object( v ); }, - &database_api_impl::filter_default< api_witness_vote_object > ); + &filter_default< api_witness_vote_object > ); break; } case( by_witness_account ): { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); - iterate_results< chain::witness_vote_index, chain::by_witness_account >( + iterate_results( + _db.get_index< chain::witness_vote_index, chain::by_witness_account >(), boost::make_tuple( key.first, key.second ), result.votes, args.limit, [&]( const witness_vote_object& v ){ return api_witness_vote_object( v ); }, - &database_api_impl::filter_default< api_witness_vote_object > ); + &filter_default< api_witness_vote_object > ); break; } default: @@ -360,34 +326,37 @@ DEFINE_API_IMPL( database_api_impl, list_accounts ) { case( by_name ): { - iterate_results< chain::account_index, chain::by_name >( + iterate_results( + _db.get_index< chain::account_index, chain::by_name >(), args.start.as< protocol::account_name_type >(), result.accounts, args.limit, [&]( const account_object& a ){ return api_account_object( a, _db ); }, - &database_api_impl::filter_default< account_object > ); + &filter_default< account_object > ); break; } case( by_proxy ): { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); - iterate_results< chain::account_index, chain::by_proxy >( + iterate_results( + _db.get_index< chain::account_index, chain::by_proxy >(), boost::make_tuple( key.first, key.second ), result.accounts, args.limit, [&]( const account_object& a ){ return api_account_object( a, _db ); }, - &database_api_impl::filter_default< account_object > ); + &filter_default< account_object > ); break; } case( by_next_vesting_withdrawal ): { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); - iterate_results< chain::account_index, chain::by_next_vesting_withdrawal >( + iterate_results( + _db.get_index< chain::account_index, chain::by_next_vesting_withdrawal >(), boost::make_tuple( key.first, key.second ), result.accounts, args.limit, [&]( const account_object& a ){ return api_account_object( a, _db ); }, - &database_api_impl::filter_default< account_object > ); + &filter_default< account_object > ); break; } default: @@ -423,12 +392,13 @@ DEFINE_API_IMPL( database_api_impl, list_owner_histories ) result.owner_auths.reserve( args.limit ); auto key = args.start.as< std::pair< account_name_type, fc::time_point_sec > >(); - iterate_results< chain::owner_authority_history_index, chain::by_account >( + iterate_results( + _db.get_index< chain::owner_authority_history_index, chain::by_account >(), boost::make_tuple( key.first, key.second ), result.owner_auths, args.limit, [&]( const owner_authority_history_object& o ){ return api_owner_authority_history_object( o ); }, - &database_api_impl::filter_default< owner_authority_history_object > ); + &filter_default< owner_authority_history_object > ); return result; } @@ -463,23 +433,25 @@ DEFINE_API_IMPL( database_api_impl, list_account_recovery_requests ) { case( by_account ): { - iterate_results< chain::account_recovery_request_index, chain::by_account >( + iterate_results( + _db.get_index< chain::account_recovery_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, [&]( const account_recovery_request_object& a ){ return api_account_recovery_request_object( a ); }, - &database_api_impl::filter_default< api_account_recovery_request_object > ); + &filter_default< api_account_recovery_request_object > ); break; } case( by_expiration ): { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); - iterate_results< chain::account_recovery_request_index, chain::by_expiration >( + iterate_results( + _db.get_index< chain::account_recovery_request_index, chain::by_expiration >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, [&]( const account_recovery_request_object& a ){ return api_account_recovery_request_object( a ); }, - &database_api_impl::filter_default< api_account_recovery_request_object > ); + &filter_default< api_account_recovery_request_object > ); break; } default: @@ -519,23 +491,25 @@ DEFINE_API_IMPL( database_api_impl, list_change_recovery_account_requests ) { case( by_account ): { - iterate_results< chain::change_recovery_account_request_index, chain::by_account >( + iterate_results( + _db.get_index< chain::change_recovery_account_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, - &database_api_impl::on_push_default< change_recovery_account_request_object >, - &database_api_impl::filter_default< change_recovery_account_request_object > ); + &on_push_default< change_recovery_account_request_object >, + &filter_default< change_recovery_account_request_object > ); break; } case( by_effective_date ): { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); - iterate_results< chain::change_recovery_account_request_index, chain::by_effective_date >( + iterate_results( + _db.get_index< chain::change_recovery_account_request_index, chain::by_effective_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, - &database_api_impl::on_push_default< change_recovery_account_request_object >, - &database_api_impl::filter_default< change_recovery_account_request_object > ); + &on_push_default< change_recovery_account_request_object >, + &filter_default< change_recovery_account_request_object > ); break; } default: @@ -576,24 +550,26 @@ DEFINE_API_IMPL( database_api_impl, list_escrows ) case( by_from_id ): { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); - iterate_results< chain::escrow_index, chain::by_from_id >( + iterate_results( + _db.get_index< chain::escrow_index, chain::by_from_id >(), boost::make_tuple( key.first, key.second ), result.escrows, args.limit, - &database_api_impl::on_push_default< escrow_object >, - &database_api_impl::filter_default< escrow_object > ); + &on_push_default< escrow_object >, + &filter_default< escrow_object > ); break; } case( by_ratification_deadline ): { auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_ratification_deadline start requires 3 values. (bool, time_point_sec, escrow_id_type)" ); - iterate_results< chain::escrow_index, chain::by_ratification_deadline >( + iterate_results( + _db.get_index< chain::escrow_index, chain::by_ratification_deadline >(), boost::make_tuple( key[0].as< bool >(), key[1].as< fc::time_point_sec >(), key[2].as< escrow_id_type >() ), result.escrows, args.limit, - &database_api_impl::on_push_default< escrow_object >, - &database_api_impl::filter_default< escrow_object > ); + &on_push_default< escrow_object >, + &filter_default< escrow_object > ); break; } default: @@ -634,23 +610,25 @@ DEFINE_API_IMPL( database_api_impl, list_withdraw_vesting_routes ) case( by_withdraw_route ): { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); - iterate_results< chain::withdraw_vesting_route_index, chain::by_withdraw_route >( + iterate_results( + _db.get_index< chain::withdraw_vesting_route_index, chain::by_withdraw_route >(), boost::make_tuple( key.first, key.second ), result.routes, args.limit, - &database_api_impl::on_push_default< withdraw_vesting_route_object >, - &database_api_impl::filter_default< withdraw_vesting_route_object > ); + &on_push_default< withdraw_vesting_route_object >, + &filter_default< withdraw_vesting_route_object > ); break; } case( by_destination ): { auto key = args.start.as< std::pair< account_name_type, withdraw_vesting_route_id_type > >(); - iterate_results< chain::withdraw_vesting_route_index, chain::by_destination >( + iterate_results( + _db.get_index< chain::withdraw_vesting_route_index, chain::by_destination >(), boost::make_tuple( key.first, key.second ), result.routes, args.limit, - &database_api_impl::on_push_default< withdraw_vesting_route_object >, - &database_api_impl::filter_default< withdraw_vesting_route_object > ); + &on_push_default< withdraw_vesting_route_object >, + &filter_default< withdraw_vesting_route_object > ); break; } default: @@ -714,36 +692,39 @@ DEFINE_API_IMPL( database_api_impl, list_savings_withdrawals ) case( by_from_id ): { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); - iterate_results< chain::savings_withdraw_index, chain::by_from_rid >( + iterate_results( + _db.get_index< chain::savings_withdraw_index, chain::by_from_rid >(), boost::make_tuple( key.first, key.second ), result.withdrawals, args.limit, [&]( const savings_withdraw_object& w ){ return api_savings_withdraw_object( w ); }, - &database_api_impl::filter_default< savings_withdraw_object > ); + &filter_default< savings_withdraw_object > ); break; } case( by_complete_from_id ): { auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_complete_from_id start requires 3 values. (time_point_sec, account_name_type, uint32_t)" ); - iterate_results< chain::savings_withdraw_index, chain::by_complete_from_rid >( + iterate_results( + _db.get_index< chain::savings_withdraw_index, chain::by_complete_from_rid >(), boost::make_tuple( key[0].as< fc::time_point_sec >(), key[1].as< account_name_type >(), key[2].as< uint32_t >() ), result.withdrawals, args.limit, [&]( const savings_withdraw_object& w ){ return api_savings_withdraw_object( w ); }, - &database_api_impl::filter_default< savings_withdraw_object > ); + &filter_default< savings_withdraw_object > ); break; } case( by_to_complete ): { auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_to_complete start requires 3 values. (account_name_type, time_point_sec, savings_withdraw_id_type" ); - iterate_results< chain::savings_withdraw_index, chain::by_to_complete >( + iterate_results( + _db.get_index< chain::savings_withdraw_index, chain::by_to_complete >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), key[2].as< savings_withdraw_id_type >() ), result.withdrawals, args.limit, [&]( const savings_withdraw_object& w ){ return api_savings_withdraw_object( w ); }, - &database_api_impl::filter_default< savings_withdraw_object > ); + &filter_default< savings_withdraw_object > ); break; } default: @@ -783,12 +764,13 @@ DEFINE_API_IMPL( database_api_impl, list_vesting_delegations ) case( by_delegation ): { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); - iterate_results< chain::vesting_delegation_index, chain::by_delegation >( + iterate_results( + _db.get_index< chain::vesting_delegation_index, chain::by_delegation >(), boost::make_tuple( key.first, key.second ), result.delegations, args.limit, - &database_api_impl::on_push_default< api_vesting_delegation_object >, - &database_api_impl::filter_default< vesting_delegation_object > ); + &on_push_default< api_vesting_delegation_object >, + &filter_default< vesting_delegation_object > ); break; } default: @@ -828,24 +810,26 @@ DEFINE_API_IMPL( database_api_impl, list_vesting_delegation_expirations ) case( by_expiration ): { auto key = args.start.as< std::pair< time_point_sec, vesting_delegation_expiration_id_type > >(); - iterate_results< chain::vesting_delegation_expiration_index, chain::by_expiration >( + iterate_results( + _db.get_index< chain::vesting_delegation_expiration_index, chain::by_expiration >(), boost::make_tuple( key.first, key.second ), result.delegations, args.limit, - &database_api_impl::on_push_default< api_vesting_delegation_expiration_object >, - &database_api_impl::filter_default< vesting_delegation_expiration_object > ); + &on_push_default< api_vesting_delegation_expiration_object >, + &filter_default< vesting_delegation_expiration_object > ); break; } case( by_account_expiration ): { auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_account_expiration start requires 3 values. (account_name_type, time_point_sec, vesting_delegation_expiration_id_type" ); - iterate_results< chain::vesting_delegation_expiration_index, chain::by_account_expiration >( + iterate_results( + _db.get_index< chain::vesting_delegation_expiration_index, chain::by_account_expiration >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< time_point_sec >(), key[2].as< vesting_delegation_expiration_id_type >() ), result.delegations, args.limit, - &database_api_impl::on_push_default< api_vesting_delegation_expiration_object >, - &database_api_impl::filter_default< vesting_delegation_expiration_object > ); + &on_push_default< api_vesting_delegation_expiration_object >, + &filter_default< vesting_delegation_expiration_object > ); break; } default: @@ -885,23 +869,25 @@ DEFINE_API_IMPL( database_api_impl, list_sbd_conversion_requests ) case( by_conversion_date ): { auto key = args.start.as< std::pair< time_point_sec, convert_request_id_type > >(); - iterate_results< chain::convert_request_index, chain::by_conversion_date >( + iterate_results( + _db.get_index< chain::convert_request_index, chain::by_conversion_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, - &database_api_impl::on_push_default< api_convert_request_object >, - &database_api_impl::filter_default< convert_request_object > ); + &on_push_default< api_convert_request_object >, + &filter_default< convert_request_object > ); break; } case( by_account ): { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); - iterate_results< chain::convert_request_index, chain::by_owner >( + iterate_results( + _db.get_index< chain::convert_request_index, chain::by_owner >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, - &database_api_impl::on_push_default< api_convert_request_object >, - &database_api_impl::filter_default< convert_request_object > ); + &on_push_default< api_convert_request_object >, + &filter_default< convert_request_object > ); break; } default: @@ -940,23 +926,25 @@ DEFINE_API_IMPL( database_api_impl, list_decline_voting_rights_requests ) { case( by_account ): { - iterate_results< chain::decline_voting_rights_request_index, chain::by_account >( + iterate_results( + _db.get_index< chain::decline_voting_rights_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, - &database_api_impl::on_push_default< api_decline_voting_rights_request_object >, - &database_api_impl::filter_default< decline_voting_rights_request_object > ); + &on_push_default< api_decline_voting_rights_request_object >, + &filter_default< decline_voting_rights_request_object > ); break; } case( by_effective_date ): { auto key = args.start.as< std::pair< time_point_sec, account_name_type > >(); - iterate_results< chain::decline_voting_rights_request_index, chain::by_effective_date >( + iterate_results( + _db.get_index< chain::decline_voting_rights_request_index, chain::by_effective_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, - &database_api_impl::on_push_default< api_decline_voting_rights_request_object >, - &database_api_impl::filter_default< decline_voting_rights_request_object > ); + &on_push_default< api_decline_voting_rights_request_object >, + &filter_default< decline_voting_rights_request_object > ); break; } default: @@ -1016,23 +1004,25 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) comment_id = comment->id; } - iterate_results< chain::comment_index, chain::by_cashout_time >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_cashout_time >(), boost::make_tuple( key[0].as< fc::time_point_sec >(), comment_id ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } case( by_permlink ): { auto key = args.start.as< std::pair< account_name_type, string > >(); - iterate_results< chain::comment_index, chain::by_permlink >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_permlink >(), boost::make_tuple( key.first, key.second ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } case( by_root ): @@ -1062,12 +1052,13 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) child_id = child->id; } - iterate_results< chain::comment_index, chain::by_root >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_root >(), boost::make_tuple( root_id, child_id ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } case( by_parent ): @@ -1086,12 +1077,13 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) child_id = child->id; } - iterate_results< chain::comment_index, chain::by_parent >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_parent >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< string >(), child_id ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } #ifndef IS_LOW_MEM @@ -1111,12 +1103,13 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) child_id = child->id; } - iterate_results< chain::comment_index, chain::by_last_update >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_last_update >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), child_id ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } case( by_author_last_update ): @@ -1135,12 +1128,13 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) comment_id = comment->id; } - iterate_results< chain::comment_index, chain::by_last_update >( + iterate_results( + _db.get_index< chain::comment_index, chain::by_last_update >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), comment_id ), result.comments, args.limit, [&]( const comment_object& c ){ return api_comment_object( c, _db ); }, - &database_api_impl::filter_default< comment_object > ); + &filter_default< comment_object > ); break; } #endif @@ -1225,21 +1219,23 @@ namespace last_votes_misc if( SORTORDERTYPE == by_comment_voter_symbol ) { - _impl.iterate_results< chain::comment_vote_index, chain::by_comment_voter_symbol >( - boost::make_tuple( comment_id, voter_id ), - c, - limit, - [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _impl._db ); }, - &database_api_impl::filter_default< comment_vote_object > ); + iterate_results( + _impl._db.get_index< chain::comment_vote_index, chain::by_comment_voter_symbol >(), + boost::make_tuple( comment_id, voter_id ), + c, + limit, + [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _impl._db ); }, + &filter_default< comment_vote_object > ); } else if( SORTORDERTYPE == by_voter_comment ) { - _impl.iterate_results< chain::comment_vote_index, chain::by_voter_comment_symbol >( - boost::make_tuple( voter_id, comment_id ), - c, - limit, - [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _impl._db ); }, - &database_api_impl::filter_default< comment_vote_object > ); + iterate_results( + _impl._db.get_index< chain::comment_vote_index, chain::by_voter_comment_symbol >(), + boost::make_tuple( voter_id, comment_id ), + c, + limit, + [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _impl._db ); }, + &filter_default< comment_vote_object > ); } } @@ -1305,12 +1301,13 @@ DEFINE_API_IMPL( database_api_impl, list_votes ) } } - iterate_results< chain::comment_vote_index, chain::by_comment_symbol_voter >( + iterate_results( + _db.get_index< chain::comment_vote_index, chain::by_comment_symbol_voter >(), boost::make_tuple( comment_id, start_symbol, voter_id ), result.votes, args.limit, [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _db ); }, - &database_api_impl::filter_default< comment_vote_object > ); + &filter_default< comment_vote_object > ); break; } case( by_voter_symbol_comment ): @@ -1345,12 +1342,13 @@ DEFINE_API_IMPL( database_api_impl, list_votes ) } } - iterate_results< chain::comment_vote_index, chain::by_voter_symbol_comment >( + iterate_results( + _db.get_index< chain::comment_vote_index, chain::by_voter_symbol_comment >(), boost::make_tuple( voter_id, start_symbol, comment_id ), result.votes, args.limit, [&]( const comment_vote_object& cv ){ return api_comment_vote_object( cv, _db ); }, - &database_api_impl::filter_default< comment_vote_object > ); + &filter_default< comment_vote_object > ); break; } default: @@ -1400,23 +1398,25 @@ DEFINE_API_IMPL( database_api_impl, list_limit_orders ) case( by_price ): { auto key = args.start.as< std::pair< price, limit_order_id_type > >(); - iterate_results< chain::limit_order_index, chain::by_price >( + iterate_results( + _db.get_index< chain::limit_order_index, chain::by_price >(), boost::make_tuple( key.first, key.second ), result.orders, args.limit, - &database_api_impl::on_push_default< api_limit_order_object >, - &database_api_impl::filter_default< limit_order_object > ); + &on_push_default< api_limit_order_object >, + &filter_default< limit_order_object > ); break; } case( by_account ): { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); - iterate_results< chain::limit_order_index, chain::by_account >( + iterate_results( + _db.get_index< chain::limit_order_index, chain::by_account >(), boost::make_tuple( key.first, key.second ), result.orders, args.limit, - &database_api_impl::on_push_default< api_limit_order_object >, - &database_api_impl::filter_default< limit_order_object > ); + &on_push_default< api_limit_order_object >, + &filter_default< limit_order_object > ); break; } default: @@ -1552,52 +1552,56 @@ DEFINE_API_IMPL( database_api_impl, list_proposals ) case by_creator: { auto key = args.start.as< std::pair< account_name_type, api_id_type > >(); - iterate_results< steem::chain::proposal_index, steem::chain::by_creator >( + iterate_results( + _db.get_index< steem::chain::proposal_index, steem::chain::by_creator >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, [&]( const proposal_object& po ){ return api_proposal_object( po, current_time ); }, [&]( const proposal_object& po ){ return filter_proposal_status( po, args.status, current_time ); }, - args.order_direction + args.order_direction == ascending ); break; } case by_start_date: { auto key = args.start.as< std::pair< time_point_sec, api_id_type > >(); - iterate_results< steem::chain::proposal_index, steem::chain::by_start_date >( + iterate_results( + _db.get_index< steem::chain::proposal_index, steem::chain::by_start_date >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, [&]( const proposal_object& po ){ return api_proposal_object( po, current_time ); }, [&]( const proposal_object& po ){ return filter_proposal_status( po, args.status, current_time ); }, - args.order_direction + args.order_direction == ascending ); break; } case by_end_date: { auto key = args.start.as< std::pair< time_point_sec, api_id_type > >(); - iterate_results< steem::chain::proposal_index, steem::chain::by_end_date >( + iterate_results( + _db.get_index< steem::chain::proposal_index, steem::chain::by_end_date >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, [&]( const proposal_object& po ){ return api_proposal_object( po, current_time ); }, [&]( const proposal_object& po ){ return filter_proposal_status( po, args.status, current_time ); }, - args.order_direction + args.order_direction == ascending ); break; } case by_total_votes: { auto key = args.start.as< std::pair< uint64_t, api_id_type > >(); - iterate_results< steem::chain::proposal_index, steem::chain::by_total_votes >( + iterate_results( + _db.get_index< steem::chain::proposal_index, steem::chain::by_total_votes >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, [&]( const proposal_object& po ){ return api_proposal_object( po, current_time ); }, [&]( const proposal_object& po ){ return filter_proposal_status( po, args.status, current_time ); }, - args.order_direction + args.order_direction == ascending ); break; } @@ -1646,7 +1650,8 @@ DEFINE_API_IMPL( database_api_impl, list_proposal_votes ) case by_voter_proposal: { auto key = args.start.as< std::pair< account_name_type, api_id_type > >(); - iterate_results< steem::chain::proposal_vote_index, steem::chain::by_voter_proposal >( + iterate_results( + _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_voter_proposal >(), boost::make_tuple( key.first, key.second ), result.proposal_votes, args.limit, @@ -1656,14 +1661,15 @@ DEFINE_API_IMPL( database_api_impl, list_proposal_votes ) auto itr = _db.find< steem::chain::proposal_object, steem::chain::by_id >( po.proposal_id ); return itr != nullptr && !itr->removed; }, - args.order_direction + args.order_direction == ascending ); break; } case by_proposal_voter: { auto key = args.start.as< std::pair< api_id_type, account_name_type > >(); - iterate_results< steem::chain::proposal_vote_index, steem::chain::by_proposal_voter >( + iterate_results( + _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_proposal_voter >(), boost::make_tuple( key.first, key.second ), result.proposal_votes, args.limit, @@ -1673,7 +1679,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposal_votes ) auto itr = _db.find< steem::chain::proposal_object, steem::chain::by_id >( po.proposal_id ); return itr != nullptr && !itr->removed; }, - args.order_direction + args.order_direction == ascending ); break; } @@ -1852,12 +1858,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) else start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< account_name_type >(), key[ 2 ].as< uint32_t >() ); - iterate_results< chain::smt_contribution_index, chain::by_symbol_contributor >( + iterate_results( + _db.get_index< chain::smt_contribution_index, chain::by_symbol_contributor >(), start, result.contributions, args.limit, - &database_api_impl::on_push_default< chain::smt_contribution_object >, - &database_api_impl::filter_default< chain::smt_contribution_object > ); + &on_push_default< chain::smt_contribution_object >, + &filter_default< chain::smt_contribution_object > ); break; } case( by_symbol_id ): @@ -1871,12 +1878,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) else start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< smt_contribution_object_id_type >() ); - iterate_results< chain::smt_contribution_index, chain::by_symbol_id >( + iterate_results( + _db.get_index< chain::smt_contribution_index, chain::by_symbol_id >(), start, result.contributions, args.limit, - &database_api_impl::on_push_default< chain::smt_contribution_object >, - &database_api_impl::filter_default< chain::smt_contribution_object > ); + &on_push_default< chain::smt_contribution_object >, + &filter_default< chain::smt_contribution_object > ); break; } #ifndef IS_LOW_MEM @@ -1891,12 +1899,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) else start = boost::make_tuple( key[ 0 ].as< account_name_type >(), key[ 1 ].as< asset_symbol_type >(), key[ 2 ].as< uint32_t >() ); - iterate_results< chain::smt_contribution_index, chain::by_contributor >( + iterate_results( + _db.get_index< chain::smt_contribution_index, chain::by_contributor >(), start, result.contributions, args.limit, - &database_api_impl::on_push_default< chain::smt_contribution_object >, - &database_api_impl::filter_default< chain::smt_contribution_object > ); + &on_push_default< chain::smt_contribution_object >, + &filter_default< chain::smt_contribution_object > ); break; } #endif @@ -1944,12 +1953,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_tokens ) start = asset_symbol_type::from_asset_num( args.start.as< asset_symbol_type >().get_stripped_precision_smt_num() ); } - iterate_results< chain::smt_token_index, chain::by_stripped_symbol >( + iterate_results( + _db.get_index< chain::smt_token_index, chain::by_stripped_symbol >(), start, result.tokens, args.limit, [&]( const smt_token_object& t ) { return api_smt_token_object( t, _db ); }, - &database_api_impl::filter_default< chain::smt_token_object > ); + &filter_default< chain::smt_token_object > ); break; } @@ -1969,12 +1979,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_tokens ) start = boost::make_tuple( key[0].as< account_name_type >(), key[1].as< asset_symbol_type >() ); } - iterate_results< chain::smt_token_index, chain::by_control_account >( + iterate_results( + _db.get_index< chain::smt_token_index, chain::by_control_account >(), start, result.tokens, args.limit, [&]( const smt_token_object& t ) { return api_smt_token_object( t, _db ); }, - &database_api_impl::filter_default< chain::smt_token_object > ); + &filter_default< chain::smt_token_object > ); break; } @@ -2024,12 +2035,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_token_emissions ) else start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< time_point_sec >() ); - iterate_results< chain::smt_token_emissions_index, chain::by_symbol_time >( + iterate_results( + _db.get_index< chain::smt_token_emissions_index, chain::by_symbol_time >(), start, result.token_emissions, args.limit, - &database_api_impl::on_push_default< chain::smt_token_emissions_object >, - &database_api_impl::filter_default< chain::smt_token_emissions_object > ); + &on_push_default< chain::smt_token_emissions_object >, + &filter_default< chain::smt_token_emissions_object > ); break; } default: @@ -2096,12 +2108,13 @@ DEFINE_API_IMPL( database_api_impl, list_smt_token_balances ) key[ 0 ].as< account_name_type >(), asset_symbol_type::from_asset_num( key[ 1 ].as< asset_symbol_type >().get_stripped_precision_smt_num() ) ); - iterate_results< chain::account_regular_balance_index, chain::by_name_stripped_symbol >( + iterate_results( + _db.get_index< chain::account_regular_balance_index, chain::by_name_stripped_symbol >(), start, result.balances, args.limit, [&]( const chain::account_regular_balance_object& b ){ return api_smt_account_balance_object( b, _db ); }, - &database_api_impl::filter_default< chain::account_regular_balance_object > ); + &filter_default< chain::account_regular_balance_object > ); break; } default: diff --git a/libraries/plugins/apis/rc_api/CMakeLists.txt b/libraries/plugins/apis/rc_api/CMakeLists.txt index d1a59c8dde..96cc224c98 100644 --- a/libraries/plugins/apis/rc_api/CMakeLists.txt +++ b/libraries/plugins/apis/rc_api/CMakeLists.txt @@ -5,7 +5,7 @@ add_library( rc_api_plugin ${HEADERS} ) -target_link_libraries( rc_api_plugin rc_plugin json_rpc_plugin ) +target_link_libraries( rc_api_plugin rc_plugin database_api_plugin json_rpc_plugin ) target_include_directories( rc_api_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if( CLANG_TIDY_EXE ) diff --git a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp index 99b88551d9..d4950a4943 100644 --- a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp +++ b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp @@ -17,6 +17,20 @@ namespace detail class rc_api_impl; } +enum sort_order_type +{ + by_name, + by_edge, + by_pool +}; + +struct list_object_args_type +{ + fc::variant start; + uint32_t limit; + sort_order_type order; +}; + using plugins::json_rpc::void_type; typedef void_type get_resource_params_args; @@ -40,12 +54,53 @@ struct get_resource_pool_return variant_object resource_pool; }; +struct pool_delegation +{ + steem::chain::util::manabar rc_manabar; + int64_t max_mana = 0; +}; + struct rc_account_api_object { - account_name_type account; + rc_account_api_object( const rc_account_object& rca, const database& db ) : + account( rca.account ), + creator( rca.creator ), + rc_manabar( rca.rc_manabar ), + max_rc_creation_adjustment( rca.max_rc_creation_adjustment ), + vests_delegated_to_pools( rca.vests_delegated_to_pools ), + delegation_slots( rca.indel_slots ), + out_delegation_total( rca.out_delegations ) + { + max_rc = get_maximum_rc( db.get_account( account ), rca ); + + for( const auto& pool : delegation_slots ) + { + pool_delegation del; + + auto indel_edge = db.find< rc_outdel_drc_edge_object, by_edge >( boost::make_tuple( pool, account, VESTS_SYMBOL ) ); + if( indel_edge != nullptr ) + { + del.rc_manabar = indel_edge->drc_manabar; + del.max_mana = indel_edge->drc_max_mana; + } + + incoming_delegations[ pool ] = del; + } + } + + account_name_type account; + account_name_type creator; steem::chain::util::manabar rc_manabar; - asset max_rc_creation_adjustment = asset( 0, VESTS_SYMBOL ); - int64_t max_rc = 0; + asset max_rc_creation_adjustment = asset( 0, VESTS_SYMBOL ); + int64_t max_rc = 0; + asset vests_delegated_to_pools = asset( 0 , VESTS_SYMBOL ); + fc::array< account_name_type, STEEM_RC_MAX_SLOTS > + delegation_slots; + + flat_map< account_name_type, pool_delegation > + incoming_delegations; + + uint32_t out_delegation_total = 0; // // This is used for bug-catching, to match that the vesting shares in a @@ -61,14 +116,50 @@ struct rc_account_api_object struct find_rc_accounts_args { - std::vector< account_name_type > accounts; + std::vector< account_name_type > accounts; }; struct find_rc_accounts_return { - std::vector< rc_account_api_object > rc_accounts; + std::vector< rc_account_api_object > rc_accounts; +}; + +typedef list_object_args_type list_rc_accounts_args; + +typedef find_rc_accounts_return list_rc_accounts_return; + +typedef rc_delegation_pool_object rc_delegation_pool_api_object; + +struct find_rc_delegation_pools_args +{ + std::vector< account_name_type > accounts; +}; + +struct find_rc_delegation_pools_return +{ + std::vector< rc_delegation_pool_api_object > rc_delegation_pools; }; +typedef list_object_args_type list_rc_delegation_pools_args; + +typedef find_rc_delegation_pools_return list_rc_delegation_pools_return; + +typedef rc_indel_edge_object rc_indel_edge_api_object; + +struct find_rc_delegations_args +{ + account_name_type account; +}; + +struct find_rc_delegations_return +{ + std::vector< rc_indel_edge_api_object > rc_delegations; +}; + +typedef list_object_args_type list_rc_delegations_args; + +typedef find_rc_delegations_return list_rc_delegations_return; + class rc_api { public: @@ -79,6 +170,11 @@ class rc_api (get_resource_params) (get_resource_pool) (find_rc_accounts) + (list_rc_accounts) + (find_rc_delegation_pools) + (list_rc_delegation_pools) + (find_rc_delegations) + (list_rc_delegations) ) private: @@ -87,31 +183,55 @@ class rc_api } } } // steem::plugins::rc +FC_REFLECT_ENUM( steem::plugins::rc::sort_order_type, + (by_name) + (by_edge) + (by_pool) ) + +FC_REFLECT( steem::plugins::rc::list_object_args_type, + (start) + (limit) + (order) ) + FC_REFLECT( steem::plugins::rc::get_resource_params_return, (resource_names) (resource_params) - (size_info) - ) + (size_info) ) FC_REFLECT( steem::plugins::rc::resource_pool_api_object, - (pool) - ) + (pool) ) FC_REFLECT( steem::plugins::rc::get_resource_pool_return, - (resource_pool) - ) + (resource_pool) ) + +FC_REFLECT( steem::plugins::rc::pool_delegation, + (rc_manabar) + (max_mana) ) FC_REFLECT( steem::plugins::rc::rc_account_api_object, (account) + (creator) (rc_manabar) (max_rc_creation_adjustment) (max_rc) - ) + (delegation_slots) + (incoming_delegations) + (out_delegation_total) ) FC_REFLECT( steem::plugins::rc::find_rc_accounts_args, - (accounts) - ) + (accounts) ) FC_REFLECT( steem::plugins::rc::find_rc_accounts_return, - (rc_accounts) - ) + (rc_accounts) ) + +FC_REFLECT( steem::plugins::rc::find_rc_delegation_pools_args, + (accounts) ) + +FC_REFLECT( steem::plugins::rc::find_rc_delegation_pools_return, + (rc_delegation_pools) ) + +FC_REFLECT( steem::plugins::rc::find_rc_delegations_args, + (account) ) + +FC_REFLECT( steem::plugins::rc::find_rc_delegations_return, + (rc_delegations) ) diff --git a/libraries/plugins/apis/rc_api/rc_api.cpp b/libraries/plugins/apis/rc_api/rc_api.cpp index 4d11351f06..be8de2a97e 100644 --- a/libraries/plugins/apis/rc_api/rc_api.cpp +++ b/libraries/plugins/apis/rc_api/rc_api.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include #include @@ -13,6 +15,8 @@ namespace steem { namespace plugins { namespace rc { namespace detail { +using namespace database_api::util; + class rc_api_impl { public: @@ -23,6 +27,11 @@ class rc_api_impl (get_resource_params) (get_resource_pool) (find_rc_accounts) + (list_rc_accounts) + (find_rc_delegation_pools) + (list_rc_delegation_pools) + (find_rc_delegations) + (list_rc_delegations) ) chain::database& _db; @@ -80,31 +89,153 @@ DEFINE_API_IMPL( rc_api_impl, get_resource_pool ) DEFINE_API_IMPL( rc_api_impl, find_rc_accounts ) { - find_rc_accounts_return result; - FC_ASSERT( args.accounts.size() <= RC_API_SINGLE_QUERY_LIMIT ); + find_rc_accounts_return result; + result.rc_accounts.reserve( args.accounts.size() ); + for( const account_name_type& a : args.accounts ) { const rc_account_object* rc_account = _db.find< rc_account_object, by_name >( a ); - if( rc_account == nullptr ) - continue; + if( rc_account != nullptr ) + { + result.rc_accounts.emplace_back( *rc_account, _db ); + } + } + + return result; +} + +DEFINE_API_IMPL( rc_api_impl, list_rc_accounts ) +{ + FC_ASSERT( args.limit <= RC_API_SINGLE_QUERY_LIMIT ); + + list_rc_accounts_return result; + result.rc_accounts.reserve( args.limit ); + + switch( args.order ) + { + case( by_name ): + { + iterate_results( + _db.get_index< rc_account_index, by_name >(), + args.start.as< account_name_type >, + result.rc_accounts, + args.limit, + [&]( const rc_account_object& rca ){ return rc_account_api_object( rca, _db ); } + &filter_default< rc_account_object > ); + break; + } + default: + FC_ASSERT( false, "Unknown or unsupported sort order" ); + } +} + +DEFINE_API_IMPL( rc_api_impl, find_rc_delegation_pools ) +{ + FC_ASSERT( args.accounts.size() <= RC_API_SINGLE_QUERY_LIMIT ); - const account_object& account = _db.get< account_object, by_name >( a ); + find_rc_delegation_pools_return result; + result.rc_delegation_pools.reserve( args.accounts.size() ); - rc_account_api_object api_rc_account; - api_rc_account.account = rc_account->account; - api_rc_account.rc_manabar = rc_account->rc_manabar; - api_rc_account.max_rc_creation_adjustment = rc_account->max_rc_creation_adjustment; - api_rc_account.max_rc = get_maximum_rc( account, *rc_account ); + for( const auto& a : args.accounts ) + { + const auto* pool = _db.find< rc_delegation_pool_object, by_account_symbol >( boost::make_tuple( a, VESTS_SYMBOL ) ); - result.rc_accounts.emplace_back( api_rc_account ); + if( pool != nullptr ) + { + result.rc_delegation_pools.push_back( *pool ); + } } return result; } +DEFINE_API_IMPL( rc_api_impl, list_rc_delegation_pools ) +{ + FC_ASSERT( args.limit <= RC_API_SINGLE_QUERY_LIMIT ); + + list_rc_delegation_pools_return result; + result.rc_delegation_pools.reserve( args.limit ); + + switch( args.order ) + { + case( by_name ): + { + iterate_results( + _db.get_index< rc_delegation_pool_index, by_account_symbol >(), + boost::make_tuple( args.start.as< account_name_type >(), VESTS_SYMBOL ), + result.rc_delegation_pools, + args.limit, + &on_push_default< rc_delegation_pool_object > + &filter_default< rc_delegation_pool_object > ); + break; + } + default: + FC_ASSERT( false, "Unknown or unsupported sort order" ); + } +} + +DEFINE_API_IMPL( rc_api_impl, find_rc_delegations ) +{ + static_assert( STEEM_RC_MAX_INDEL <= RC_API_SINGLE_QUERY_LIMIT, "STEEM_RC_MAX_INDEL exceeds RC_API_SINGLE_QUERY_LIMIT" ); + + find_rc_delegations_return result; + result.rc_delegations.reserve( STEEM_RC_MAX_INDEL ); + + const auto& del_idx = _db.get_index< rc_outdel_drc_edge_index, by_edge >(); + + for( auto itr = del_idx.lower_bound( args.account ); itr != del_idx.end() && itr->from_account == args.account; ++itr ) + { + result.rc_delegations.push_back( *itr ); + } + + return result; +} + +DEFINE_API_IMPL( rc_api_impl, list_rc_delegations ) +{ + FC_ASSERT( args.limit <= RC_API_SINGLE_QUERY_LIMIT ); + + list_rc_delegations_return result; + result.rc_delegations.reserve( args.limit ); + + switch( args.order ) + { + case( by_edge ): + { + auto key = args.start.as< vector< fc::variant > >(); + FC_ASSERT( key.size() == 2, "by_edge start requires 2 values. (from_account, pool_name)" ); + + iterate_results( + _db.get_index< rc_outdel_drc_edge_index, by_edge >(), + boost::make_tuple( key[0].as< account_name_type >(), key[1].as< account_name_type >() ), + result.rc_delegations, + args.limit, + &on_push_default< rc_outdel_drc_edge_object > + &filter_default< rc_outdel_drc_edge_object > ); + break; + } + case( by_pool ): + { + auto key = args.start.as< vector< fc::variant > >(); + FC_ASSERT( key.size() == 2, "by_edge start requires 2 values. (from_account, pool_name)" ); + + iterate_results( + _db.get_index< rc_outdel_drc_edge_index, by_pool >(), + boost::make_tuple( key[0].as< account_name_type >(), key[1].as< account_name_type >() ), + result.rc_delegations, + args.limit, + &on_push_default< rc_outdel_drc_edge_object > + &filter_default< rc_outdel_drc_edge_object > ); + break; + } + default: + FC_ASSERT( false, "Unknown or unsupported sort order" ); + } +} + } // detail rc_api::rc_api(): my( new detail::rc_api_impl() ) @@ -118,6 +249,11 @@ DEFINE_READ_APIS( rc_api, (get_resource_params) (get_resource_pool) (find_rc_accounts) + (list_rc_accounts) + (find_rc_delegation_pools) + (list_rc_delegation_pools) + (find_rc_delegations) + (list_rc_delegations) ) } } } // steem::plugins::rc diff --git a/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp b/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp index 3b3d18fa28..596aad2df4 100644 --- a/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp +++ b/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp @@ -287,6 +287,13 @@ typedef multi_index_container< const_mem_fun< rc_indel_edge_object, asset_symbol_type, &rc_indel_edge_object::get_asset_symbol >, member< rc_indel_edge_object, account_name_type, &rc_indel_edge_object::to_pool > > + >, + ordered_unique< tag< by_pool >, + composite_key< rc_indel_edge_object, + member< rc_indel_edge_object, account_name_type, &rc_indel_edge_object::to_pool >, + const_mem_fun< rc_indel_edge_object, asset_symbol_type, &rc_indel_edge_object::get_asset_symbol >, + member< rc_indel_edge_object, account_name_type, &rc_indel_edge_object::from_account > + > > >, allocator< rc_indel_edge_object > From f872dd18e503d2893af57a0c10544950ebacaa81 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Wed, 12 Feb 2020 17:43:55 -0800 Subject: [PATCH 02/10] Add database_api/util to CMake headers --- libraries/plugins/apis/database_api/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/apis/database_api/CMakeLists.txt b/libraries/plugins/apis/database_api/CMakeLists.txt index 7aecf8c3b0..c49c1bb4c3 100644 --- a/libraries/plugins/apis/database_api/CMakeLists.txt +++ b/libraries/plugins/apis/database_api/CMakeLists.txt @@ -1,4 +1,4 @@ -file(GLOB HEADERS "include/steem/plugins/database_api/*.hpp") +file(GLOB HEADERS "include/steem/plugins/database_api/*.hpp" "include/steem/plugins/database_api/util/*.hpp") add_library( database_api_plugin database_api.cpp From 92b23a0f15593fdb402768824f6ada2322566503 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Thu, 13 Feb 2020 12:30:51 -0800 Subject: [PATCH 03/10] Still doesn't build --- libraries/plugins/apis/database_api/CMakeLists.txt | 6 ++++-- .../rc_api/include/steem/plugins/rc_api/rc_api.hpp | 10 +++++++--- libraries/plugins/apis/rc_api/rc_api.cpp | 4 ++-- .../plugins/rc/include/steem/plugins/rc/rc_objects.hpp | 10 +++------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libraries/plugins/apis/database_api/CMakeLists.txt b/libraries/plugins/apis/database_api/CMakeLists.txt index c49c1bb4c3..d5ca0e9571 100644 --- a/libraries/plugins/apis/database_api/CMakeLists.txt +++ b/libraries/plugins/apis/database_api/CMakeLists.txt @@ -8,7 +8,8 @@ add_library( database_api_plugin target_link_libraries( database_api_plugin chain_plugin json_rpc_plugin ) target_include_directories( database_api_plugin - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" ) if( CLANG_TIDY_EXE ) set_target_properties( @@ -17,10 +18,11 @@ if( CLANG_TIDY_EXE ) ) endif( CLANG_TIDY_EXE ) -install( TARGETS +INSTALL( TARGETS database_api_plugin RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) +INSTALL( FILES ${HEADERS} DESTINATION "include/steem/plugins/database_api" ) \ No newline at end of file diff --git a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp index d4950a4943..9d26be687a 100644 --- a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp +++ b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -73,11 +73,15 @@ struct rc_account_api_object { max_rc = get_maximum_rc( db.get_account( account ), rca ); - for( const auto& pool : delegation_slots ) + db.get_index< chain::comment_index, chain::by_permlink >(); // works + db.get_index< rc_outdel_drc_edge_index, by_edge >(); // does not work + db.get_index< rc_outdel_drc_edge_index >().indices().get< by_edge >(); // works + for( const account_name_type& pool : delegation_slots ) { pool_delegation del; - auto indel_edge = db.find< rc_outdel_drc_edge_object, by_edge >( boost::make_tuple( pool, account, VESTS_SYMBOL ) ); + db.get< rc_outdel_drc_edge_object, by_edge >( boost::make_tuple( pool, account, VESTS_SYMBOL ) ); // does not work + auto indel_edge = db.find< rc_outdel_drc_edge_object, by_edge >( boost::make_tuple( pool, account, VESTS_SYMBOL ) ); // does not work if( indel_edge != nullptr ) { del.rc_manabar = indel_edge->drc_manabar; diff --git a/libraries/plugins/apis/rc_api/rc_api.cpp b/libraries/plugins/apis/rc_api/rc_api.cpp index be8de2a97e..361e00d115 100644 --- a/libraries/plugins/apis/rc_api/rc_api.cpp +++ b/libraries/plugins/apis/rc_api/rc_api.cpp @@ -4,10 +4,10 @@ #include #include -#include - #include +#include + #include #include diff --git a/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp b/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp index 596aad2df4..6c2d08d0c4 100644 --- a/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp +++ b/libraries/plugins/rc/include/steem/plugins/rc/rc_objects.hpp @@ -12,15 +12,11 @@ #include -namespace steem { namespace chain { -struct by_account; -} } - namespace steem { namespace plugins { namespace rc { -using namespace std; using namespace steem::chain; -using namespace steem::protocol; +using steem::protocol::asset; +using steem::protocol::asset_symbol_type; #ifndef STEEM_RC_SPACE_ID #define STEEM_RC_SPACE_ID 16 @@ -302,7 +298,7 @@ typedef multi_index_container< typedef multi_index_container< rc_outdel_drc_edge_object, indexed_by< - ordered_unique< tag< by_id >, member< rc_outdel_drc_edge_object, rc_outdel_drc_edge_object::id_type, &rc_outdel_drc_edge_object::id > >, + ordered_unique< tag< by_id >, member< rc_outdel_drc_edge_object, rc_outdel_drc_edge_id_type, &rc_outdel_drc_edge_object::id > >, ordered_unique< tag< by_edge >, composite_key< rc_outdel_drc_edge_object, member< rc_outdel_drc_edge_object, account_name_type, &rc_outdel_drc_edge_object::from_pool >, From d104efdeedbc523bf063c77df6bbc8fe9fcfad1c Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Thu, 13 Feb 2020 13:06:27 -0800 Subject: [PATCH 04/10] Add missing file --- .../database_api/util/iterate_results.hpp | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libraries/plugins/apis/database_api/include/steem/plugins/database_api/util/iterate_results.hpp diff --git a/libraries/plugins/apis/database_api/include/steem/plugins/database_api/util/iterate_results.hpp b/libraries/plugins/apis/database_api/include/steem/plugins/database_api/util/iterate_results.hpp new file mode 100644 index 0000000000..f9b2813955 --- /dev/null +++ b/libraries/plugins/apis/database_api/include/steem/plugins/database_api/util/iterate_results.hpp @@ -0,0 +1,49 @@ +#pragma once + +namespace steem { namespace plugins { namespace database_api { namespace util { + +template< typename ResultType > +static ResultType on_push_default( const ResultType& r ) { return r; } + +template< typename ValueType > +static bool filter_default( const ValueType& r ) { return true; } + +template +void iterate_results( + const IndexType& idx, + StartType start, + std::vector& result, + uint32_t limit, + OnPushType&& on_push, + FilterType&& filter, + bool ascending = true ) +{ + if( ascending ) + { + auto itr = idx.lower_bound( start ); + auto end = idx.end(); + + while( result.size() < limit && itr != end ) + { + if( filter( *itr ) ) + result.push_back( on_push( *itr ) ); + + ++itr; + } + } + else + { + auto itr = boost::make_reverse_iterator( idx.lower_bound( start ) ); + auto end = idx.rend(); + + while( result.size() < limit && itr != end ) + { + if( filter( *itr ) ) + result.push_back( on_push( *itr ) ); + + ++itr; + } + } +} + +} } } } // steem::plugins::database_api::util From 0f8af5c358beda91582e6a9f8e3e52fb7554a148 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Thu, 13 Feb 2020 13:49:49 -0800 Subject: [PATCH 05/10] Fix plugin_test #3610 --- tests/plugin_tests/rc_delegation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugin_tests/rc_delegation.cpp b/tests/plugin_tests/rc_delegation.cpp index f376a7c376..70b254f0f4 100644 --- a/tests/plugin_tests/rc_delegation.cpp +++ b/tests/plugin_tests/rc_delegation.cpp @@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE( rc_drc_pool_consumption ) const auto& gpo = db->get_dynamic_global_properties(); rc_plugin_skip_flags skip {0, 0, 0, 0}; - set< account_name_type > whitelist; + std::set< account_name_type > whitelist; use_account_rcs( *db, gpo, "alice", 100, skip, whitelist ); BOOST_REQUIRE( poola_pool.rc_pool_manabar.current_mana == 50 ); From a065e3a2996e87604f91084c21ce4257f15f46d6 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Thu, 13 Feb 2020 14:09:35 -0800 Subject: [PATCH 06/10] Fix reflection --- .../plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp index 9d26be687a..961b5d46af 100644 --- a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp +++ b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp @@ -218,6 +218,7 @@ FC_REFLECT( steem::plugins::rc::rc_account_api_object, (rc_manabar) (max_rc_creation_adjustment) (max_rc) + (vests_delegated_to_pools) (delegation_slots) (incoming_delegations) (out_delegation_total) ) From 6f67d42b50a0ca138e96c31e82145410e0172594 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Fri, 14 Feb 2020 02:34:32 -0500 Subject: [PATCH 07/10] #3610: Distinguish sort types and struct tags with enum class, cleanup compilation errors --- .../include/steem/plugins/rc_api/rc_api.hpp | 2 +- .../steem/plugins/rc_api/rc_api_plugin.hpp | 2 - libraries/plugins/apis/rc_api/rc_api.cpp | 38 +++++++++++-------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp index 961b5d46af..b348fcee3a 100644 --- a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp +++ b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api.hpp @@ -17,7 +17,7 @@ namespace detail class rc_api_impl; } -enum sort_order_type +enum class sort_order_type { by_name, by_edge, diff --git a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api_plugin.hpp b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api_plugin.hpp index 47f15bbc1d..f000401470 100644 --- a/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api_plugin.hpp +++ b/libraries/plugins/apis/rc_api/include/steem/plugins/rc_api/rc_api_plugin.hpp @@ -10,8 +10,6 @@ namespace steem { namespace plugins { namespace rc { -using namespace appbase; - class rc_api_plugin : public appbase::plugin< rc_api_plugin > { public: diff --git a/libraries/plugins/apis/rc_api/rc_api.cpp b/libraries/plugins/apis/rc_api/rc_api.cpp index 361e00d115..8eccfbc29f 100644 --- a/libraries/plugins/apis/rc_api/rc_api.cpp +++ b/libraries/plugins/apis/rc_api/rc_api.cpp @@ -116,20 +116,22 @@ DEFINE_API_IMPL( rc_api_impl, list_rc_accounts ) switch( args.order ) { - case( by_name ): + case( sort_order_type::by_name ): { iterate_results( _db.get_index< rc_account_index, by_name >(), - args.start.as< account_name_type >, + args.start.as< account_name_type >(), result.rc_accounts, args.limit, - [&]( const rc_account_object& rca ){ return rc_account_api_object( rca, _db ); } + [&]( const rc_account_object& rca ){ return rc_account_api_object( rca, _db ); }, &filter_default< rc_account_object > ); break; } default: FC_ASSERT( false, "Unknown or unsupported sort order" ); } + + return result; } DEFINE_API_IMPL( rc_api_impl, find_rc_delegation_pools ) @@ -161,20 +163,22 @@ DEFINE_API_IMPL( rc_api_impl, list_rc_delegation_pools ) switch( args.order ) { - case( by_name ): + case( sort_order_type::by_name ): { iterate_results( _db.get_index< rc_delegation_pool_index, by_account_symbol >(), boost::make_tuple( args.start.as< account_name_type >(), VESTS_SYMBOL ), result.rc_delegation_pools, args.limit, - &on_push_default< rc_delegation_pool_object > + &on_push_default< rc_delegation_pool_object >, &filter_default< rc_delegation_pool_object > ); break; } default: FC_ASSERT( false, "Unknown or unsupported sort order" ); } + + return result; } DEFINE_API_IMPL( rc_api_impl, find_rc_delegations ) @@ -184,7 +188,7 @@ DEFINE_API_IMPL( rc_api_impl, find_rc_delegations ) find_rc_delegations_return result; result.rc_delegations.reserve( STEEM_RC_MAX_INDEL ); - const auto& del_idx = _db.get_index< rc_outdel_drc_edge_index, by_edge >(); + const auto& del_idx = _db.get_index< rc_indel_edge_index, by_edge >(); for( auto itr = del_idx.lower_bound( args.account ); itr != del_idx.end() && itr->from_account == args.account; ++itr ) { @@ -203,37 +207,39 @@ DEFINE_API_IMPL( rc_api_impl, list_rc_delegations ) switch( args.order ) { - case( by_edge ): + case( sort_order_type::by_edge ): { auto key = args.start.as< vector< fc::variant > >(); FC_ASSERT( key.size() == 2, "by_edge start requires 2 values. (from_account, pool_name)" ); iterate_results( - _db.get_index< rc_outdel_drc_edge_index, by_edge >(), - boost::make_tuple( key[0].as< account_name_type >(), key[1].as< account_name_type >() ), + _db.get_index< rc_indel_edge_index, by_edge >(), + boost::make_tuple( key[0].as< account_name_type >(), asset_symbol_type(), key[1].as< account_name_type >() ), result.rc_delegations, args.limit, - &on_push_default< rc_outdel_drc_edge_object > - &filter_default< rc_outdel_drc_edge_object > ); + &on_push_default< rc_indel_edge_object >, + &filter_default< rc_indel_edge_object > ); break; } - case( by_pool ): + case( sort_order_type::by_pool ): { auto key = args.start.as< vector< fc::variant > >(); FC_ASSERT( key.size() == 2, "by_edge start requires 2 values. (from_account, pool_name)" ); iterate_results( - _db.get_index< rc_outdel_drc_edge_index, by_pool >(), - boost::make_tuple( key[0].as< account_name_type >(), key[1].as< account_name_type >() ), + _db.get_index< rc_indel_edge_index, by_pool >(), + boost::make_tuple( key[0].as< account_name_type >(), asset_symbol_type(), key[1].as< account_name_type >() ), result.rc_delegations, args.limit, - &on_push_default< rc_outdel_drc_edge_object > - &filter_default< rc_outdel_drc_edge_object > ); + &on_push_default< rc_indel_edge_object >, + &filter_default< rc_indel_edge_object > ); break; } default: FC_ASSERT( false, "Unknown or unsupported sort order" ); } + + return result; } } // detail From bac18e37e99970805320586aa1b87ce47867e58b Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Fri, 14 Feb 2020 17:17:16 -0800 Subject: [PATCH 08/10] iFix rc_api --- libraries/plugins/apis/rc_api/rc_api.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/plugins/apis/rc_api/rc_api.cpp b/libraries/plugins/apis/rc_api/rc_api.cpp index 8eccfbc29f..993a1210ca 100644 --- a/libraries/plugins/apis/rc_api/rc_api.cpp +++ b/libraries/plugins/apis/rc_api/rc_api.cpp @@ -214,11 +214,11 @@ DEFINE_API_IMPL( rc_api_impl, list_rc_delegations ) iterate_results( _db.get_index< rc_indel_edge_index, by_edge >(), - boost::make_tuple( key[0].as< account_name_type >(), asset_symbol_type(), key[1].as< account_name_type >() ), + boost::make_tuple( key[0].as< account_name_type >(), VESTS_SYMBOL, key[1].as< account_name_type >() ), result.rc_delegations, args.limit, - &on_push_default< rc_indel_edge_object >, - &filter_default< rc_indel_edge_object > ); + &on_push_default< rc_indel_edge_api_object >, + &filter_default< rc_indel_edge_api_object > ); break; } case( sort_order_type::by_pool ): @@ -228,11 +228,11 @@ DEFINE_API_IMPL( rc_api_impl, list_rc_delegations ) iterate_results( _db.get_index< rc_indel_edge_index, by_pool >(), - boost::make_tuple( key[0].as< account_name_type >(), asset_symbol_type(), key[1].as< account_name_type >() ), + boost::make_tuple( key[0].as< account_name_type >(), VESTS_SYMBOL, key[1].as< account_name_type >() ), result.rc_delegations, args.limit, - &on_push_default< rc_indel_edge_object >, - &filter_default< rc_indel_edge_object > ); + &on_push_default< rc_indel_edge_api_object >, + &filter_default< rc_indel_edge_api_object > ); break; } default: From 86d0cb688113736ea54b3beb7240f8c2ba9f5317 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Tue, 18 Feb 2020 15:02:04 -0500 Subject: [PATCH 09/10] #3610: Remove commented code --- libraries/plugins/apis/database_api/database_api.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/plugins/apis/database_api/database_api.cpp b/libraries/plugins/apis/database_api/database_api.cpp index cb42bb07b7..d195f3d3e6 100644 --- a/libraries/plugins/apis/database_api/database_api.cpp +++ b/libraries/plugins/apis/database_api/database_api.cpp @@ -20,10 +20,6 @@ namespace steem { namespace plugins { namespace database_api { using namespace util; -//using util::iterate_results; -//using util::filter_default; -//using util::on_push_default; - class database_api_impl { public: From e4e50bb9b15d8991b38d803066f13c87aa53b0b5 Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Tue, 18 Feb 2020 15:08:24 -0500 Subject: [PATCH 10/10] #3610: Fix whitespace formatting issues --- .../apis/database_api/database_api.cpp | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/libraries/plugins/apis/database_api/database_api.cpp b/libraries/plugins/apis/database_api/database_api.cpp index d195f3d3e6..a1c069d088 100644 --- a/libraries/plugins/apis/database_api/database_api.cpp +++ b/libraries/plugins/apis/database_api/database_api.cpp @@ -194,7 +194,7 @@ DEFINE_API_IMPL( database_api_impl, list_witnesses ) case( by_name ): { iterate_results( - _db.get_index< chain::witness_index, chain::by_name >(), + _db.get_index< chain::witness_index, chain::by_name >(), args.start.as< protocol::account_name_type >(), result.witnesses, args.limit, @@ -206,7 +206,7 @@ DEFINE_API_IMPL( database_api_impl, list_witnesses ) { auto key = args.start.as< std::pair< share_type, account_name_type > >(); iterate_results( - _db.get_index< chain::witness_index, chain::by_vote_name >(), + _db.get_index< chain::witness_index, chain::by_vote_name >(), boost::make_tuple( key.first, key.second ), result.witnesses, args.limit, @@ -219,7 +219,7 @@ DEFINE_API_IMPL( database_api_impl, list_witnesses ) auto key = args.start.as< std::pair< fc::uint128, account_name_type > >(); auto wit_id = _db.get< chain::witness_object, chain::by_name >( key.second ).id; iterate_results( - _db.get_index< chain::witness_index, chain::by_schedule_time >(), + _db.get_index< chain::witness_index, chain::by_schedule_time >(), boost::make_tuple( key.first, wit_id ), result.witnesses, args.limit, @@ -264,7 +264,7 @@ DEFINE_API_IMPL( database_api_impl, list_witness_votes ) { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); iterate_results( - _db.get_index< chain::witness_vote_index, chain::by_account_witness >(), + _db.get_index< chain::witness_vote_index, chain::by_account_witness >(), boost::make_tuple( key.first, key.second ), result.votes, args.limit, @@ -276,7 +276,7 @@ DEFINE_API_IMPL( database_api_impl, list_witness_votes ) { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); iterate_results( - _db.get_index< chain::witness_vote_index, chain::by_witness_account >(), + _db.get_index< chain::witness_vote_index, chain::by_witness_account >(), boost::make_tuple( key.first, key.second ), result.votes, args.limit, @@ -323,7 +323,7 @@ DEFINE_API_IMPL( database_api_impl, list_accounts ) case( by_name ): { iterate_results( - _db.get_index< chain::account_index, chain::by_name >(), + _db.get_index< chain::account_index, chain::by_name >(), args.start.as< protocol::account_name_type >(), result.accounts, args.limit, @@ -335,7 +335,7 @@ DEFINE_API_IMPL( database_api_impl, list_accounts ) { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); iterate_results( - _db.get_index< chain::account_index, chain::by_proxy >(), + _db.get_index< chain::account_index, chain::by_proxy >(), boost::make_tuple( key.first, key.second ), result.accounts, args.limit, @@ -347,7 +347,7 @@ DEFINE_API_IMPL( database_api_impl, list_accounts ) { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); iterate_results( - _db.get_index< chain::account_index, chain::by_next_vesting_withdrawal >(), + _db.get_index< chain::account_index, chain::by_next_vesting_withdrawal >(), boost::make_tuple( key.first, key.second ), result.accounts, args.limit, @@ -430,7 +430,7 @@ DEFINE_API_IMPL( database_api_impl, list_account_recovery_requests ) case( by_account ): { iterate_results( - _db.get_index< chain::account_recovery_request_index, chain::by_account >(), + _db.get_index< chain::account_recovery_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, @@ -442,7 +442,7 @@ DEFINE_API_IMPL( database_api_impl, list_account_recovery_requests ) { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); iterate_results( - _db.get_index< chain::account_recovery_request_index, chain::by_expiration >(), + _db.get_index< chain::account_recovery_request_index, chain::by_expiration >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, @@ -488,7 +488,7 @@ DEFINE_API_IMPL( database_api_impl, list_change_recovery_account_requests ) case( by_account ): { iterate_results( - _db.get_index< chain::change_recovery_account_request_index, chain::by_account >(), + _db.get_index< chain::change_recovery_account_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, @@ -500,7 +500,7 @@ DEFINE_API_IMPL( database_api_impl, list_change_recovery_account_requests ) { auto key = args.start.as< std::pair< fc::time_point_sec, account_name_type > >(); iterate_results( - _db.get_index< chain::change_recovery_account_request_index, chain::by_effective_date >(), + _db.get_index< chain::change_recovery_account_request_index, chain::by_effective_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, @@ -547,7 +547,7 @@ DEFINE_API_IMPL( database_api_impl, list_escrows ) { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); iterate_results( - _db.get_index< chain::escrow_index, chain::by_from_id >(), + _db.get_index< chain::escrow_index, chain::by_from_id >(), boost::make_tuple( key.first, key.second ), result.escrows, args.limit, @@ -560,7 +560,7 @@ DEFINE_API_IMPL( database_api_impl, list_escrows ) auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_ratification_deadline start requires 3 values. (bool, time_point_sec, escrow_id_type)" ); iterate_results( - _db.get_index< chain::escrow_index, chain::by_ratification_deadline >(), + _db.get_index< chain::escrow_index, chain::by_ratification_deadline >(), boost::make_tuple( key[0].as< bool >(), key[1].as< fc::time_point_sec >(), key[2].as< escrow_id_type >() ), result.escrows, args.limit, @@ -607,7 +607,7 @@ DEFINE_API_IMPL( database_api_impl, list_withdraw_vesting_routes ) { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); iterate_results( - _db.get_index< chain::withdraw_vesting_route_index, chain::by_withdraw_route >(), + _db.get_index< chain::withdraw_vesting_route_index, chain::by_withdraw_route >(), boost::make_tuple( key.first, key.second ), result.routes, args.limit, @@ -619,7 +619,7 @@ DEFINE_API_IMPL( database_api_impl, list_withdraw_vesting_routes ) { auto key = args.start.as< std::pair< account_name_type, withdraw_vesting_route_id_type > >(); iterate_results( - _db.get_index< chain::withdraw_vesting_route_index, chain::by_destination >(), + _db.get_index< chain::withdraw_vesting_route_index, chain::by_destination >(), boost::make_tuple( key.first, key.second ), result.routes, args.limit, @@ -689,7 +689,7 @@ DEFINE_API_IMPL( database_api_impl, list_savings_withdrawals ) { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); iterate_results( - _db.get_index< chain::savings_withdraw_index, chain::by_from_rid >(), + _db.get_index< chain::savings_withdraw_index, chain::by_from_rid >(), boost::make_tuple( key.first, key.second ), result.withdrawals, args.limit, @@ -702,7 +702,7 @@ DEFINE_API_IMPL( database_api_impl, list_savings_withdrawals ) auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_complete_from_id start requires 3 values. (time_point_sec, account_name_type, uint32_t)" ); iterate_results( - _db.get_index< chain::savings_withdraw_index, chain::by_complete_from_rid >(), + _db.get_index< chain::savings_withdraw_index, chain::by_complete_from_rid >(), boost::make_tuple( key[0].as< fc::time_point_sec >(), key[1].as< account_name_type >(), key[2].as< uint32_t >() ), result.withdrawals, args.limit, @@ -715,7 +715,7 @@ DEFINE_API_IMPL( database_api_impl, list_savings_withdrawals ) auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_to_complete start requires 3 values. (account_name_type, time_point_sec, savings_withdraw_id_type" ); iterate_results( - _db.get_index< chain::savings_withdraw_index, chain::by_to_complete >(), + _db.get_index< chain::savings_withdraw_index, chain::by_to_complete >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), key[2].as< savings_withdraw_id_type >() ), result.withdrawals, args.limit, @@ -761,7 +761,7 @@ DEFINE_API_IMPL( database_api_impl, list_vesting_delegations ) { auto key = args.start.as< std::pair< account_name_type, account_name_type > >(); iterate_results( - _db.get_index< chain::vesting_delegation_index, chain::by_delegation >(), + _db.get_index< chain::vesting_delegation_index, chain::by_delegation >(), boost::make_tuple( key.first, key.second ), result.delegations, args.limit, @@ -807,7 +807,7 @@ DEFINE_API_IMPL( database_api_impl, list_vesting_delegation_expirations ) { auto key = args.start.as< std::pair< time_point_sec, vesting_delegation_expiration_id_type > >(); iterate_results( - _db.get_index< chain::vesting_delegation_expiration_index, chain::by_expiration >(), + _db.get_index< chain::vesting_delegation_expiration_index, chain::by_expiration >(), boost::make_tuple( key.first, key.second ), result.delegations, args.limit, @@ -820,7 +820,7 @@ DEFINE_API_IMPL( database_api_impl, list_vesting_delegation_expirations ) auto key = args.start.as< std::vector< fc::variant > >(); FC_ASSERT( key.size() == 3, "by_account_expiration start requires 3 values. (account_name_type, time_point_sec, vesting_delegation_expiration_id_type" ); iterate_results( - _db.get_index< chain::vesting_delegation_expiration_index, chain::by_account_expiration >(), + _db.get_index< chain::vesting_delegation_expiration_index, chain::by_account_expiration >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< time_point_sec >(), key[2].as< vesting_delegation_expiration_id_type >() ), result.delegations, args.limit, @@ -866,7 +866,7 @@ DEFINE_API_IMPL( database_api_impl, list_sbd_conversion_requests ) { auto key = args.start.as< std::pair< time_point_sec, convert_request_id_type > >(); iterate_results( - _db.get_index< chain::convert_request_index, chain::by_conversion_date >(), + _db.get_index< chain::convert_request_index, chain::by_conversion_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, @@ -878,7 +878,7 @@ DEFINE_API_IMPL( database_api_impl, list_sbd_conversion_requests ) { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); iterate_results( - _db.get_index< chain::convert_request_index, chain::by_owner >(), + _db.get_index< chain::convert_request_index, chain::by_owner >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, @@ -923,7 +923,7 @@ DEFINE_API_IMPL( database_api_impl, list_decline_voting_rights_requests ) case( by_account ): { iterate_results( - _db.get_index< chain::decline_voting_rights_request_index, chain::by_account >(), + _db.get_index< chain::decline_voting_rights_request_index, chain::by_account >(), args.start.as< account_name_type >(), result.requests, args.limit, @@ -935,7 +935,7 @@ DEFINE_API_IMPL( database_api_impl, list_decline_voting_rights_requests ) { auto key = args.start.as< std::pair< time_point_sec, account_name_type > >(); iterate_results( - _db.get_index< chain::decline_voting_rights_request_index, chain::by_effective_date >(), + _db.get_index< chain::decline_voting_rights_request_index, chain::by_effective_date >(), boost::make_tuple( key.first, key.second ), result.requests, args.limit, @@ -1001,7 +1001,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) } iterate_results( - _db.get_index< chain::comment_index, chain::by_cashout_time >(), + _db.get_index< chain::comment_index, chain::by_cashout_time >(), boost::make_tuple( key[0].as< fc::time_point_sec >(), comment_id ), result.comments, args.limit, @@ -1013,7 +1013,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) { auto key = args.start.as< std::pair< account_name_type, string > >(); iterate_results( - _db.get_index< chain::comment_index, chain::by_permlink >(), + _db.get_index< chain::comment_index, chain::by_permlink >(), boost::make_tuple( key.first, key.second ), result.comments, args.limit, @@ -1049,7 +1049,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) } iterate_results( - _db.get_index< chain::comment_index, chain::by_root >(), + _db.get_index< chain::comment_index, chain::by_root >(), boost::make_tuple( root_id, child_id ), result.comments, args.limit, @@ -1074,7 +1074,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) } iterate_results( - _db.get_index< chain::comment_index, chain::by_parent >(), + _db.get_index< chain::comment_index, chain::by_parent >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< string >(), child_id ), result.comments, args.limit, @@ -1100,7 +1100,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) } iterate_results( - _db.get_index< chain::comment_index, chain::by_last_update >(), + _db.get_index< chain::comment_index, chain::by_last_update >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), child_id ), result.comments, args.limit, @@ -1125,7 +1125,7 @@ DEFINE_API_IMPL( database_api_impl, list_comments ) } iterate_results( - _db.get_index< chain::comment_index, chain::by_last_update >(), + _db.get_index< chain::comment_index, chain::by_last_update >(), boost::make_tuple( key[0].as< account_name_type >(), key[1].as< fc::time_point_sec >(), comment_id ), result.comments, args.limit, @@ -1298,7 +1298,7 @@ DEFINE_API_IMPL( database_api_impl, list_votes ) } iterate_results( - _db.get_index< chain::comment_vote_index, chain::by_comment_symbol_voter >(), + _db.get_index< chain::comment_vote_index, chain::by_comment_symbol_voter >(), boost::make_tuple( comment_id, start_symbol, voter_id ), result.votes, args.limit, @@ -1339,7 +1339,7 @@ DEFINE_API_IMPL( database_api_impl, list_votes ) } iterate_results( - _db.get_index< chain::comment_vote_index, chain::by_voter_symbol_comment >(), + _db.get_index< chain::comment_vote_index, chain::by_voter_symbol_comment >(), boost::make_tuple( voter_id, start_symbol, comment_id ), result.votes, args.limit, @@ -1395,7 +1395,7 @@ DEFINE_API_IMPL( database_api_impl, list_limit_orders ) { auto key = args.start.as< std::pair< price, limit_order_id_type > >(); iterate_results( - _db.get_index< chain::limit_order_index, chain::by_price >(), + _db.get_index< chain::limit_order_index, chain::by_price >(), boost::make_tuple( key.first, key.second ), result.orders, args.limit, @@ -1407,7 +1407,7 @@ DEFINE_API_IMPL( database_api_impl, list_limit_orders ) { auto key = args.start.as< std::pair< account_name_type, uint32_t > >(); iterate_results( - _db.get_index< chain::limit_order_index, chain::by_account >(), + _db.get_index< chain::limit_order_index, chain::by_account >(), boost::make_tuple( key.first, key.second ), result.orders, args.limit, @@ -1549,7 +1549,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposals ) { auto key = args.start.as< std::pair< account_name_type, api_id_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_index, steem::chain::by_creator >(), + _db.get_index< steem::chain::proposal_index, steem::chain::by_creator >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, @@ -1563,7 +1563,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposals ) { auto key = args.start.as< std::pair< time_point_sec, api_id_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_index, steem::chain::by_start_date >(), + _db.get_index< steem::chain::proposal_index, steem::chain::by_start_date >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, @@ -1577,7 +1577,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposals ) { auto key = args.start.as< std::pair< time_point_sec, api_id_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_index, steem::chain::by_end_date >(), + _db.get_index< steem::chain::proposal_index, steem::chain::by_end_date >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, @@ -1591,7 +1591,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposals ) { auto key = args.start.as< std::pair< uint64_t, api_id_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_index, steem::chain::by_total_votes >(), + _db.get_index< steem::chain::proposal_index, steem::chain::by_total_votes >(), boost::make_tuple( key.first, key.second ), result.proposals, args.limit, @@ -1647,7 +1647,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposal_votes ) { auto key = args.start.as< std::pair< account_name_type, api_id_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_voter_proposal >(), + _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_voter_proposal >(), boost::make_tuple( key.first, key.second ), result.proposal_votes, args.limit, @@ -1665,7 +1665,7 @@ DEFINE_API_IMPL( database_api_impl, list_proposal_votes ) { auto key = args.start.as< std::pair< api_id_type, account_name_type > >(); iterate_results( - _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_proposal_voter >(), + _db.get_index< steem::chain::proposal_vote_index, steem::chain::by_proposal_voter >(), boost::make_tuple( key.first, key.second ), result.proposal_votes, args.limit, @@ -1855,7 +1855,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< account_name_type >(), key[ 2 ].as< uint32_t >() ); iterate_results( - _db.get_index< chain::smt_contribution_index, chain::by_symbol_contributor >(), + _db.get_index< chain::smt_contribution_index, chain::by_symbol_contributor >(), start, result.contributions, args.limit, @@ -1875,7 +1875,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< smt_contribution_object_id_type >() ); iterate_results( - _db.get_index< chain::smt_contribution_index, chain::by_symbol_id >(), + _db.get_index< chain::smt_contribution_index, chain::by_symbol_id >(), start, result.contributions, args.limit, @@ -1896,7 +1896,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_contributions ) start = boost::make_tuple( key[ 0 ].as< account_name_type >(), key[ 1 ].as< asset_symbol_type >(), key[ 2 ].as< uint32_t >() ); iterate_results( - _db.get_index< chain::smt_contribution_index, chain::by_contributor >(), + _db.get_index< chain::smt_contribution_index, chain::by_contributor >(), start, result.contributions, args.limit, @@ -1950,7 +1950,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_tokens ) } iterate_results( - _db.get_index< chain::smt_token_index, chain::by_stripped_symbol >(), + _db.get_index< chain::smt_token_index, chain::by_stripped_symbol >(), start, result.tokens, args.limit, @@ -1976,7 +1976,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_tokens ) } iterate_results( - _db.get_index< chain::smt_token_index, chain::by_control_account >(), + _db.get_index< chain::smt_token_index, chain::by_control_account >(), start, result.tokens, args.limit, @@ -2032,7 +2032,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_token_emissions ) start = boost::make_tuple( key[ 0 ].as< asset_symbol_type >(), key[ 1 ].as< time_point_sec >() ); iterate_results( - _db.get_index< chain::smt_token_emissions_index, chain::by_symbol_time >(), + _db.get_index< chain::smt_token_emissions_index, chain::by_symbol_time >(), start, result.token_emissions, args.limit, @@ -2105,7 +2105,7 @@ DEFINE_API_IMPL( database_api_impl, list_smt_token_balances ) asset_symbol_type::from_asset_num( key[ 1 ].as< asset_symbol_type >().get_stripped_precision_smt_num() ) ); iterate_results( - _db.get_index< chain::account_regular_balance_index, chain::by_name_stripped_symbol >(), + _db.get_index< chain::account_regular_balance_index, chain::by_name_stripped_symbol >(), start, result.balances, args.limit,