@@ -445,94 +445,6 @@ vector<optional<account_object>> database_api_impl::get_accounts( const vector<s
445445 return result;
446446}
447447
448- vector<limit_order_object> database_api::get_account_limit_orders (
449- const string& account_name_or_id, const string &base, const string "e,
450- uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price )
451- {
452- return my->get_account_limit_orders ( account_name_or_id, base, quote, limit, ostart_id, ostart_price );
453- }
454-
455- vector<limit_order_object> database_api_impl::get_account_limit_orders (
456- const string& account_name_or_id, const string &base, const string "e,
457- uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price )
458- {
459- FC_ASSERT ( limit <= 101 );
460-
461- vector<limit_order_object> results;
462- uint32_t count = 0 ;
463-
464- const account_object* account = get_account_from_string (account_name_or_id);
465- if (account == nullptr )
466- return results;
467-
468- auto assets = lookup_asset_symbols ( {base, quote} );
469- FC_ASSERT ( assets[0 ], " Invalid base asset symbol: ${s}" , (" s" ,base) );
470- FC_ASSERT ( assets[1 ], " Invalid quote asset symbol: ${s}" , (" s" ,quote) );
471-
472- auto base_id = assets[0 ]->id ;
473- auto quote_id = assets[1 ]->id ;
474-
475- if (ostart_price.valid ()) {
476- FC_ASSERT (ostart_price->base .asset_id == base_id, " Base asset inconsistent with start price" );
477- FC_ASSERT (ostart_price->quote .asset_id == quote_id, " Quote asset inconsistent with start price" );
478- }
479-
480- const auto & index_by_account = _db.get_index_type <limit_order_index>().indices ().get <by_account>();
481- limit_order_multi_index_type::index<by_account>::type::const_iterator lower_itr;
482- limit_order_multi_index_type::index<by_account>::type::const_iterator upper_itr;
483-
484- // if both order_id and price are invalid, query the first page
485- if ( !ostart_id.valid () && !ostart_price.valid () )
486- {
487- lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , price::max (base_id, quote_id)));
488- }
489- else if ( ostart_id.valid () )
490- {
491- // in case of the order been deleted during page querying
492- const limit_order_object *p_loo = _db.find (*ostart_id);
493-
494- if ( !p_loo )
495- {
496- if ( ostart_price.valid () )
497- {
498- lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , *ostart_price, *ostart_id));
499- }
500- else
501- {
502- // start order id been deleted, yet not provided price either
503- FC_THROW (" Order id invalid (maybe just been canceled?), and start price not provided" );
504- }
505- }
506- else
507- {
508- const limit_order_object &loo = *p_loo;
509-
510- // in case of the order not belongs to specified account or market
511- FC_ASSERT (loo.sell_price .base .asset_id == base_id, " Order base asset inconsistent" );
512- FC_ASSERT (loo.sell_price .quote .asset_id == quote_id, " Order quote asset inconsistent with order" );
513- FC_ASSERT (loo.seller == account->get_id (), " Order not owned by specified account" );
514-
515- lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , loo.sell_price , *ostart_id));
516- }
517- }
518- else
519- {
520- // if reach here start_price must be valid
521- lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , *ostart_price));
522- }
523-
524- upper_itr = index_by_account.upper_bound (std::make_tuple (account->id , price::min (base_id, quote_id)));
525-
526- // Add the account's orders
527- for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count)
528- {
529- const limit_order_object &order = *lower_itr;
530- results.emplace_back (order);
531- }
532-
533- return results;
534- }
535-
536448std::map<string,full_account> database_api::get_full_accounts ( const vector<string>& names_or_ids,
537449 optional<bool > subscribe )
538450{
@@ -1062,6 +974,94 @@ vector<limit_order_object> database_api_impl::get_limit_orders( const std::strin
1062974 return get_limit_orders (asset_a_id, asset_b_id, limit);
1063975}
1064976
977+ vector<limit_order_object> database_api::get_account_limit_orders (
978+ const string& account_name_or_id, const string &base, const string "e,
979+ uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price )
980+ {
981+ return my->get_account_limit_orders ( account_name_or_id, base, quote, limit, ostart_id, ostart_price );
982+ }
983+
984+ vector<limit_order_object> database_api_impl::get_account_limit_orders (
985+ const string& account_name_or_id, const string &base, const string "e,
986+ uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price )
987+ {
988+ FC_ASSERT ( limit <= 101 );
989+
990+ vector<limit_order_object> results;
991+ uint32_t count = 0 ;
992+
993+ const account_object* account = get_account_from_string (account_name_or_id);
994+ if (account == nullptr )
995+ return results;
996+
997+ auto assets = lookup_asset_symbols ( {base, quote} );
998+ FC_ASSERT ( assets[0 ], " Invalid base asset symbol: ${s}" , (" s" ,base) );
999+ FC_ASSERT ( assets[1 ], " Invalid quote asset symbol: ${s}" , (" s" ,quote) );
1000+
1001+ auto base_id = assets[0 ]->id ;
1002+ auto quote_id = assets[1 ]->id ;
1003+
1004+ if (ostart_price.valid ()) {
1005+ FC_ASSERT (ostart_price->base .asset_id == base_id, " Base asset inconsistent with start price" );
1006+ FC_ASSERT (ostart_price->quote .asset_id == quote_id, " Quote asset inconsistent with start price" );
1007+ }
1008+
1009+ const auto & index_by_account = _db.get_index_type <limit_order_index>().indices ().get <by_account>();
1010+ limit_order_multi_index_type::index<by_account>::type::const_iterator lower_itr;
1011+ limit_order_multi_index_type::index<by_account>::type::const_iterator upper_itr;
1012+
1013+ // if both order_id and price are invalid, query the first page
1014+ if ( !ostart_id.valid () && !ostart_price.valid () )
1015+ {
1016+ lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , price::max (base_id, quote_id)));
1017+ }
1018+ else if ( ostart_id.valid () )
1019+ {
1020+ // in case of the order been deleted during page querying
1021+ const limit_order_object *p_loo = _db.find (*ostart_id);
1022+
1023+ if ( !p_loo )
1024+ {
1025+ if ( ostart_price.valid () )
1026+ {
1027+ lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , *ostart_price, *ostart_id));
1028+ }
1029+ else
1030+ {
1031+ // start order id been deleted, yet not provided price either
1032+ FC_THROW (" Order id invalid (maybe just been canceled?), and start price not provided" );
1033+ }
1034+ }
1035+ else
1036+ {
1037+ const limit_order_object &loo = *p_loo;
1038+
1039+ // in case of the order not belongs to specified account or market
1040+ FC_ASSERT (loo.sell_price .base .asset_id == base_id, " Order base asset inconsistent" );
1041+ FC_ASSERT (loo.sell_price .quote .asset_id == quote_id, " Order quote asset inconsistent with order" );
1042+ FC_ASSERT (loo.seller == account->get_id (), " Order not owned by specified account" );
1043+
1044+ lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , loo.sell_price , *ostart_id));
1045+ }
1046+ }
1047+ else
1048+ {
1049+ // if reach here start_price must be valid
1050+ lower_itr = index_by_account.lower_bound (std::make_tuple (account->id , *ostart_price));
1051+ }
1052+
1053+ upper_itr = index_by_account.upper_bound (std::make_tuple (account->id , price::min (base_id, quote_id)));
1054+
1055+ // Add the account's orders
1056+ for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count)
1057+ {
1058+ const limit_order_object &order = *lower_itr;
1059+ results.emplace_back (order);
1060+ }
1061+
1062+ return results;
1063+ }
1064+
10651065vector<call_order_object> database_api::get_call_orders (const std::string& a, uint32_t limit)const
10661066{
10671067 return my->get_call_orders ( a, limit );
0 commit comments