Skip to content
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

Use configured limit as API page size if omitted #2622

Merged
merged 3 commits into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,8 @@ namespace graphene { namespace app {
{
FC_ASSERT( _app.get_options().has_market_history_plugin, "Market history plugin is not enabled." );

uint32_t limit = olimit.valid() ? *olimit
: application_options::get_default().api_limit_get_liquidity_pool_history;

const auto configured_limit = _app.get_options().api_limit_get_liquidity_pool_history;
uint32_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down
12 changes: 5 additions & 7 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,18 +1035,17 @@ vector<limit_order_object> database_api_impl::get_limit_orders( const std::strin
}

vector<limit_order_object> database_api::get_limit_orders_by_account( const string& account_name_or_id,
optional<uint32_t> limit, optional<limit_order_id_type> start_id )
const optional<uint32_t>& limit, const optional<limit_order_id_type>& start_id )
{
return my->get_limit_orders_by_account( account_name_or_id, limit, start_id );
}

vector<limit_order_object> database_api_impl::get_limit_orders_by_account( const string& account_name_or_id,
optional<uint32_t> olimit, optional<limit_order_id_type> ostart_id )
const optional<uint32_t>& olimit, const optional<limit_order_id_type>& ostart_id )
{
uint32_t limit = olimit.valid() ? *olimit : 101;

FC_ASSERT( _app_options, "Internal error" );
const auto configured_limit = _app_options->api_limit_get_limit_orders_by_account;
uint32_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down Expand Up @@ -1777,8 +1776,8 @@ vector<extended_liquidity_pool_object> database_api_impl::get_liquidity_pools_by
FC_ASSERT( _app_options && _app_options->has_api_helper_indexes_plugin,
"api_helper_indexes plugin is not enabled on this server." );

uint32_t limit = olimit.valid() ? *olimit : application_options::get_default().api_limit_get_liquidity_pools;
const auto configured_limit = _app_options->api_limit_get_liquidity_pools;
uint32_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down Expand Up @@ -1935,10 +1934,9 @@ vector<extended_liquidity_pool_object> database_api_impl::get_liquidity_pools_by
const optional<asset_id_type>& ostart_id,
const optional<bool>& with_statistics )const
{
uint32_t limit = olimit.valid() ? *olimit : application_options::get_default().api_limit_get_liquidity_pools;

FC_ASSERT( _app_options, "Internal error" );
const auto configured_limit = _app_options->api_limit_get_liquidity_pools;
uint32_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down
3 changes: 1 addition & 2 deletions libraries/app/database_api_helper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ public:
const optional<OBJ_ID_TYPE>& ostart_id,
X... x ) const
{
uint64_t limit = olimit.valid() ? *olimit : ( application_options::get_default().*app_opt_member_ptr );

FC_ASSERT( _app_options, "Internal error" );
const auto configured_limit = _app_options->*app_opt_member_ptr;
uint64_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down
7 changes: 3 additions & 4 deletions libraries/app/database_api_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector<limit_order_object> get_limit_orders( const std::string& a, const std::string& b,
uint32_t limit)const;
vector<limit_order_object> get_limit_orders_by_account( const string& account_name_or_id,
optional<uint32_t> limit,
optional<limit_order_id_type> start_id );
const optional<uint32_t>& limit,
const optional<limit_order_id_type>& start_id );
vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
const string &base,
const string &quote, uint32_t limit,
Expand Down Expand Up @@ -278,10 +278,9 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
const optional<bool>& with_statistics,
X... x )const
{
uint32_t limit = olimit.valid() ? *olimit : application_options::get_default().api_limit_get_liquidity_pools;

FC_ASSERT( _app_options, "Internal error" );
const auto configured_limit = _app_options->api_limit_get_liquidity_pools;
uint32_t limit = olimit.valid() ? *olimit : configured_limit;
FC_ASSERT( limit <= configured_limit,
"limit can not be greater than ${configured_limit}",
("configured_limit", configured_limit) );
Expand Down
38 changes: 18 additions & 20 deletions libraries/app/include/graphene/app/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ namespace graphene { namespace app {
* If specified, only the operations occurred not later than this time will be returned.
* @param stop A UNIX timestamp. Optional.
* If specified, only the operations occurred later than this time will be returned.
* @param limit Maximum quantity of operations in the history to retrieve. Optional.
* If not specified, the default value of
* @ref application_options::api_limit_get_liquidity_pool_history will be used.
* @param limit Maximum quantity of operations in the history to retrieve. Optional.
* If not specified, the configured value of
* @a api_limit_get_liquidity_pool_history will be used.
* If specified, it must not exceed the configured value of
* @a api_limit_get_liquidity_pool_history.
* @param operation_type Optional. If specified, only the operations whose type is the specified type
Expand All @@ -223,15 +223,14 @@ namespace graphene { namespace app {
* the most recent records, the rest records can be retrieved with the
* @ref get_liquidity_pool_history_by_sequence API.
* 3. List of operation type code: 59-creation, 60-deletion, 61-deposit, 62-withdrawal, 63-exchange.
* 4. Can only omit one or more arguments in the end of the list, but not one or more in the middle.
* If need to not specify an individual argument, can specify \c null in the place.
* 4. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<liquidity_pool_history_object> get_liquidity_pool_history(
liquidity_pool_id_type pool_id,
const optional<fc::time_point_sec>& start = optional<fc::time_point_sec>(),
const optional<fc::time_point_sec>& stop = optional<fc::time_point_sec>(),
const optional<uint32_t>& limit = application_options::get_default()
.api_limit_get_liquidity_pool_history,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<int64_t>& operation_type = optional<int64_t>() )const;

/**
Expand All @@ -241,9 +240,9 @@ namespace graphene { namespace app {
* If specified, only the operations whose sequences are not greater than this will be returned.
* @param stop A UNIX timestamp. Optional.
* If specified, only operations occurred later than this time will be returned.
* @param limit Maximum quantity of operations in the history to retrieve. Optional.
* If not specified, the default value of
* @ref application_options::api_limit_get_liquidity_pool_history will be used.
* @param limit Maximum quantity of operations in the history to retrieve. Optional.
* If not specified, the configured value of
* @a api_limit_get_liquidity_pool_history will be used.
* If specified, it must not exceed the configured value of
* @a api_limit_get_liquidity_pool_history.
* @param operation_type Optional. If specified, only the operations whose type is the specified type
Expand All @@ -253,15 +252,14 @@ namespace graphene { namespace app {
* @note
* 1. The time must be UTC. The range is (stop, start].
* 2. List of operation type code: 59-creation, 60-deletion, 61-deposit, 62-withdrawal, 63-exchange.
* 3. Can only omit one or more arguments in the end of the list, but not one or more in the middle.
* If need to not specify an individual argument, can specify \c null in the place.
* 3. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<liquidity_pool_history_object> get_liquidity_pool_history_by_sequence(
liquidity_pool_id_type pool_id,
const optional<uint64_t>& start = optional<uint64_t>(),
const optional<fc::time_point_sec>& stop = optional<fc::time_point_sec>(),
const optional<uint32_t>& limit = application_options::get_default()
.api_limit_get_liquidity_pool_history,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<int64_t>& operation_type = optional<int64_t>() )const;

private:
Expand Down Expand Up @@ -624,7 +622,7 @@ namespace graphene { namespace app {
* @param catalog The catalog to get info from. Each account can store data in multiple catalogs. Optional.
* @param key The key to get info from. Each catalog can contain multiple keys. Optional.
* @param limit The limitation of items each query can fetch, not greater than the configured value of
* @a api_limit_get_storage_info
* @a api_limit_get_storage_info. Optional.
* @param start_id Start ID of stored object, fetch objects whose IDs are greater than or equal to this ID
* @return The stored objects found, sorted by their ID
*
Expand All @@ -639,17 +637,17 @@ namespace graphene { namespace app {
* f) unconditionally.
* Queries with keys without a catalog are not allowed.
* 2. If @p account_name_or_id is specified but cannot be tied to an account, an error will be returned.
* 3. @p limit can be omitted or be @a null, if so the default value of
* @ref application_options::api_limit_get_tickets will be used.
* 3. @p limit can be omitted or be @a null, if so the configured value of
* @a api_limit_get_storage_info will be used.
* 4. @p start_id can be omitted or be @a null, if so the API will return the "first page" of objects.
* 5. One or more parameters can be omitted from the end of the parameter list, and the parameters in the
* middle cannot be omitted (but can be @a null).
* 5. One or more optional parameters can be omitted from the end of the parameter list, and the optional
* parameters in the middle cannot be omitted (but can be @a null).
*/
vector<account_storage_object> get_storage_info(
const optional<std::string>& account_name_or_id = optional<std::string>(),
const optional<std::string>& catalog = optional<std::string>(),
const optional<std::string>& key = optional<std::string>(),
const optional<uint32_t>& limit = application_options::get_default().api_limit_get_storage_info,
const optional<uint32_t>& limit = optional<uint32_t>(),
const optional<account_storage_id_type>& start_id = optional<account_storage_id_type>() )const;

private:
Expand Down
Loading