| 67 | } |
| 68 | |
| 69 | database_api_impl::database_api_impl( graphene::chain::database& db, const application_options* app_options ) |
| 70 | :database_api_helper( db, app_options ) |
| 71 | { |
| 72 | dlog("creating database api ${x}", ("x",int64_t(this)) ); |
| 73 | _new_connection = _db.new_objects.connect([this](const vector<object_id_type>& ids, |
| 74 | const flat_set<account_id_type>& impacted_accounts) { |
| 75 | on_objects_new(ids, impacted_accounts); |
| 76 | }); |
| 77 | _change_connection = _db.changed_objects.connect([this](const vector<object_id_type>& ids, |
| 78 | const flat_set<account_id_type>& impacted_accounts) { |
| 79 | on_objects_changed(ids, impacted_accounts); |
| 80 | }); |
| 81 | _removed_connection = _db.removed_objects.connect([this](const vector<object_id_type>& ids, |
| 82 | const vector<const object*>& objs, |
| 83 | const flat_set<account_id_type>& impacted_accounts) { |
| 84 | on_objects_removed(ids, objs, impacted_accounts); |
| 85 | }); |
| 86 | _applied_block_connection = _db.applied_block.connect([this](const signed_block&){ on_applied_block(); }); |
| 87 | |
| 88 | _pending_trx_connection = _db.on_pending_transaction.connect([this](const signed_transaction& trx ){ |
| 89 | if( _pending_trx_callback ) |
| 90 | _pending_trx_callback( fc::variant(trx, GRAPHENE_MAX_NESTED_OBJECTS) ); |
| 91 | }); |
| 92 | try |
| 93 | { |
| 94 | amount_in_collateral_index = &_db.get_index_type< primary_index< call_order_index > >() |
| 95 | .get_secondary_index<graphene::api_helper_indexes::amount_in_collateral_index>(); |
| 96 | } |
| 97 | catch( const fc::assert_exception& ) |
| 98 | { |
| 99 | amount_in_collateral_index = nullptr; |
| 100 | } |
| 101 | |
| 102 | try |
| 103 | { |
| 104 | asset_in_liquidity_pools_index = &_db.get_index_type< primary_index< liquidity_pool_index > >() |
| 105 | .get_secondary_index<graphene::api_helper_indexes::asset_in_liquidity_pools_index>(); |
| 106 | } |
| 107 | catch( const fc::assert_exception& ) |
| 108 | { |
| 109 | asset_in_liquidity_pools_index = nullptr; |
| 110 | } |
| 111 | |
| 112 | try |
| 113 | { |
| 114 | next_object_ids_index = &_db.get_index_type< primary_index< simple_index< chain_property_object > > >() |
| 115 | .get_secondary_index<graphene::api_helper_indexes::next_object_ids_index>(); |
| 116 | } |
| 117 | catch( const fc::assert_exception& ) |
| 118 | { |
| 119 | next_object_ids_index = nullptr; |
| 120 | } |
| 121 | |
| 122 | } |
| 123 | |
| 124 | database_api_impl::~database_api_impl() |
| 125 | { |