BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
database.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 
27 
36 
38 #include <graphene/db/object.hpp>
40 #include <fc/signals.hpp>
41 
42 #include <fc/log/logger.hpp>
43 
44 #include <map>
45 
46 namespace graphene { namespace protocol { struct predicate_result; } }
47 
48 namespace graphene { namespace chain {
51  class op_evaluator;
52  class transaction_evaluation_state;
53  class proposal_object;
54  class operation_history_object;
55  class chain_property_object;
56  class witness_schedule_object;
57  class witness_object;
58  class force_settlement_object;
59  class limit_order_object;
60  class collateral_bid_object;
61  class call_order_object;
62 
63  struct budget_record;
64  enum class vesting_balance_type;
65 
71  {
73  public:
74  database();
75  ~database() override;
76 
78  {
84  skip_tapos_check = 1 << 5,
85  // skip_authority_check = 1 << 6, // removed, effectively identical to skip_transaction_signatures
86  skip_merkle_check = 1 << 7,
90  };
91 
104  void open(
105  const fc::path& data_dir,
106  std::function<genesis_state_type()> genesis_loader,
107  const std::string& db_version );
108 
116  void reindex(fc::path data_dir);
117 
125  void wipe(const fc::path& data_dir, bool include_blocks);
126  void close(bool rewind = true);
127 
129 
144  witness_id_type get_scheduled_witness(uint32_t slot_num)const;
145 
154  fc::time_point_sec get_slot_time(uint32_t slot_num)const;
155 
164  uint32_t get_slot_at_time(fc::time_point_sec when)const;
165 
170  uint32_t witness_participation_rate()const;
171  private:
172  uint32_t update_witness_missed_blocks( const signed_block& b );
173 
174  void update_witness_schedule();
175 
177 
178  public:
179  const chain_id_type& get_chain_id()const;
180  const asset_object& get_core_asset()const;
186  const fee_schedule& current_fee_schedule()const;
187  const account_statistics_object& get_account_stats_by_owner( account_id_type owner )const;
189 
191  uint32_t head_block_num()const;
193  witness_id_type head_block_witness()const;
194 
195  decltype( chain_parameters::block_interval ) block_interval( )const;
196 
198 
207  vector<authority> get_viable_custom_authorities(
208  account_id_type account, const operation& op,
209  rejected_predicate_map* rejected_authorities = nullptr )const;
210 
211  uint32_t last_non_undoable_block_num() const;
212 
216  const limit_order_object* find_settled_debt_order( const asset_id_type& a )const;
217 
223  bool force_by_collateral_index )const;
224 
227 
229  void initialize_indexes(); // Mark as public since it is used in tests
230  private:
231  void initialize_evaluators();
232  void init_genesis(const genesis_state_type& genesis_state = genesis_state_type());
233 
234  template<typename EvaluatorType>
235  void register_evaluator()
236  {
237  const auto op_type = operation::tag<typename EvaluatorType::operation_type>::value;
238  FC_ASSERT( op_type >= 0, "Negative operation type" );
239  FC_ASSERT( op_type < _operation_evaluators.size(),
240  "The operation type (${a}) must be smaller than the size of _operation_evaluators (${b})",
241  ("a", op_type)("b", _operation_evaluators.size()) );
242  _operation_evaluators[op_type] = std::make_unique<op_evaluator_impl<EvaluatorType>>();
243  }
245 
247 
248  public:
255  asset get_balance(account_id_type owner, asset_id_type asset_id)const;
257  asset get_balance(const account_object& owner, const asset_object& asset_obj)const;
258 
264  void adjust_balance(account_id_type account, asset delta);
265 
266  void deposit_market_fee_vesting_balance(const account_id_type &account_id, const asset &delta);
273  asset get_market_fee_vesting_balance(const account_id_type &account_id, const asset_id_type &asset_id);
274 
290  share_type amount,
291  uint32_t req_vesting_seconds,
292  vesting_balance_type balance_type,
293  account_id_type req_owner,
294  bool require_vesting );
295 
297  void deposit_cashback(const account_object& acct, share_type amount, bool require_vesting = true);
299  void deposit_witness_pay(const witness_object& wit, share_type amount);
300 
301  string to_pretty_string( const asset& a )const;
302 
304 
305  void debug_dump();
306  void apply_debug_updates();
307  void debug_update( const fc::variant_object& update );
308 
310 
313 
317  void globally_settle_asset( const asset_object& bitasset, const price& settle_price,
318  bool check_margin_calls = false );
319  void cancel_settle_order( const force_settlement_object& order );
320  void cancel_limit_order( const limit_order_object& order,
321  bool create_virtual_op = true,
322  bool skip_cancel_fee = false );
323  void revive_bitasset( const asset_object& bitasset, const asset_bitasset_data_object& bad );
324  void cancel_bid(const collateral_bid_object& bid, bool create_virtual_op = true);
325  void execute_bid( const collateral_bid_object& bid, share_type debt_covered,
326  share_type collateral_from_fund, const price_feed& current_feed );
327 
328  private:
330  void cleanup_and_remove_limit_order( const limit_order_object& order );
333  optional<limit_order_id_type> process_limit_order_on_fill( const limit_order_object& order,
334  const asset& order_receives );
335  void _cancel_bids_and_revive_mpa( const asset_object& bitasset, const asset_bitasset_data_object& bad );
336  bool check_for_blackswan( const asset_object& mia, bool enable_black_swan = true,
337  const asset_bitasset_data_object* bitasset_ptr = nullptr );
338  template<typename IndexType>
339  void globally_settle_asset_impl( const asset_object& bitasset,
340  const price& settle_price,
341  const IndexType& call_index,
342  bool check_margin_calls = false );
347  void individually_settle( const asset_bitasset_data_object& bitasset, const call_order_object& call_order );
351  bool match_force_settlements( const asset_bitasset_data_object& bitasset );
363  asset match_impl( const force_settlement_object& settle,
364  const call_order_object& call,
365  const price& match_price,
366  const asset_bitasset_data_object& bitasset,
367  const asset& max_settlement,
368  const price& fill_price,
369  bool is_margin_call = false,
370  bool settle_order_is_taker = true );
371 
372  public:
381  bool apply_order_before_hardfork_625( const limit_order_object& new_order_object );
383  bool apply_order( const limit_order_object& new_order_object );
385 
395  void apply_force_settlement( const force_settlement_object& new_settlement,
396  const asset_bitasset_data_object& bitasset,
397  const asset_object& asset_obj );
398 
399  bool check_call_orders( const asset_object& mia, bool enable_black_swan = true,
400  bool for_new_limit_order = false,
401  const asset_bitasset_data_object* bitasset_ptr = nullptr,
402  bool mute_exceptions = false,
403  bool skip_matching_settle_orders = false );
404 
413  void check_settled_debt_order( const asset_bitasset_data_object& bitasset );
414 
415  // Note: Ideally this should be private.
416  // Now it is public because we use it in a non-member function in db_market.cpp .
417  enum class match_result_type
418  {
419  none_filled = 0,
420  only_taker_filled = 1,
421  only_maker_filled = 2,
422  both_filled = 3
423  };
424 
425  private:
431  match_result_type match( const limit_order_object& taker, const limit_order_object& maker,
433  const price& trade_price );
434  match_result_type match_limit_normal_limit( const limit_order_object& taker, const limit_order_object& maker,
435  const price& trade_price );
436  match_result_type match_limit_settled_debt( const limit_order_object& taker, const limit_order_object& maker,
437  const price& trade_price );
438  match_result_type match_settled_debt_limit( const limit_order_object& taker, const limit_order_object& maker,
439  const price& trade_price );
440  /***
441  * @brief Match limit order as taker to a call order as maker
442  * @param taker the order that is removing liquidity from the book
443  * @param maker the order that put liquidity on the book
444  * @param trade_price the price the trade should execute at
445  * @param bitasset the bitasset object corresponding to debt asset of the call order
446  * @param call_pays_price price call order pays. Call order may pay more collateral
447  * than limit order takes if call order subject to a margin call fee.
448  * @returns 0 if no orders were matched, 1 if taker was filled, 2 if maker was filled, 3 if both were filled
449  */
450  match_result_type match( const limit_order_object& taker, const call_order_object& maker,
451  const price& trade_price,
452  const asset_bitasset_data_object& bitasset,
453  const price& call_pays_price);
455  match_result_type match( const limit_order_object& taker, const call_order_object& maker,
456  const price& trade_price,
457  const asset_bitasset_data_object& bitasset) {
458  return match(taker, maker, trade_price, bitasset, trade_price);
459  }
460 
462 
473  asset match( const force_settlement_object& settle,
474  const call_order_object& call,
475  const price& match_price,
476  const asset_bitasset_data_object& bitasset,
477  const asset& max_settlement,
478  const price& fill_price,
479  bool is_margin_call = false );
480 
490  asset match( const call_order_object& call,
491  const force_settlement_object& settle,
492  const price& match_price,
493  const asset_bitasset_data_object& bitasset,
494  const asset& max_settlement,
495  const price& fill_price );
496 
507  bool fill_limit_order( const limit_order_object& order, const asset& pays, const asset& receives,
508  bool cull_if_small, const price& fill_price, const bool is_maker );
509  /***
510  * @brief attempt to fill a call order
511  * @param order the order
512  * @param pays what the buyer pays for the collateral
513  * @param receives the collateral received by the buyer
514  * @param fill_price the price the transaction executed at
515  * @param is_maker TRUE if the buyer is the maker, FALSE if the buyer is the taker
516  * @param margin_fee Margin call fees paid in collateral asset
517  * @param reduce_current_supply Whether to reduce current supply of the asset. Usually it is true.
518  * When globally settleing or individually settling it is false.
519  * @returns TRUE if the order was completely filled
520  */
521  bool fill_call_order( const call_order_object& order, const asset& pays, const asset& receives,
522  const price& fill_price, const bool is_maker, const asset& margin_fee,
523  bool reduce_current_supply = true );
524 
526  bool fill_call_order( const call_order_object& order, const asset& pays, const asset& receives,
527  const price& fill_price, const bool is_maker,
528  bool reduce_current_supply = true )
529  {
530  return fill_call_order( order, pays, receives, fill_price, is_maker, asset(0, pays.asset_id),
531  reduce_current_supply );
532  }
533 
534  bool fill_settle_order( const force_settlement_object& settle, const asset& pays, const asset& receives,
535  const price& fill_price, bool is_maker, bool pay_force_settle_fee = true );
536 
539  void pay_order( const account_object& receiver, const asset& receives, const asset& pays );
540 
541  public:
548  asset calculate_market_fee( const asset_object& trade_asset, const asset& trade_amount,
549  const bool& is_maker )const;
550  asset pay_market_fees(const account_object* seller, const asset_object& recv_asset, const asset& receives,
551  const bool& is_maker, const optional<asset>& calculated_market_fees = {});
552  asset pay_force_settle_fees(const asset_object& collecting_asset, const asset& collat_receives);
555 
557 
562  bool is_known_block( const block_id_type& id )const;
563  bool is_known_transaction( const transaction_id_type& id )const;
564  block_id_type get_block_id_for_num( uint32_t block_num )const;
565  optional<signed_block> fetch_block_by_id( const block_id_type& id )const;
566  optional<signed_block> fetch_block_by_number( uint32_t num )const;
567  const signed_transaction& get_recent_transaction( const transaction_id_type& trx_id )const;
568  std::vector<block_id_type> get_block_ids_on_fork(block_id_type head_of_fork) const;
569 
570  void add_checkpoints( const flat_map<uint32_t,block_id_type>& checkpts );
571  const flat_map<uint32_t,block_id_type> get_checkpoints()const { return _checkpoints; }
572  bool before_last_checkpoint()const;
573 
574  bool push_block( const signed_block& b, uint32_t skip = skip_nothing );
576  private:
577  bool _push_block( const signed_block& b );
578  public:
579  // It is public because it is used in pending_transactions_restorer in db_with.hpp
583 
585  const fc::time_point_sec when,
586  witness_id_type witness_id,
587  const fc::ecc::private_key& block_signing_private_key,
588  uint32_t skip
589  );
590  private:
591  signed_block _generate_block(
592  const fc::time_point_sec when,
593  witness_id_type witness_id,
594  const fc::ecc::private_key& block_signing_private_key
595  );
596 
597  public:
598  void pop_block();
599  void clear_pending();
600 
612  uint32_t push_applied_operation( const operation& op, bool is_virtual = true );
613  void set_applied_operation_result( uint32_t op_id, const operation_result& r );
614  const vector<optional< operation_history_object > >& get_applied_operations()const;
615 
625 
631 
636  fc::signal<void(const vector<object_id_type>&, const flat_set<account_id_type>&)> new_objects;
637 
642  fc::signal<void(const vector<object_id_type>&, const flat_set<account_id_type>&)> changed_objects;
643 
647  fc::signal<void(const vector<object_id_type>&,
648  const vector<const object*>&, const flat_set<account_id_type>&)> removed_objects;
649 
651 
656 
657 
660  std::deque< precomputable_transaction > _popped_tx;
661 
675  fc::future<void> precompute_parallel( const signed_block& block, const uint32_t skip = skip_nothing )const;
676 
685  private:
686  template<typename Trx>
687  void _precompute_parallel( const Trx* trx, const size_t count, const uint32_t skip )const;
688 
689  protected:
690  // Mark pop_undo() as protected -- we do not want outside calling pop_undo(),
691  // it should call pop_block() instead
693 
694  private:
695  optional<undo_database::session> _pending_tx_session;
696  vector< unique_ptr<op_evaluator> > _operation_evaluators;
697 
698  template<class Index>
699  vector<std::reference_wrapper<const typename Index::object_type>> sort_votable_objects(size_t count)const;
700 
701  public:
702  // these were formerly private, but they have a fairly well-defined API, so let's make them public
703  void apply_block( const signed_block& next_block, uint32_t skip = skip_nothing );
706  bool is_virtual = true );
707 
708  private:
709  void _apply_block( const signed_block& next_block );
710  processed_transaction _apply_transaction( const signed_transaction& trx );
711 
714  operation_result try_push_virtual_operation( transaction_evaluation_state& eval_state,
715  const operation& op );
716 
719 
720  const witness_object& validate_block_header( uint32_t skip, const signed_block& next_block )const;
721  const witness_object& _validate_block_header( const signed_block& next_block )const;
722  void verify_signing_witness( const signed_block& new_block, const fork_item& fork_entry )const;
723  void update_witnesses( fork_item& fork_entry )const;
724  void create_block_summary(const signed_block& next_block);
725 
727 
728  protected:
729  void notify_applied_block( const signed_block& block );
731  void notify_changed_objects();
732 
734  public:
740  bool skip_median_update = false );
741  private:
742  void update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks );
743  void update_signing_witness(const witness_object& signing_witness, const signed_block& new_block);
744  void update_last_irreversible_block();
745  void clear_expired_transactions();
746  void clear_expired_proposals();
747  void clear_expired_orders();
748  void clear_expired_force_settlements();
749  void update_expired_feeds();
750  void update_core_exchange_rates();
751  void update_maintenance_flag( bool new_maintenance_flag );
752  void update_withdraw_permissions();
753  void update_credit_offers_and_deals();
754  void clear_expired_htlcs();
755 
758 
760 
761  void initialize_budget_record( fc::time_point_sec now, budget_record& rec )const;
762  void process_budget();
763  void pay_workers( share_type& budget );
764  void perform_chain_maintenance( const signed_block& next_block );
765  void update_active_witnesses();
766  void update_active_committee_members();
767  void update_worker_votes();
768  void process_bids( const asset_bitasset_data_object& bad );
769  void process_bitassets();
770 
771  template<class Type>
772  void perform_account_maintenance( Type tally_helper );
775 
776  vector< processed_transaction > _pending_tx;
777  fork_database _fork_db;
778 
788  block_database _block_id_to_block;
789 
796  vector<optional<operation_history_object> > _applied_ops;
797 
798  public:
800  uint32_t _current_block_num = 0;
801  private:
802  uint16_t _current_trx_in_block = 0;
803  uint16_t _current_op_in_trx = 0;
804  uint32_t _current_virtual_op = 0;
805 
806  vector<uint64_t> _vote_tally_buffer;
807  vector<uint64_t> _witness_count_histogram_buffer;
808  vector<uint64_t> _committee_count_histogram_buffer;
809  std::array<uint64_t,2> _total_voting_stake; // 0=committee, 1=witness,
810  // as in vote_id_type::vote_type
811 
812  flat_map<uint32_t,block_id_type> _checkpoints;
813 
814  node_property_object _node_property_object;
815 
818  bool _track_standby_votes = true;
819 
827  bool _opened = false;
828 
830  uint32_t _undo_session_nesting_depth = 0;
831 
833  flat_set<asset_id_type> _issue_453_affected_assets;
834 
837  const asset_object* _p_core_asset_obj = nullptr;
838  const asset_dynamic_data_object* _p_core_dynamic_data_obj = nullptr;
839  const global_property_object* _p_global_prop_obj = nullptr;
840  const dynamic_global_property_object* _p_dyn_global_prop_obj = nullptr;
841  const chain_property_object* _p_chain_property_obj = nullptr;
842  const witness_schedule_object* _p_witness_schedule_obj = nullptr;
844  public:
846  inline void enable_standby_votes_tracking(bool enable) { _track_standby_votes = enable; }
847  };
848 
849 } }
graphene::chain::database::match_result_type::none_filled
@ none_filled
graphene::chain::database::apply_force_settlement
void apply_force_settlement(const force_settlement_object &new_settlement, const asset_bitasset_data_object &bitasset, const asset_object &asset_obj)
Process a new force-settlement request.
Definition: db_market.cpp:943
graphene::chain::database::skip_transaction_signatures
@ skip_transaction_signatures
used by non-witness nodes
Definition: database.hpp:81
graphene::protocol::precomputable_transaction
Definition: transaction.hpp:233
genesis_state.hpp
fc::variant_object
An order-perserving dictionary of variant's.
Definition: variant_object.hpp:20
graphene::chain::database::skip_tapos_check
@ skip_tapos_check
used while reindexing – note this skips expiration check too
Definition: database.hpp:84
graphene::chain::database::is_known_transaction
bool is_known_transaction(const transaction_id_type &id) const
Definition: db_block.cpp:57
graphene::chain::dynamic_global_property_object
Maintains global state information (committee_member list, current fees)
Definition: global_property_object.hpp:62
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::chain::database::find_settled_debt_order
const limit_order_object * find_settled_debt_order(const asset_id_type &a) const
Definition: db_getter.cpp:152
graphene::chain::database::pop_undo
void pop_undo()
Definition: database.hpp:692
graphene::chain::database::get_chain_id
const chain_id_type & get_chain_id() const
Definition: db_getter.cpp:87
graphene::protocol::rejected_predicate_map
map< custom_authority_id_type, rejected_predicate > rejected_predicate_map
Definition: transaction.hpp:31
graphene::chain::database::apply_order_before_hardfork_625
bool apply_order_before_hardfork_625(const limit_order_object &new_order_object)
Process a new limit order through the markets.
Definition: db_market.cpp:672
graphene::chain::database::head_block_time
time_point_sec head_block_time() const
Definition: db_getter.cpp:67
graphene::chain::database::_current_block_time
fc::time_point_sec _current_block_time
Definition: database.hpp:799
asset_object.hpp
graphene::chain::database::get_balance
asset get_balance(account_id_type owner, asset_id_type asset_id) const
Retrieve a particular account's balance in a given asset.
Definition: db_balance.cpp:35
graphene::protocol::fee_schedule
contains all of the parameters necessary to calculate the fee for any operation
Definition: fee_schedule.hpp:173
graphene::protocol::price
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:108
fc::static_variant< transfer_operation, limit_order_create_operation, limit_order_cancel_operation, call_order_update_operation, fill_order_operation, account_create_operation, account_update_operation, account_whitelist_operation, account_upgrade_operation, account_transfer_operation, asset_create_operation, asset_update_operation, asset_update_bitasset_operation, asset_update_feed_producers_operation, asset_issue_operation, asset_reserve_operation, asset_fund_fee_pool_operation, asset_settle_operation, asset_global_settle_operation, asset_publish_feed_operation, witness_create_operation, witness_update_operation, proposal_create_operation, proposal_update_operation, proposal_delete_operation, withdraw_permission_create_operation, withdraw_permission_update_operation, withdraw_permission_claim_operation, withdraw_permission_delete_operation, committee_member_create_operation, committee_member_update_operation, committee_member_update_global_parameters_operation, vesting_balance_create_operation, vesting_balance_withdraw_operation, worker_create_operation, custom_operation, assert_operation, balance_claim_operation, override_transfer_operation, transfer_to_blind_operation, blind_transfer_operation, transfer_from_blind_operation, asset_settle_cancel_operation, asset_claim_fees_operation, fba_distribute_operation, bid_collateral_operation, execute_bid_operation, asset_claim_pool_operation, asset_update_issuer_operation, htlc_create_operation, htlc_redeem_operation, htlc_redeemed_operation, htlc_extend_operation, htlc_refund_operation, custom_authority_create_operation, custom_authority_update_operation, custom_authority_delete_operation, ticket_create_operation, ticket_update_operation, liquidity_pool_create_operation, liquidity_pool_delete_operation, liquidity_pool_deposit_operation, liquidity_pool_withdraw_operation, liquidity_pool_exchange_operation, samet_fund_create_operation, samet_fund_delete_operation, samet_fund_update_operation, samet_fund_borrow_operation, samet_fund_repay_operation, credit_offer_create_operation, credit_offer_delete_operation, credit_offer_update_operation, credit_offer_accept_operation, credit_deal_repay_operation, credit_deal_expired_operation, liquidity_pool_update_operation, credit_deal_update_operation, limit_order_update_operation >
graphene::chain::database::clear_pending
void clear_pending()
Definition: db_block.cpp:541
graphene::chain::database::notify_changed_objects
void notify_changed_objects()
Definition: db_notify.cpp:592
graphene::protocol::transaction_id_type
fc::ripemd160 transaction_id_type
Definition: types.hpp:306
graphene::chain::database::~database
~database() override
Definition: db_management.cpp:50
graphene::chain::database::reindex
void reindex(fc::path data_dir)
Rebuild object graph from block history and open detabase.
Definition: db_management.cpp:55
graphene::chain::database::pay_market_fees
asset pay_market_fees(const account_object *seller, const asset_object &recv_asset, const asset &receives, const bool &is_maker, const optional< asset > &calculated_market_fees={})
Definition: db_market.cpp:2592
graphene::chain::transaction_evaluation_state
Definition: transaction_evaluation_state.hpp:37
graphene::chain::database::get_viable_custom_authorities
vector< authority > get_viable_custom_authorities(account_id_type account, const operation &op, rejected_predicate_map *rejected_authorities=nullptr) const
Get a list of custom authorities which can validate the provided operation for the provided account.
Definition: db_getter.cpp:102
graphene::chain::database::check_settled_debt_order
void check_settled_debt_order(const asset_bitasset_data_object &bitasset)
Match the settled debt order of the specified asset as taker with other orders on the opposite side o...
Definition: db_market.cpp:2504
graphene::chain::vesting_balance_type
vesting_balance_type
Definition: vesting_balance_object.hpp:143
graphene::chain::database::wipe
void wipe(const fc::path &data_dir, bool include_blocks)
wipe Delete database from disk, and potentially the raw chain as well.
Definition: db_management.cpp:165
fee_schedule.hpp
graphene::chain::database::removed_objects
fc::signal< void(const vector< object_id_type > &, const vector< const object * > &, const flat_set< account_id_type > &)> removed_objects
Definition: database.hpp:648
fc::sha256
Definition: sha256.hpp:10
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::chain::database::adjust_balance
void adjust_balance(account_id_type account, asset delta)
Adjust a particular account's balance in a given asset by a delta.
Definition: db_balance.cpp:54
graphene::chain::database::_current_block_num
uint32_t _current_block_num
Definition: database.hpp:800
fc::signal
boost::signals2::signal< T > signal
Definition: signals.hpp:20
graphene::chain::database::check_call_orders
bool check_call_orders(const asset_object &mia, bool enable_black_swan=true, bool for_new_limit_order=false, const asset_bitasset_data_object *bitasset_ptr=nullptr, bool mute_exceptions=false, bool skip_matching_settle_orders=false)
Definition: db_market.cpp:2079
graphene::chain::database::push_block
bool push_block(const signed_block &b, uint32_t skip=skip_nothing)
Definition: db_block.cpp:118
graphene::db::object_database::close
void close()
Definition: object_database.cpp:39
graphene::chain::database::pop_block
void pop_block()
Definition: db_block.cpp:523
graphene::chain::database::push_proposal
processed_transaction push_proposal(const proposal_object &proposal)
Definition: db_block.cpp:336
graphene::chain::database::get_applied_operations
const vector< optional< operation_history_object > > & get_applied_operations() const
Definition: db_block.cpp:566
graphene::chain::database::apply_block
void apply_block(const signed_block &next_block, uint32_t skip=skip_nothing)
Definition: db_block.cpp:573
graphene::chain::database::get_checkpoints
const flat_map< uint32_t, block_id_type > get_checkpoints() const
Definition: database.hpp:571
graphene::chain::database::notify_on_pending_transaction
void notify_on_pending_transaction(const signed_transaction &tx)
Definition: db_notify.cpp:587
graphene::chain::database::applied_block
fc::signal< void(const signed_block &)> applied_block
Definition: database.hpp:624
graphene::chain::database::notify_applied_block
void notify_applied_block(const signed_block &block)
Definition: db_notify.cpp:582
graphene::chain::database::set_applied_operation_result
void set_applied_operation_result(uint32_t op_id, const operation_result &r)
Definition: db_block.cpp:555
graphene::chain::database::_push_transaction
processed_transaction _push_transaction(const precomputable_transaction &trx)
Definition: db_block.cpp:282
graphene::chain::database::deposit_witness_pay
void deposit_witness_pay(const witness_object &wit, share_type amount)
helper to handle witness pay
Definition: db_balance.cpp:249
graphene::chain::database::get_core_asset
const asset_object & get_core_asset() const
Definition: db_getter.cpp:37
graphene::chain::database::generate_block
signed_block generate_block(const fc::time_point_sec when, witness_id_type witness_id, const fc::ecc::private_key &block_signing_private_key, uint32_t skip)
Definition: db_block.cpp:382
fork_database.hpp
graphene::db::abstract_object
Definition: object.hpp:107
graphene::chain::database::on_pending_transaction
fc::signal< void(const signed_transaction &)> on_pending_transaction
Definition: database.hpp:630
graphene::chain::database::match_result_type
match_result_type
Definition: database.hpp:417
graphene::chain::database::changed_objects
fc::signal< void(const vector< object_id_type > &, const flat_set< account_id_type > &)> changed_objects
Definition: database.hpp:642
graphene::chain::database::cancel_limit_order
void cancel_limit_order(const limit_order_object &order, bool create_virtual_op=true, bool skip_cancel_fee=false)
Definition: db_market.cpp:533
simple_index.hpp
fc::ecc::private_key
an elliptic curve private key.
Definition: elliptic.hpp:89
node_property_object.hpp
graphene::chain::database::fetch_block_by_id
optional< signed_block > fetch_block_by_id(const block_id_type &id) const
Definition: db_block.cpp:68
graphene::chain::database::revive_bitasset
void revive_bitasset(const asset_object &bitasset, const asset_bitasset_data_object &bad)
Definition: db_market.cpp:422
graphene::protocol::signed_transaction
adds a signature to a transaction
Definition: transaction.hpp:134
graphene::chain::database::match_result_type::only_maker_filled
@ only_maker_filled
graphene::chain::database::head_block_id
block_id_type head_block_id() const
Definition: db_getter.cpp:77
graphene::chain::account_statistics_object
Definition: account_object.hpp:46
graphene::chain::database::match_result_type::both_filled
@ both_filled
signals.hpp
fc::path
wraps boost::filesystem::path to provide platform independent path manipulation.
Definition: filesystem.hpp:28
graphene::chain::fork_item
Definition: fork_database.hpp:40
graphene::chain::database::get_node_properties
const node_property_object & get_node_properties() const
Definition: db_getter.cpp:92
graphene::chain::database::current_fee_schedule
const fee_schedule & current_fee_schedule() const
Definition: db_getter.cpp:62
graphene::chain::database::update_bitasset_current_feed
void update_bitasset_current_feed(const asset_bitasset_data_object &bitasset, bool skip_median_update=false)
Definition: db_update.cpp:270
graphene::chain::database::validation_steps
validation_steps
Definition: database.hpp:77
graphene::chain::database::cancel_bid
void cancel_bid(const collateral_bid_object &bid, bool create_virtual_op=true)
Definition: db_market.cpp:477
graphene::chain::asset_dynamic_data_object
tracks the asset information that changes frequently
Definition: asset_object.hpp:56
graphene::chain::database::get_core_dynamic_data
const asset_dynamic_data_object & get_core_dynamic_data() const
Definition: db_getter.cpp:42
graphene::chain::database::match_result_type::only_taker_filled
@ only_taker_filled
evaluator.hpp
graphene::chain::database::apply_order
bool apply_order(const limit_order_object &new_order_object)
Definition: db_market.cpp:741
graphene::chain::database::get_slot_time
fc::time_point_sec get_slot_time(uint32_t slot_num) const
Definition: db_witness_schedule.cpp:44
graphene::chain::database::witness_participation_rate
uint32_t witness_participation_rate() const
Definition: db_witness_schedule.cpp:98
fc::time_point_sec
Definition: time.hpp:74
account_object.hpp
graphene::chain::database::push_applied_operation
uint32_t push_applied_operation(const operation &op, bool is_virtual=true)
Definition: db_block.cpp:548
fc::ripemd160
Definition: ripemd160.hpp:11
graphene::chain::database::execute_bid
void execute_bid(const collateral_bid_object &bid, share_type debt_covered, share_type collateral_from_fund, const price_feed &current_feed)
Definition: db_market.cpp:492
graphene::protocol::block_id_type
fc::ripemd160 block_id_type
Definition: types.hpp:304
graphene::chain::database::push_transaction
processed_transaction push_transaction(const precomputable_transaction &trx, uint32_t skip=skip_nothing)
Definition: db_block.cpp:270
graphene::chain::node_property_object
Contains per-node database configuration.
Definition: node_property_object.hpp:39
graphene::chain::database::globally_settle_asset
void globally_settle_asset(const asset_object &bitasset, const price &settle_price, bool check_margin_calls=false)
Definition: db_market.cpp:221
graphene::chain::asset_bitasset_data_object
contains properties that only apply to bitassets (market issued assets)
Definition: asset_object.hpp:255
graphene::chain::database::to_pretty_string
string to_pretty_string(const asset &a) const
Definition: db_balance.cpp:49
graphene::chain::database::before_last_checkpoint
bool before_last_checkpoint() const
Definition: db_block.cpp:864
graphene::chain::budget_record
Definition: budget_record_object.hpp:30
graphene::chain::database::get_block_ids_on_fork
std::vector< block_id_type > get_block_ids_on_fork(block_id_type head_of_fork) const
Definition: db_block.cpp:93
graphene::chain::database::open
void open(const fc::path &data_dir, std::function< genesis_state_type()> genesis_loader, const std::string &db_version)
Open a database, creating a new one if necessary.
Definition: db_management.cpp:176
graphene::chain::database::get_chain_properties
const chain_property_object & get_chain_properties() const
Definition: db_getter.cpp:52
graphene::chain::database::deposit_market_fee_vesting_balance
void deposit_market_fee_vesting_balance(const account_id_type &account_id, const asset &delta)
Definition: db_balance.cpp:127
graphene::chain::database::head_block_num
uint32_t head_block_num() const
Definition: db_getter.cpp:72
graphene::chain::database::get_slot_at_time
uint32_t get_slot_at_time(fc::time_point_sec when) const
Definition: db_witness_schedule.cpp:74
graphene::protocol::share_type
safe< int64_t > share_type
Definition: types.hpp:309
graphene::db::object_database
maintains a set of indexed objects that can be modified with multi-level rollback support
Definition: object_database.hpp:39
graphene::chain::database::deposit_lazy_vesting
optional< vesting_balance_id_type > deposit_lazy_vesting(const optional< vesting_balance_id_type > &ovbid, share_type amount, uint32_t req_vesting_seconds, vesting_balance_type balance_type, account_id_type req_owner, bool require_vesting)
Helper to make lazy deposit to CDD VBO.
Definition: db_balance.cpp:156
graphene::chain::database::_popped_tx
std::deque< precomputable_transaction > _popped_tx
Definition: database.hpp:660
graphene::chain::database::debug_dump
void debug_dump()
Definition: db_debug.cpp:41
FC_ASSERT
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
graphene::chain::database::validate_transaction
processed_transaction validate_transaction(const signed_transaction &trx)
Definition: db_block.cpp:307
graphene::protocol::processed_transaction
captures the result of evaluating the operations contained in the transaction
Definition: transaction.hpp:292
graphene::chain::database::skip_witness_schedule_check
@ skip_witness_schedule_check
used while reindexing
Definition: database.hpp:89
graphene::chain::genesis_state_type
Definition: genesis_state.hpp:40
graphene::chain::database::get_market_fee_vesting_balance
asset get_market_fee_vesting_balance(const account_id_type &account_id, const asset_id_type &asset_id)
Retrieve a particular account's market fee vesting balance in a given asset.
Definition: db_balance.cpp:114
graphene::chain::database::last_non_undoable_block_num
uint32_t last_non_undoable_block_num() const
Definition: db_getter.cpp:130
graphene::chain::database::node_properties
node_property_object & node_properties()
Definition: db_getter.cpp:97
graphene::chain::database::skip_block_size_check
@ skip_block_size_check
used when applying locally generated transactions
Definition: database.hpp:83
logger.hpp
graphene::chain::global_property_object
Maintains global state information (committee_member list, current fees)
Definition: global_property_object.hpp:40
graphene::chain::database::deposit_cashback
void deposit_cashback(const account_object &acct, share_type amount, bool require_vesting=true)
helper to handle cashback rewards
Definition: db_balance.cpp:202
graphene::chain::database::skip_merkle_check
@ skip_merkle_check
used while reindexing
Definition: database.hpp:86
graphene::chain::call_order_object
tracks debt and call price information
Definition: market_object.hpp:140
graphene::chain::witness_object
Definition: witness_object.hpp:32
graphene::chain::database::initialize_indexes
void initialize_indexes()
Reset the object graph in-memory.
Definition: db_init.cpp:154
graphene::chain::witness_schedule_object
Definition: witness_schedule_object.hpp:30
graphene::chain::fork_database
Definition: fork_database.hpp:70
graphene::chain::database::get_witness_schedule_object
const witness_schedule_object & get_witness_schedule_object() const
Definition: db_getter.cpp:147
graphene::chain::database::apply_operation
operation_result apply_operation(transaction_evaluation_state &eval_state, const operation &op, bool is_virtual=true)
Definition: db_block.cpp:784
graphene::chain::database::get_account_stats_by_owner
const account_statistics_object & get_account_stats_by_owner(account_id_type owner) const
Definition: db_getter.cpp:142
graphene::chain::database::head_block_witness
witness_id_type head_block_witness() const
graphene::chain::database::apply_debug_updates
void apply_debug_updates()
Definition: db_debug.cpp:187
graphene::chain::database::enable_standby_votes_tracking
void enable_standby_votes_tracking(bool enable)
Enable or disable tracking of votes of standby witnesses and committee members.
Definition: database.hpp:846
graphene::chain::database::process_tickets
generic_operation_result process_tickets()
Definition: db_update.cpp:652
graphene::chain::database::get_global_properties
const global_property_object & get_global_properties() const
Definition: db_getter.cpp:47
graphene::chain::block_database
Definition: block_database.hpp:34
fc::optional< vesting_balance_id_type >
graphene::chain::database::skip_witness_signature
@ skip_witness_signature
used while reindexing
Definition: database.hpp:80
graphene::chain::database::get_recent_transaction
const signed_transaction & get_recent_transaction(const transaction_id_type &trx_id) const
Definition: db_block.cpp:85
graphene::chain::database::skip_assert_evaluation
@ skip_assert_evaluation
used while reindexing
Definition: database.hpp:87
graphene::chain::chain_property_object
Definition: chain_property_object.hpp:33
graphene::chain::database::pay_force_settle_fees
asset pay_force_settle_fees(const asset_object &collecting_asset, const asset &collat_receives)
Definition: db_market.cpp:2702
graphene::chain::database::get_block_id_for_num
block_id_type get_block_id_for_num(uint32_t block_num) const
Definition: db_block.cpp:63
graphene::chain::database::fetch_block_by_number
optional< signed_block > fetch_block_by_number(uint32_t num) const
Definition: db_block.cpp:76
graphene::chain::database::cancel_settle_order
void cancel_settle_order(const force_settlement_object &order)
Definition: db_market.cpp:524
graphene::protocol::signed_block
Definition: block.hpp:64
graphene::chain::database::skip_transaction_dupe_check
@ skip_transaction_dupe_check
used while reindexing
Definition: database.hpp:82
graphene::chain::database::debug_update
void debug_update(const fc::variant_object &update)
Definition: db_debug.cpp:197
graphene::chain::database::get_dynamic_global_properties
const dynamic_global_property_object & get_dynamic_global_properties() const
Definition: db_getter.cpp:57
object.hpp
graphene::chain::database::calculate_market_fee
asset calculate_market_fee(const asset_object &trade_asset, const asset &trade_amount, const bool &is_maker) const
Calculate the market fee that is to be taken.
Definition: db_market.cpp:2557
graphene::chain::database::get_scheduled_witness
witness_id_type get_scheduled_witness(uint32_t slot_num) const
Get the witness scheduled for block production in a slot.
Definition: db_witness_schedule.cpp:36
graphene::chain::database::skip_undo_history_check
@ skip_undo_history_check
used while reindexing
Definition: database.hpp:88
graphene::chain::proposal_object
tracks the approval of a partially approved transaction
Definition: proposal_object.hpp:40
graphene::chain::database::find_least_collateralized_short
const call_order_object * find_least_collateralized_short(const asset_bitasset_data_object &bitasset, bool force_by_collateral_index) const
Definition: db_getter.cpp:161
graphene::chain::database::add_checkpoints
void add_checkpoints(const flat_map< uint32_t, block_id_type > &checkpts)
Definition: db_block.cpp:858
object_database.hpp
global_property_object.hpp
graphene::chain::limit_order_object
an offer to sell an amount of an asset at a specified exchange rate by a certain time
Definition: market_object.hpp:45
graphene::db::object_database::pop_undo
void pop_undo()
Definition: object_database.cpp:163
block_database.hpp
graphene::chain::database::new_objects
fc::signal< void(const vector< object_id_type > &, const flat_set< account_id_type > &)> new_objects
Definition: database.hpp:636
graphene::protocol::generic_operation_result
Definition: base.hpp:88
graphene::chain::database::database
database()
Definition: db_management.cpp:44
graphene
Definition: api.cpp:48
fc::future< void >
Definition: future.hpp:283
graphene::chain::database::is_known_block
bool is_known_block(const block_id_type &id) const
Definition: db_block.cpp:48
graphene::chain::database::skip_nothing
@ skip_nothing
Definition: database.hpp:79
graphene::chain::database::precompute_parallel
fc::future< void > precompute_parallel(const signed_block &block, const uint32_t skip=skip_nothing) const
Definition: db_block.cpp:888
graphene::protocol::chain_parameters::block_interval
uint8_t block_interval
interval in seconds between blocks
Definition: chain_parameters.hpp:53
graphene::chain::database::apply_transaction
processed_transaction apply_transaction(const signed_transaction &trx, uint32_t skip=skip_nothing)
Definition: db_block.cpp:688
graphene::db::object
base for all database objects
Definition: object.hpp:61
fc::safe
Definition: safe.hpp:26