BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
database_api_impl.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <fc/bloom_filter.hpp>
27 #include "database_api_helper.hxx"
28 
29 #define GET_REQUIRED_FEES_MAX_RECURSION 4
30 
31 namespace graphene { namespace app {
32 
33 using market_queue_type = std::map< std::pair<graphene::chain::asset_id_type, graphene::chain::asset_id_type>,
34  std::vector<fc::variant> >;
35 
36 class database_api_impl : public std::enable_shared_from_this<database_api_impl>, public database_api_helper
37 {
38  public:
40  virtual ~database_api_impl();
41 
42  // Objects
43  fc::variants get_objects( const vector<object_id_type>& ids, optional<bool> subscribe )const;
44 
45  // Subscriptions
46  void set_subscribe_callback( std::function<void(const variant&)> cb, bool notify_remove_create );
47  void set_auto_subscription( bool enable );
48  void set_pending_transaction_callback( std::function<void(const variant&)> cb );
49  void set_block_applied_callback( std::function<void(const variant& block_id)> cb );
50  void cancel_all_subscriptions(bool reset_callback, bool reset_market_subscriptions);
51 
52  // Blocks and transactions
53  optional<maybe_signed_block_header> get_block_header( uint32_t block_num, bool with_witness_signature )const;
54  map<uint32_t, optional<maybe_signed_block_header>> get_block_header_batch(
55  const vector<uint32_t>& block_nums, bool with_witness_signatures )const;
56  optional<signed_block> get_block(uint32_t block_num)const;
57  processed_transaction get_transaction( uint32_t block_num, uint32_t trx_in_block )const;
58 
59  // Globals
65  object_id_type get_next_object_id( uint8_t space_id, uint8_t type_id, bool with_pending_transactions )const;
66 
67  // Keys
68  vector<flat_set<account_id_type>> get_key_references( vector<public_key_type> key )const;
69  bool is_public_key_registered(string public_key) const;
70 
71  // Accounts
72  vector<optional<account_object>> get_accounts( const vector<std::string>& account_names_or_ids,
73  optional<bool> subscribe )const;
74  map<string, full_account, std::less<>> get_full_accounts( const vector<string>& names_or_ids,
75  const optional<bool>& subscribe );
76  vector<account_statistics_object> get_top_voters(uint32_t limit)const;
77  optional<account_object> get_account_by_name( string name )const;
78  vector<account_id_type> get_account_references( const std::string account_id_or_name )const;
79  vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
80  map<string, account_id_type, std::less<>> lookup_accounts( const string& lower_bound_name,
81  uint32_t limit,
82  const optional<bool>& subscribe )const;
83  uint64_t get_account_count()const;
84 
85  // Balances
86  vector<asset> get_account_balances( const std::string& account_name_or_id,
87  const flat_set<asset_id_type>& assets )const;
88  vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
89  vector<balance_object> get_balance_objects( const vector<address>& addrs )const;
90  vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
91  vector<vesting_balance_object> get_vesting_balances( const std::string account_id_or_name )const;
92 
93  // Assets
94  uint64_t get_asset_count()const;
95  vector<optional<extended_asset_object>> get_assets( const vector<std::string>& asset_symbols_or_ids,
96  optional<bool> subscribe )const;
97  vector<extended_asset_object> list_assets(const string& lower_bound_symbol, uint32_t limit)const;
98  vector<optional<extended_asset_object>> lookup_asset_symbols(const vector<string>& symbols_or_ids)const;
99  vector<extended_asset_object> get_assets_by_issuer(const std::string& issuer_name_or_id,
100  asset_id_type start, uint32_t limit)const;
101 
102  // Markets / feeds
103  vector<limit_order_object> get_limit_orders( const std::string& a, const std::string& b,
104  uint32_t limit)const;
105  vector<limit_order_object> get_limit_orders_by_account( const string& account_name_or_id,
106  const optional<uint32_t>& limit,
107  const optional<limit_order_id_type>& start_id );
108  vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
109  const string &base,
110  const string &quote, uint32_t limit,
111  optional<limit_order_id_type> ostart_id,
112  optional<price> ostart_price );
113  vector<call_order_object> get_call_orders(const std::string& a, uint32_t limit)const;
114  vector<call_order_object> get_call_orders_by_account(const std::string& account_name_or_id,
115  asset_id_type start, uint32_t limit)const;
116  vector<force_settlement_object> get_settle_orders(const std::string& a, uint32_t limit)const;
117  vector<force_settlement_object> get_settle_orders_by_account(const std::string& account_name_or_id,
118  force_settlement_id_type start,
119  uint32_t limit)const;
120  vector<collateral_bid_object> get_collateral_bids( const std::string& asset,
121  uint32_t limit, uint32_t start)const;
122 
123  void subscribe_to_market( std::function<void(const variant&)> callback,
124  const std::string& a, const std::string& b );
125  void unsubscribe_from_market(const std::string& a, const std::string& b);
126 
127  market_ticker get_ticker( const string& base, const string& quote,
128  bool skip_order_book = false )const;
129  market_volume get_24_volume( const string& base, const string& quote )const;
130  order_book get_order_book( const string& base, const string& quote,
131  uint32_t limit )const;
132  vector<market_ticker> get_top_markets( uint32_t limit )const;
133  vector<market_trade> get_trade_history( const string& base, const string& quote,
135  uint32_t limit )const;
136  vector<market_trade> get_trade_history_by_sequence( const string& base, const string& quote,
137  int64_t start, fc::time_point_sec stop,
138  uint32_t limit )const;
139 
140  // Liquidity pools
141  vector<extended_liquidity_pool_object> get_liquidity_pools_by_one_asset(
142  const std::string& asset_symbol_or_id,
143  const optional<uint32_t>& limit,
144  const optional<liquidity_pool_id_type>& start_id,
145  const optional<bool>& with_statistics )const;
146  vector<optional<extended_liquidity_pool_object>> get_liquidity_pools(
147  const vector<liquidity_pool_id_type>& ids,
148  const optional<bool>& subscribe,
149  const optional<bool>& with_statistics )const;
150  vector<optional<extended_liquidity_pool_object>> get_liquidity_pools_by_share_asset(
151  const vector<std::string>& asset_symbols_or_ids,
152  const optional<bool>& subscribe,
153  const optional<bool>& with_statistics )const;
154  vector<extended_liquidity_pool_object> get_liquidity_pools_by_owner(
155  const std::string& account_name_or_id,
156  const optional<uint32_t>& limit,
157  const optional<asset_id_type>& start_id,
158  const optional<bool>& with_statistics )const;
159 
160  // Witnesses
161  vector<optional<witness_object>> get_witnesses(const vector<witness_id_type>& witness_ids)const;
162  fc::optional<witness_object> get_witness_by_account(const std::string& account_id_or_name)const;
163  map<string, witness_id_type, std::less<>> lookup_witness_accounts(
164  const string& lower_bound_name, uint32_t limit )const;
165  uint64_t get_witness_count()const;
166 
167  // Committee members
168  vector<optional<committee_member_object>> get_committee_members(
169  const vector<committee_member_id_type>& committee_member_ids )const;
171  const std::string& account_id_or_name )const;
172  map<string, committee_member_id_type, std::less<>> lookup_committee_member_accounts(
173  const string& lower_bound_name, uint32_t limit )const;
174  uint64_t get_committee_count()const;
175 
176  // Workers
177  vector<worker_object> get_all_workers( const optional<bool>& is_expired )const;
178  vector<worker_object> get_workers_by_account(const std::string& account_id_or_name)const;
179  uint64_t get_worker_count()const;
180 
181  // Votes
182  vector<variant> lookup_vote_ids( const vector<vote_id_type>& votes )const;
183 
184  // Authority / validation
185  std::string get_transaction_hex(const signed_transaction& trx)const;
186  std::string get_transaction_hex_without_sig(const transaction& trx)const;
187 
188  set<public_key_type> get_required_signatures( const signed_transaction& trx,
189  const flat_set<public_key_type>& available_keys )const;
190  set<public_key_type> get_potential_signatures( const signed_transaction& trx )const;
191  set<address> get_potential_address_signatures( const signed_transaction& trx )const;
192  bool verify_authority( const signed_transaction& trx )const;
193  bool verify_account_authority( const string& account_name_or_id,
194  const flat_set<public_key_type>& signers )const;
195  processed_transaction validate_transaction( const signed_transaction& trx )const;
196  vector< fc::variant > get_required_fees( const vector<operation>& ops,
197  const std::string& asset_id_or_symbol )const;
198 
199  // Proposed transactions
200  vector<proposal_object> get_proposed_transactions( const std::string account_id_or_name )const;
201 
202  // Blinded balances
203  vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
204 
205  // Withdrawals
206  vector<withdraw_permission_object> get_withdraw_permissions_by_giver( const std::string account_id_or_name,
207  withdraw_permission_id_type start,
208  uint32_t limit )const;
209  vector<withdraw_permission_object> get_withdraw_permissions_by_recipient( const std::string account_id_or_name,
210  withdraw_permission_id_type start,
211  uint32_t limit )const;
212 
213  // HTLC
214  optional<htlc_object> get_htlc( htlc_id_type id, optional<bool> subscribe ) const;
215  vector<htlc_object> get_htlc_by_from( const std::string account_id_or_name,
216  htlc_id_type start, uint32_t limit ) const;
217  vector<htlc_object> get_htlc_by_to( const std::string account_id_or_name,
218  htlc_id_type start, uint32_t limit) const;
219  vector<htlc_object> list_htlcs(const htlc_id_type lower_bound_id, uint32_t limit) const;
220 
221  //private:
222 
224  // Accounts
226 
228  // Assets
230 
231  template<class ASSET>
233  {
234  asset_id_type id = a.get_id();
235  extended_asset_object result = extended_asset_object( std::forward<ASSET>( a ) );
237  {
239  if( result.bitasset_data_id.valid() )
241  }
242  return result;
243  }
244 
245  // helper function
246  vector<optional<extended_asset_object>> get_assets( const vector<asset_id_type>& asset_ids,
247  optional<bool> subscribe = optional<bool>() )const;
248 
250  // Markets
252 
253  // helper function
254  vector<limit_order_object> get_limit_orders( const asset_id_type a, const asset_id_type b,
255  const uint32_t limit )const;
256 
258  // Liquidity pools
260 
261  template<class LP>
263  {
264  liquidity_pool_id_type id = a.get_id();
265  extended_liquidity_pool_object result = extended_liquidity_pool_object( std::forward<LP>( a ) );
266  if( with_stats && _app_options && _app_options->has_market_history_plugin )
267  {
268  liquidity_pool_ticker_id_type ticker_id( id.instance );
269  const liquidity_pool_ticker_object* ticker = _db.find( ticker_id );
270  if( ticker )
271  result.statistics = *ticker;
272  }
273  return result;
274  }
275 
276  // template function to reduce duplicate code
277  template <typename INDEX_TAG, typename... X>
278  vector<extended_liquidity_pool_object> get_liquidity_pools_by_asset_x(
279  const optional<uint32_t>& olimit,
280  const optional<liquidity_pool_id_type>& ostart_id,
281  const optional<bool>& with_statistics,
282  X... x )const
283  {
284  FC_ASSERT( _app_options, "Internal error" );
285  const auto configured_limit = _app_options->api_limit_get_liquidity_pools;
286  uint32_t limit = olimit.valid() ? *olimit : configured_limit;
287  FC_ASSERT( limit <= configured_limit,
288  "limit can not be greater than ${configured_limit}",
289  ("configured_limit", configured_limit) );
290 
291  bool with_stats = ( with_statistics.valid() && *with_statistics );
292 
293  vector<extended_liquidity_pool_object> results;
294 
295  liquidity_pool_id_type start_pool_id = ostart_id.valid() ? *ostart_id : liquidity_pool_id_type();
296  object_id_type start_id { start_pool_id };
297 
298  const auto& idx = _db.get_index_type<liquidity_pool_index>().indices().get<INDEX_TAG>();
299 
300  auto lower_itr = idx.lower_bound( make_tuple_if_multiple( x..., start_id ) );
301  auto upper_itr = call_end_or_upper_bound( idx, x... );
302 
303  results.reserve( limit );
304  for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr )
305  {
306  results.emplace_back( extend_liquidity_pool( *lower_itr, with_stats ) );
307  }
308 
309  return results;
310  }
311 
313  // Subscription
315 
316  // Decides whether to subscribe using member variables and given parameter
317  bool get_whether_to_subscribe( optional<bool> subscribe )const
318  {
319  if( !_subscribe_callback )
320  return false;
321  if( subscribe.valid() )
322  return *subscribe;
324  }
325 
326  // Note:
327  // Different type of object_id<T> objects could become identical after packed.
328  // For example, both `account_id_type a=1.2.0` and `asset_id_type b=1.3.0` will become `0` after packed.
329  // In order to avoid collision, we don't use a template function here, instead, we implicitly convert all
330  // object IDs to `object_id_type` when subscribing.
331  //
332  // If need to subscribe to other data types, override this function with the types as parameter.
333  // For example, we had a `get_subscription_key( const public_key_type& item )` function here, which was
334  // removed lately since we no longer subscribe to public keys.
335  vector<char> get_subscription_key( const object_id_type& item )const
336  {
337  return fc::raw::pack(item);
338  }
339 
340  template<typename T>
341  void subscribe_to_item( const T& item )const
342  {
343  if( !_subscribe_callback )
344  return;
345 
346  vector<char> key = get_subscription_key( object_id_type(item) );
347  if( !_subscribe_filter.contains( key.data(), key.size() ) )
348  {
349  _subscribe_filter.insert( key.data(), key.size() );
350  }
351  }
352 
353  template<typename T>
354  bool is_subscribed_to_item( const T& item )const
355  {
356  if( !_subscribe_callback )
357  return false;
358 
359  vector<char> key = get_subscription_key( object_id_type(item) );
360  return _subscribe_filter.contains( key.data(), key.size() );
361  }
362 
363  // for full-account subscription
364  bool is_impacted_account( const flat_set<account_id_type>& accounts );
365 
366  // for market subscription
367  template<typename T>
368  const std::pair<asset_id_type,asset_id_type> get_order_market( const T& order )
369  {
370  return order.get_market();
371  }
372 
373  // for market subscription
374  const std::pair<asset_id_type,asset_id_type> get_order_market( const force_settlement_object& order )
375  {
376  // TODO cache the result to avoid repeatly fetching from db
377  asset_id_type backing_id = order.balance.asset_id( _db ).bitasset_data( _db ).options.short_backing_asset;
378  auto tmp = std::make_pair( order.balance.asset_id, backing_id );
379  if( tmp.first > tmp.second ) std::swap( tmp.first, tmp.second );
380  return tmp;
381  }
382 
383  template<typename T>
384  void enqueue_if_subscribed_to_market(const object* obj, market_queue_type& queue, bool full_object=true)
385  {
386  const T* order = dynamic_cast<const T*>(obj);
387  FC_ASSERT( order != nullptr);
388 
389  const auto& market = get_order_market( *order );
390 
391  auto sub = _market_subscriptions.find( market );
392  if( sub != _market_subscriptions.end() ) {
393  queue[market].emplace_back( full_object ? obj->to_variant() : fc::variant(obj->id, 1) );
394  }
395  }
396 
397  void broadcast_updates( const vector<variant>& updates );
398  void broadcast_market_updates( const market_queue_type& queue);
399  void handle_object_changed( bool force_notify,
400  bool full_object,
401  const vector<object_id_type>& ids,
402  const flat_set<account_id_type>& impacted_accounts,
403  std::function<const object*(object_id_type id)> find_object );
404 
406  void on_objects_new(const vector<object_id_type>& ids, const flat_set<account_id_type>& impacted_accounts);
407  void on_objects_changed(const vector<object_id_type>& ids, const flat_set<account_id_type>& impacted_accounts);
408  void on_objects_removed(const vector<object_id_type>& ids, const vector<const object*>& objs,
409  const flat_set<account_id_type>& impacted_accounts);
410  void on_applied_block();
411 
413  // Member variables
415 
416  bool _notify_remove_create = false;
418 
420  std::set<account_id_type> _subscribed_accounts;
421 
422  std::function<void(const fc::variant&)> _subscribe_callback;
423  std::function<void(const fc::variant&)> _pending_trx_callback;
424  std::function<void(const fc::variant&)> _block_applied_callback;
425 
431 
432  map< pair<asset_id_type,asset_id_type>, std::function<void(const variant&)> > _market_subscriptions;
433 
437 };
438 
439 } } // graphene::app
graphene::app::database_api_impl::get_objects
fc::variants get_objects(const vector< object_id_type > &ids, optional< bool > subscribe) const
Definition: database_api.cpp:140
graphene::app::extended_asset_object::total_in_collateral
optional< share_type > total_in_collateral
Definition: api_objects.hpp:167
graphene::app::order
Definition: api_objects.hpp:82
graphene::market_history::liquidity_pool_ticker_object
Stores ticker data for liquidity pools.
Definition: market_history_plugin.hpp:301
graphene::app::database_api_impl::lookup_committee_member_accounts
map< string, committee_member_id_type, std::less<> > lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const
Definition: database_api.cpp:2303
graphene::app::database_api_impl::get_limit_orders_by_account
vector< limit_order_object > get_limit_orders_by_account(const string &account_name_or_id, const optional< uint32_t > &limit, const optional< limit_order_id_type > &start_id)
Definition: database_api.cpp:1079
graphene::app::database_api_impl::get_block
optional< signed_block > get_block(uint32_t block_num) const
Definition: database_api.cpp:280
graphene::app::market_ticker
Definition: api_objects.hpp:112
graphene::app::database_api_impl::get_order_book
order_book get_order_book(const string &base, const string &quote, uint32_t limit) const
Definition: database_api.cpp:1450
graphene::app::database_api_impl::on_applied_block
void on_applied_block()
Definition: database_api.cpp:3284
graphene::app::database_api_impl::get_witness_count
uint64_t get_witness_count() const
Definition: database_api.cpp:2250
fc::variant_object
An order-perserving dictionary of variant's.
Definition: variant_object.hpp:20
graphene::app::database_api_impl::_removed_connection
boost::signals2::scoped_connection _removed_connection
Definition: database_api_impl.hxx:428
graphene::app::database_api_impl::get_committee_members
vector< optional< committee_member_object > > get_committee_members(const vector< committee_member_id_type > &committee_member_ids) const
Definition: database_api.cpp:2267
graphene::app::database_api_impl::get_liquidity_pools_by_share_asset
vector< optional< extended_liquidity_pool_object > > get_liquidity_pools_by_share_asset(const vector< std::string > &asset_symbols_or_ids, const optional< bool > &subscribe, const optional< bool > &with_statistics) const
Definition: database_api.cpp:1919
graphene::app::database_api_impl::_subscribe_callback
std::function< void(const fc::variant &)> _subscribe_callback
Definition: database_api_impl.hxx:422
graphene::chain::dynamic_global_property_object
Maintains global state information (committee_member list, current fees)
Definition: global_property_object.hpp:62
graphene::app::database_api_impl::lookup_account_names
vector< optional< account_object > > lookup_account_names(const vector< string > &account_names) const
Definition: database_api.cpp:772
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::app::database_api_impl::get_asset_count
uint64_t get_asset_count() const
Definition: database_api.cpp:1002
graphene::app::database_api_impl::get_account_limit_orders
vector< limit_order_object > get_account_limit_orders(const string &account_name_or_id, const string &base, const string &quote, uint32_t limit, optional< limit_order_id_type > ostart_id, optional< price > ostart_price)
Definition: database_api.cpp:1120
graphene::app::database_api_impl::get_blinded_balances
vector< blinded_balance_object > get_blinded_balances(const flat_set< commitment_type > &commitments) const
Definition: database_api.cpp:2813
graphene::app::database_api_impl
Definition: database_api_impl.hxx:36
graphene::app::database_api_impl::verify_account_authority
bool verify_account_authority(const string &account_name_or_id, const flat_set< public_key_type > &signers) const
Definition: database_api.cpp:2645
graphene::app::database_api_impl::unsubscribe_from_market
void unsubscribe_from_market(const std::string &a, const std::string &b)
Definition: database_api.cpp:1382
graphene::app::database_api_impl::list_assets
vector< extended_asset_object > list_assets(const string &lower_bound_symbol, uint32_t limit) const
Definition: database_api.cpp:977
graphene::chain::asset_object::bitasset_data_id
optional< asset_bitasset_data_id_type > bitasset_data_id
Extra data associated with BitAssets. This field is non-null if and only if is_market_issued() return...
Definition: asset_object.hpp:142
graphene::app::database_api_impl::get_required_fees
vector< fc::variant > get_required_fees(const vector< operation > &ops, const std::string &asset_id_or_symbol) const
Definition: database_api.cpp:2743
graphene::app::database_api_impl::list_htlcs
vector< htlc_object > list_htlcs(const htlc_id_type lower_bound_id, uint32_t limit) const
Definition: database_api.cpp:2987
graphene::app::database_api_impl::get_block_header
optional< maybe_signed_block_header > get_block_header(uint32_t block_num, bool with_witness_signature) const
Definition: database_api.cpp:248
graphene::app::database_api_impl::get_liquidity_pools_by_asset_x
vector< extended_liquidity_pool_object > get_liquidity_pools_by_asset_x(const optional< uint32_t > &olimit, const optional< liquidity_pool_id_type > &ostart_id, const optional< bool > &with_statistics, X... x) const
Definition: database_api_impl.hxx:278
graphene::app::database_api_impl::lookup_vote_ids
vector< variant > lookup_vote_ids(const vector< vote_id_type > &votes) const
Definition: database_api.cpp:2428
graphene::app::database_api_impl::is_public_key_registered
bool is_public_key_registered(string public_key) const
Definition: database_api.cpp:452
graphene::app::database_api_impl::subscribe_to_item
void subscribe_to_item(const T &item) const
Definition: database_api_impl.hxx:341
graphene::app::database_api_impl::get_vesting_balances
vector< vesting_balance_object > get_vesting_balances(const std::string account_id_or_name) const
Definition: database_api.cpp:918
graphene::app::database_api_impl::get_dynamic_global_properties
dynamic_global_property_object get_dynamic_global_properties() const
Definition: database_api.cpp:358
graphene::app::database_api_impl::set_block_applied_callback
void set_block_applied_callback(std::function< void(const variant &block_id)> cb)
Definition: database_api.cpp:211
graphene::app::database_api_impl::next_object_ids_index
const graphene::api_helper_indexes::next_object_ids_index * next_object_ids_index
Definition: database_api_impl.hxx:436
graphene::app::extended_asset_object
Definition: api_objects.hpp:161
graphene::app::database_api_impl::get_workers_by_account
vector< worker_object > get_workers_by_account(const std::string &account_id_or_name) const
Definition: database_api.cpp:2391
graphene::app::database_api_impl::lookup_asset_symbols
vector< optional< extended_asset_object > > lookup_asset_symbols(const vector< string > &symbols_or_ids) const
Definition: database_api.cpp:1041
graphene::app::database_api_helper::_app_options
const application_options * _app_options
Definition: database_api_helper.hxx:36
fc::bloom_filter
Definition: bloom_filter.hpp:179
graphene::app::database_api_impl::set_auto_subscription
void set_auto_subscription(bool enable)
Definition: database_api.cpp:191
graphene::app::database_api_impl::set_pending_transaction_callback
void set_pending_transaction_callback(std::function< void(const variant &)> cb)
Definition: database_api.cpp:201
graphene::app::database_api_helper::call_end_or_upper_bound
auto call_end_or_upper_bound(const T &t) const
Definition: database_api_helper.hxx:57
graphene::app::database_api_impl::get_collateral_bids
vector< collateral_bid_object > get_collateral_bids(const std::string &asset, uint32_t limit, uint32_t start) const
Definition: database_api.cpp:1336
graphene::app::database_api_impl::get_top_markets
vector< market_ticker > get_top_markets(uint32_t limit) const
Definition: database_api.cpp:1499
graphene::app::database_api_impl::get_trade_history
vector< market_trade > get_trade_history(const string &base, const string &quote, fc::time_point_sec start, fc::time_point_sec stop, uint32_t limit) const
Definition: database_api.cpp:1536
graphene::app::database_api_impl::validate_transaction
processed_transaction validate_transaction(const signed_transaction &trx) const
Definition: database_api.cpp:2676
graphene::app::database_api_impl::get_htlc
optional< htlc_object > get_htlc(htlc_id_type id, optional< bool > subscribe) const
Definition: database_api.cpp:2912
fc::sha256
Definition: sha256.hpp:10
graphene::app::database_api_impl::_notify_remove_create
bool _notify_remove_create
Definition: database_api_impl.hxx:416
graphene::app::extended_asset_object::total_backing_collateral
optional< share_type > total_backing_collateral
Definition: api_objects.hpp:168
graphene::api_helper_indexes::amount_in_collateral_index::get_amount_in_collateral
share_type get_amount_in_collateral(const asset_id_type &asset) const
Definition: api_helper_indexes.cpp:83
graphene::app::database_api_impl::lookup_accounts
map< string, account_id_type, std::less<> > lookup_accounts(const string &lower_bound_name, uint32_t limit, const optional< bool > &subscribe) const
Definition: database_api.cpp:784
graphene::app::database_api_impl::get_settle_orders_by_account
vector< force_settlement_object > get_settle_orders_by_account(const std::string &account_name_or_id, force_settlement_id_type start, uint32_t limit) const
Definition: database_api.cpp:1298
graphene::api_helper_indexes::amount_in_collateral_index
This secondary index tracks how much of each asset is locked up as collateral for MPAs,...
Definition: api_helper_indexes.hpp:38
graphene::app::database_api_impl::get_worker_count
uint64_t get_worker_count() const
Definition: database_api.cpp:2410
graphene::app::database_api_impl::get_account_by_name
optional< account_object > get_account_by_name(string name) const
Definition: database_api.cpp:732
graphene::app::database_api_impl::get_potential_signatures
set< public_key_type > get_potential_signatures(const signed_transaction &trx) const
Definition: database_api.cpp:2553
graphene::app::database_api_impl::get_chain_id
chain_id_type get_chain_id() const
Definition: database_api.cpp:348
graphene::app::database_api_impl::get_order_market
const std::pair< asset_id_type, asset_id_type > get_order_market(const T &order)
Definition: database_api_impl.hxx:368
graphene::app::database_api_impl::cancel_all_subscriptions
void cancel_all_subscriptions(bool reset_callback, bool reset_market_subscriptions)
Definition: database_api.cpp:221
graphene::db::object_database::find
const T * find(const object_id_type &id) const
Definition: object_database.hpp:126
graphene::app::database_api_impl::extend_asset
extended_asset_object extend_asset(ASSET &&a) const
Definition: database_api_impl.hxx:232
graphene::app::database_api_impl::get_liquidity_pools_by_owner
vector< extended_liquidity_pool_object > get_liquidity_pools_by_owner(const std::string &account_name_or_id, const optional< uint32_t > &limit, const optional< asset_id_type > &start_id, const optional< bool > &with_statistics) const
Definition: database_api.cpp:1966
graphene::app::database_api_impl::get_named_account_balances
vector< asset > get_named_account_balances(const std::string &name, const flat_set< asset_id_type > &assets) const
database_api_helper.hxx
graphene::app::market_volume
Definition: api_objects.hpp:140
graphene::app::database_api_impl::get_whether_to_subscribe
bool get_whether_to_subscribe(optional< bool > subscribe) const
Definition: database_api_impl.hxx:317
graphene::api_helper_indexes::amount_in_collateral_index::get_backing_collateral
share_type get_backing_collateral(const asset_id_type &asset) const
Definition: api_helper_indexes.cpp:90
graphene::app::market_queue_type
std::map< std::pair< graphene::chain::asset_id_type, graphene::chain::asset_id_type >, std::vector< fc::variant > > market_queue_type
Definition: database_api_impl.hxx:34
graphene::app::database_api_impl::get_assets_by_issuer
vector< extended_asset_object > get_assets_by_issuer(const std::string &issuer_name_or_id, asset_id_type start, uint32_t limit) const
Definition: database_api.cpp:1013
graphene::db::index::get
const object & get(object_id_type id) const
Definition: index.hpp:110
fc::optional::valid
bool valid() const
Definition: optional.hpp:186
fc::variants
std::vector< variant > variants
Definition: variant.hpp:170
graphene::app::database_api_impl::get_global_properties
global_property_object get_global_properties() const
Definition: database_api.cpp:328
graphene::app::database_api_impl::on_objects_changed
void on_objects_changed(const vector< object_id_type > &ids, const flat_set< account_id_type > &impacted_accounts)
Definition: database_api.cpp:3214
graphene::app::database_api_impl::get_withdraw_permissions_by_giver
vector< withdraw_permission_object > get_withdraw_permissions_by_giver(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit) const
Definition: database_api.cpp:2842
graphene::app::database_api_impl::set_subscribe_callback
void set_subscribe_callback(std::function< void(const variant &)> cb, bool notify_remove_create)
Definition: database_api.cpp:172
fc::time_point_sec
Definition: time.hpp:74
graphene::app::database_api_impl::get_call_orders
vector< call_order_object > get_call_orders(const std::string &a, uint32_t limit) const
Definition: database_api.cpp:1211
graphene::app::database_api_impl::verify_authority
bool verify_authority(const signed_transaction &trx) const
Definition: database_api.cpp:2626
bloom_filter.hpp
graphene::app::database_api_impl::get_top_voters
vector< account_statistics_object > get_top_voters(uint32_t limit) const
Definition: database_api.cpp:706
graphene::app::database_api_impl::get_transaction_hex
std::string get_transaction_hex(const signed_transaction &trx) const
Definition: database_api.cpp:2505
graphene::app::database_api_impl::get_committee_count
uint64_t get_committee_count() const
Definition: database_api.cpp:2341
graphene::app::database_api_impl::get_call_orders_by_account
vector< call_order_object > get_call_orders_by_account(const std::string &account_name_or_id, asset_id_type start, uint32_t limit) const
Definition: database_api.cpp:1240
graphene::app::database_api_impl::get_ticker
market_ticker get_ticker(const string &base, const string &quote, bool skip_order_book=false) const
Definition: database_api.cpp:1397
fc::bloom_filter::contains
virtual bool contains(const unsigned char *key_begin, const std::size_t length) const
Definition: bloom_filter.hpp:318
graphene::app::database_api_impl::get_24_volume
market_volume get_24_volume(const string &base, const string &quote) const
Definition: database_api.cpp:1431
graphene::app::application_options::api_limit_get_liquidity_pools
uint32_t api_limit_get_liquidity_pools
Definition: application.hpp:79
graphene::app::database_api_impl::get_committee_member_by_account
fc::optional< committee_member_object > get_committee_member_by_account(const std::string &account_id_or_name) const
Definition: database_api.cpp:2286
graphene::app::database_api_impl::get_subscription_key
vector< char > get_subscription_key(const object_id_type &item) const
Definition: database_api_impl.hxx:335
graphene::app::database_api_impl::handle_object_changed
void handle_object_changed(bool force_notify, bool full_object, const vector< object_id_type > &ids, const flat_set< account_id_type > &impacted_accounts, std::function< const object *(object_id_type id)> find_object)
Definition: database_api.cpp:3222
graphene::app::database_api_impl::lookup_witness_accounts
map< string, witness_id_type, std::less<> > lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const
Definition: database_api.cpp:2212
graphene::app::database_api_impl::database_api_impl
database_api_impl(graphene::chain::database &db, const application_options *app_options)
Definition: database_api.cpp:69
graphene::app::database_api_impl::amount_in_collateral_index
const graphene::api_helper_indexes::amount_in_collateral_index * amount_in_collateral_index
Definition: database_api_impl.hxx:434
graphene::app::database_api_impl::get_htlc_by_to
vector< htlc_object > get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const
Definition: database_api.cpp:2958
graphene::app::database_api_impl::asset_in_liquidity_pools_index
const graphene::api_helper_indexes::asset_in_liquidity_pools_index * asset_in_liquidity_pools_index
Definition: database_api_impl.hxx:435
graphene::app::extended_liquidity_pool_object::statistics
optional< liquidity_pool_ticker_object > statistics
Definition: api_objects.hpp:177
graphene::app::database_api_impl::extend_liquidity_pool
extended_liquidity_pool_object extend_liquidity_pool(LP &&a, bool with_stats) const
Definition: database_api_impl.hxx:262
graphene::app::database_api_impl::_subscribe_filter
fc::bloom_filter _subscribe_filter
Definition: database_api_impl.hxx:419
graphene::app::order_book
Definition: api_objects.hpp:102
graphene::app::database_api_impl::_applied_block_connection
boost::signals2::scoped_connection _applied_block_connection
Definition: database_api_impl.hxx:429
graphene::app::database_api_impl::is_impacted_account
bool is_impacted_account(const flat_set< account_id_type > &accounts)
Definition: database_api.cpp:3151
graphene::app::extended_liquidity_pool_object
Definition: api_objects.hpp:171
graphene::app::database_api_impl::get_account_count
uint64_t get_account_count() const
Definition: database_api.cpp:818
graphene::app::database_api_impl::get_chain_properties
chain_property_object get_chain_properties() const
Definition: database_api.cpp:318
fc::bloom_filter::insert
void insert(const unsigned char *key_begin, const std::size_t &length)
Definition: bloom_filter.hpp:275
graphene::app::database_api_impl::get_witness_by_account
fc::optional< witness_object > get_witness_by_account(const std::string &account_id_or_name) const
Definition: database_api.cpp:2196
graphene::app::database_api_impl::get_witnesses
vector< optional< witness_object > > get_witnesses(const vector< witness_id_type > &witness_ids) const
Definition: database_api.cpp:2179
graphene::api_helper_indexes::next_object_ids_index
This secondary index tracks the next ID of all object types.
Definition: api_helper_indexes.hpp:79
graphene::app::database_api_impl::get_block_header_batch
map< uint32_t, optional< maybe_signed_block_header > > get_block_header_batch(const vector< uint32_t > &block_nums, bool with_witness_signatures) const
Definition: database_api.cpp:264
graphene::app::database_api_impl::on_objects_new
void on_objects_new(const vector< object_id_type > &ids, const flat_set< account_id_type > &impacted_accounts)
Definition: database_api.cpp:3206
graphene::app::database_api_impl::get_next_object_id
object_id_type get_next_object_id(uint8_t space_id, uint8_t type_id, bool with_pending_transactions) const
Definition: database_api.cpp:369
graphene::app::database_api_impl::on_objects_removed
void on_objects_removed(const vector< object_id_type > &ids, const vector< const object * > &objs, const flat_set< account_id_type > &impacted_accounts)
Definition: database_api.cpp:3188
graphene::app::database_api_impl::broadcast_market_updates
void broadcast_market_updates(const market_queue_type &queue)
Definition: database_api.cpp:3172
FC_ASSERT
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
graphene::protocol::processed_transaction
captures the result of evaluating the operations contained in the transaction
Definition: transaction.hpp:292
graphene::app::database_api_impl::broadcast_updates
void broadcast_updates(const vector< variant > &updates)
Definition: database_api.cpp:3161
graphene::app::database_api_impl::get_settle_orders
vector< force_settlement_object > get_settle_orders(const std::string &a, uint32_t limit) const
Definition: database_api.cpp:1267
fc::scoped_connection
boost::signals2::scoped_connection scoped_connection
Definition: signals.hpp:22
graphene::app::database_api_impl::_pending_trx_callback
std::function< void(const fc::variant &)> _pending_trx_callback
Definition: database_api_impl.hxx:423
fc::variant
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition: variant.hpp:198
graphene::app::database_api_impl::get_config
fc::variant_object get_config() const
Definition: database_api.cpp:338
graphene::db::object_id_type
Definition: object_id.hpp:30
graphene::app::application_options::has_market_history_plugin
bool has_market_history_plugin
Definition: application.hpp:44
graphene::app::database_api_impl::get_limit_orders
vector< limit_order_object > get_limit_orders(const std::string &a, const std::string &b, uint32_t limit) const
Definition: database_api.cpp:1058
graphene::db::object_id
Definition: object_id.hpp:103
graphene::app::database_api_impl::_enabled_auto_subscription
bool _enabled_auto_subscription
Definition: database_api_impl.hxx:417
graphene::app::database_api_impl::_new_connection
boost::signals2::scoped_connection _new_connection
Definition: database_api_impl.hxx:426
graphene::app::database_api_impl::get_order_market
const std::pair< asset_id_type, asset_id_type > get_order_market(const force_settlement_object &order)
Definition: database_api_impl.hxx:374
graphene::app::database_api_impl::get_liquidity_pools_by_one_asset
vector< extended_liquidity_pool_object > get_liquidity_pools_by_one_asset(const std::string &asset_symbol_or_id, const optional< uint32_t > &limit, const optional< liquidity_pool_id_type > &start_id, const optional< bool > &with_statistics) const
Definition: database_api.cpp:1804
graphene::app::database_api_impl::get_proposed_transactions
vector< proposal_object > get_proposed_transactions(const std::string account_id_or_name) const
Definition: database_api.cpp:2777
graphene::app::database_api_impl::~database_api_impl
virtual ~database_api_impl()
Definition: database_api.cpp:124
graphene::chain::global_property_object
Maintains global state information (committee_member list, current fees)
Definition: global_property_object.hpp:40
graphene::chain::force_settlement_object
tracks bitassets scheduled for force settlement at some point in the future.
Definition: market_object.hpp:187
graphene::app::database_api_impl::get_full_accounts
map< string, full_account, std::less<> > get_full_accounts(const vector< string > &names_or_ids, const optional< bool > &subscribe)
Definition: database_api.cpp:522
graphene::app::database_api_impl::get_transaction
processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const
Definition: database_api.cpp:299
graphene::app::database_api_impl::subscribe_to_market
void subscribe_to_market(std::function< void(const variant &)> callback, const std::string &a, const std::string &b)
Definition: database_api.cpp:1366
graphene::app::database_api_impl::get_trade_history_by_sequence
vector< market_trade > get_trade_history_by_sequence(const string &base, const string &quote, int64_t start, fc::time_point_sec stop, uint32_t limit) const
Definition: database_api.cpp:1638
graphene::db::generic_index
Definition: generic_index.hpp:43
graphene::api_helper_indexes::asset_in_liquidity_pools_index
This secondary index maintains a map to make it easier to find liquidity pools by any asset in the po...
Definition: api_helper_indexes.hpp:59
graphene::db::abstract_object::get_id
object_id< SpaceID, TypeID > get_id() const
Definition: object.hpp:113
graphene::app::database_api_impl::get_vested_balances
vector< asset > get_vested_balances(const vector< balance_id_type > &objs) const
Definition: database_api.cpp:900
graphene::app::database_api_impl::enqueue_if_subscribed_to_market
void enqueue_if_subscribed_to_market(const object *obj, market_queue_type &queue, bool full_object=true)
Definition: database_api_impl.hxx:384
graphene::app::database_api_helper::_db
graphene::chain::database & _db
Definition: database_api_helper.hxx:35
graphene::app::database_api_impl::get_required_signatures
set< public_key_type > get_required_signatures(const signed_transaction &trx, const flat_set< public_key_type > &available_keys) const
Definition: database_api.cpp:2528
graphene::app::database_api_impl::get_potential_address_signatures
set< address > get_potential_address_signatures(const signed_transaction &trx) const
Definition: database_api.cpp:2592
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
graphene::app::database_api_impl::_block_applied_callback
std::function< void(const fc::variant &)> _block_applied_callback
Definition: database_api_impl.hxx:424
graphene::chain::chain_property_object
Definition: chain_property_object.hpp:33
graphene::app::database_api_impl::is_subscribed_to_item
bool is_subscribed_to_item(const T &item) const
Definition: database_api_impl.hxx:354
graphene::protocol::asset
Definition: asset.hpp:31
graphene::app::database_api_impl::_pending_trx_connection
boost::signals2::scoped_connection _pending_trx_connection
Definition: database_api_impl.hxx:430
graphene::app::database_api_impl::get_account_balances
vector< asset > get_account_balances(const std::string &account_name_or_id, const flat_set< asset_id_type > &assets) const
Definition: database_api.cpp:835
graphene::db::object_database::get_index_type
const IndexType & get_index_type() const
Definition: object_database.hpp:77
graphene::app::database_api_impl::get_accounts
vector< optional< account_object > > get_accounts(const vector< std::string > &account_names_or_ids, optional< bool > subscribe) const
Definition: database_api.cpp:498
graphene::app::database_api_impl::_change_connection
boost::signals2::scoped_connection _change_connection
Definition: database_api_impl.hxx:427
graphene::app::database_api_impl::_market_subscriptions
map< pair< asset_id_type, asset_id_type >, std::function< void(const variant &)> > _market_subscriptions
Definition: database_api_impl.hxx:432
graphene::app::database_api_impl::get_htlc_by_from
vector< htlc_object > get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const
Definition: database_api.cpp:2928
graphene::app::database_api_impl::get_withdraw_permissions_by_recipient
vector< withdraw_permission_object > get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit) const
Definition: database_api.cpp:2876
graphene
Definition: api.cpp:48
graphene::app::database_api_impl::get_assets
vector< optional< extended_asset_object > > get_assets(const vector< std::string > &asset_symbols_or_ids, optional< bool > subscribe) const
Definition: database_api.cpp:953
graphene::app::database_api_impl::get_balance_objects
vector< balance_object > get_balance_objects(const vector< address > &addrs) const
Definition: database_api.cpp:872
graphene::app::database_api_impl::get_account_references
vector< account_id_type > get_account_references(const std::string account_id_or_name) const
Definition: database_api.cpp:746
graphene::app::database_api_helper::make_tuple_if_multiple
auto make_tuple_if_multiple(X x) const
Definition: database_api_helper.hxx:49
graphene::app::application_options
Definition: application.hpp:38
graphene::app::database_api_impl::get_all_workers
vector< worker_object > get_all_workers(const optional< bool > &is_expired) const
Definition: database_api.cpp:2358
fc::raw::pack
void pack(Stream &s, const flat_set< T, A... > &value, uint32_t _max_depth)
Definition: flat.hpp:11
graphene::app::database_api_impl::get_transaction_hex_without_sig
std::string get_transaction_hex_without_sig(const transaction &trx) const
Definition: database_api.cpp:2516
graphene::app::database_api_impl::_subscribed_accounts
std::set< account_id_type > _subscribed_accounts
Definition: database_api_impl.hxx:420
graphene::app::database_api_helper
Definition: database_api_helper.hxx:28
graphene::app::database_api_impl::get_key_references
vector< flat_set< account_id_type > > get_key_references(vector< public_key_type > key) const
Definition: database_api.cpp:394
graphene::app::database_api_impl::get_liquidity_pools
vector< optional< extended_liquidity_pool_object > > get_liquidity_pools(const vector< liquidity_pool_id_type > &ids, const optional< bool > &subscribe, const optional< bool > &with_statistics) const
Definition: database_api.cpp:1873