-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#463, Add API to query for open orders of one account in one market #849
Changes from 1 commit
0d1d389
205d389
466e150
fca8cbf
352817f
a102db8
8f41ab0
4c1fd77
59b5b1b
ec7ef61
1e0c369
50b6d62
7e67682
a5077e8
fc0fc1d
cbc4d05
7f18c59
5ff8fea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -646,13 +646,13 @@ vector<limit_order_object> database_api_impl::get_account_limit_orders( const st | |
account = _db.find(fc::variant(name_or_id, 1).as<account_id_type>(1)); | ||
else | ||
{ | ||
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>(); | ||
auto itr = idx.find(name_or_id); | ||
if (itr != idx.end()) | ||
account = &*itr; | ||
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>(); | ||
auto itr = idx.find(name_or_id); | ||
if (itr != idx.end()) | ||
account = &*itr; | ||
} | ||
if (account == nullptr) | ||
return results; | ||
return results; | ||
|
||
auto assets = lookup_asset_symbols( {base, quote} ); | ||
FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); | ||
|
@@ -662,8 +662,8 @@ vector<limit_order_object> database_api_impl::get_account_limit_orders( const st | |
auto quote_id = assets[1]->id; | ||
|
||
if (ostart_price.valid()) { | ||
FC_ASSERT(ostart_price->base.asset_id == base_id, "Base asset inconsistent with start price"); | ||
FC_ASSERT(ostart_price->quote.asset_id == quote_id, "Quote asset inconsistent with start price"); | ||
FC_ASSERT(ostart_price->base.asset_id == base_id, "Base asset inconsistent with start price"); | ||
FC_ASSERT(ostart_price->quote.asset_id == quote_id, "Quote asset inconsistent with start price"); | ||
} | ||
|
||
const auto& index_by_account = _db.get_index_type<limit_order_index>().indices().get<by_account>(); | ||
|
@@ -680,12 +680,13 @@ vector<limit_order_object> database_api_impl::get_account_limit_orders( const st | |
{ | ||
// in case of the order been deleted during page querying | ||
const limit_order_object *p_loo = _db.find(*ostart_id); | ||
upper_itr = index_by_account.upper_bound(std::make_tuple(account->id, price::min(base_id, quote_id))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change slightly reduced performance under certain circumstances :) Before this change, if an exception is thrown due to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. performance reduction means if run into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
|
||
if ( !p_loo ) | ||
{ | ||
if ( ostart_price.valid() ) | ||
{ | ||
lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, *ostart_price, *ostart_id)); | ||
upper_itr = index_by_account.upper_bound(std::make_tuple(account->id, ostart_price->min())); | ||
} | ||
else | ||
{ | ||
|
@@ -703,7 +704,6 @@ vector<limit_order_object> database_api_impl::get_account_limit_orders( const st | |
FC_ASSERT(loo.seller == account->get_id(), "Order not owned by specified account"); | ||
|
||
lower_itr = index_by_account.lower_bound(std::make_tuple(account->id, loo.sell_price, *ostart_id)); | ||
upper_itr = index_by_account.upper_bound(std::make_tuple(account->id, loo.sell_price.min())); | ||
} | ||
} | ||
else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the best place to check whether the start price is consistent with
base
andquote
parameters. If not, IMHO best to throw out an exception.