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

The database API is huge, messy and inconsistent #338

Closed
theoreticalbts opened this issue Sep 24, 2015 · 1 comment
Closed

The database API is huge, messy and inconsistent #338

theoreticalbts opened this issue Sep 24, 2015 · 1 comment

Comments

@theoreticalbts
Copy link
Contributor

Problems in the database API:

(1) vector<optional<account_object>> get_accounts(const vector<account_id_type>& account_ids)const;
(2) vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
(3) vector<optional<asset_object>> lookup_asset_symbols(const vector<string>& symbols_or_ids)const;

Accounts have different functions (1)-(2) to get accounts.
Assets have a single function (3) which accepts symbols or stringified ID's.

(4) optional<account_object> get_account_by_name( string name )const;

Accounts have a function (4) to get a single account by name, everything else uses vectors.

(5) std::map<string,full_account> get_full_accounts( const vector<string>& names_or_ids, bool subscribe );

get_full_accounts (5) gets the account object and associated objects, nothing else has anything similar. It would
be useful to have other queries which fetch an object and all related objects, e.g. given a BitAsset,
fetch the asset object, BitAsset data structure, and the asset object for the base asset.

(6) vector<asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const;
(7) vector<call_order_object> get_call_orders(asset_id_type a, uint32_t limit)const;
(8) map<string, witness_id_type> lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const;

Methods (6), (7), and (8) do the same thing but have different names.

(9) vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const;
(10) vector<call_order_object> get_call_orders(asset_id_type a, uint32_t limit)const;
(11) vector<force_settlement_object> get_settle_orders(asset_id_type a, uint32_t limit)const;

Methods (9), (10), and (11) have no way to request later pages. Furthermore, on reading the code,
the limits are not enforced by some of these methods.

(12) * @param limit Maximum number of results to return -- must not exceed 1000
(13) * @param limit Maximum number of assets to fetch (must not exceed 100)

Maximum number of things to query should be consistent and enforced. We
may want to provide local wrappers for methods which return iterators, possibly
with latency hiding (e.g. instead of having it block for the whole round trip
when you reach the end of the iterator, instead have it send off the request
for the next page when the iterator reaches the halfway point of the current
page).

The database API needs to be refactored, broken apart into multiple simpler API's. The sections in database_api.hpp could conceivably be separately implemented (although we need some kind of union API to make them all accessible to clients under API ID 0).

@theoreticalbts theoreticalbts added this to the Graphene 15.4 milestone Sep 24, 2015
@theoreticalbts theoreticalbts modified the milestones: Graphene 16.1, Graphene 15.4 Jan 4, 2016
@dnotestein dnotestein modified the milestones: FutureRelease, Graphene 16.1 Feb 23, 2016
@vikramrajkumar
Copy link
Contributor

This issue was moved to bitshares/bitshares-core#95

pmconrad added a commit to pmconrad/graphene that referenced this issue Jul 29, 2017
pmconrad added a commit to pmconrad/graphene that referenced this issue Dec 22, 2017
pmconrad pushed a commit to pmconrad/graphene that referenced this issue Jan 11, 2018
pmconrad pushed a commit to pmconrad/graphene that referenced this issue Apr 17, 2018
For:
* cryptonomex#338 Margin call order fills at price of matching limit_order
* cryptonomex#343 Inconsistent sorting of call orders between matching against a limit order and a force settle order
* cryptonomex#453 Multiple limit order and call order matching issue
* cryptonomex#606 Undercollateralized short positions should be called regardless of asks
pmconrad pushed a commit to pmconrad/graphene that referenced this issue Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants