-
Notifications
You must be signed in to change notification settings - Fork 649
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
add api calls to get non expired withdrawls #657
Changes from 2 commits
d822ebe
2677dfb
845eb37
f52bdc5
bd7e7a4
a34d4bd
06f574e
de1ca7d
d4fa8d0
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 |
---|---|---|
|
@@ -154,6 +154,10 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl> | |
// Blinded balances | ||
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const; | ||
|
||
// Withdrawals | ||
vector<withdraw_permission_object> get_withdrawals_giver(account_id_type account, object_id_type start, uint32_t limit)const; | ||
vector<withdraw_permission_object> get_withdrawals_recipient(account_id_type account, object_id_type start, uint32_t limit)const; | ||
|
||
|
||
//private: | ||
static string price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ); | ||
|
@@ -2051,6 +2055,50 @@ vector<blinded_balance_object> database_api_impl::get_blinded_balances( const fl | |
return result; | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// // | ||
// Withdrawals // | ||
// // | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
vector<withdraw_permission_object> database_api::get_withdrawals_giver(account_id_type account, object_id_type start, uint32_t limit)const | ||
{ | ||
return my->get_withdrawals_giver( account, start, limit ); | ||
} | ||
|
||
vector<withdraw_permission_object> database_api_impl::get_withdrawals_giver(account_id_type account, object_id_type start, uint32_t limit)const | ||
{ | ||
FC_ASSERT( limit <= 100 ); | ||
vector<withdraw_permission_object> result; | ||
|
||
auto withdraw_itr = _db.get_index_type<withdraw_permission_index>().indices().get<by_from>().lower_bound(boost::make_tuple(account, start)); | ||
while( withdraw_itr->withdraw_from_account == account && result.size() < limit) | ||
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. Need to check for 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. added end of index check at 845eb37 for some reason i cant do
so i had to code that twice, as far as i remember i never saw the issue in other indexes. |
||
{ | ||
result.push_back(*withdraw_itr); | ||
++withdraw_itr; | ||
} | ||
return result; | ||
} | ||
|
||
vector<withdraw_permission_object> database_api::get_withdrawals_recipient(account_id_type account, object_id_type start, uint32_t limit)const | ||
{ | ||
return my->get_withdrawals_recipient( account, start, limit ); | ||
} | ||
|
||
vector<withdraw_permission_object> database_api_impl::get_withdrawals_recipient(account_id_type account, object_id_type start, uint32_t limit)const | ||
{ | ||
FC_ASSERT( limit <= 100 ); | ||
vector<withdraw_permission_object> result; | ||
|
||
auto withdraw_itr = _db.get_index_type<withdraw_permission_index>().indices().get<by_authorized>().lower_bound(boost::make_tuple(account, start)); | ||
while( withdraw_itr->authorized_account == account && result.size() < limit) | ||
{ | ||
result.push_back(*withdraw_itr); | ||
++withdraw_itr; | ||
} | ||
return result; | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// // | ||
// Private methods // | ||
|
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.
Perhaps use
upper_bound
for pagination, otherwise we will have effectively 99 rows per page, which will impact performance somehow.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.
make sense change to
upper_bound
but i had to add a special case to be able to retrieve first object. this will not make too much sense in the live change as 1.12.0 is already gone but as i am in a private testnet i think the right thing is to consider it.