BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
graphene::chain::database Class Reference

tracks the blockchain state in an extensible manner More...

#include <database.hpp>

Inheritance diagram for graphene::chain::database:
graphene::db::object_database

Public Types

enum  validation_steps {
  skip_nothing = 0, skip_witness_signature = 1 << 0, skip_transaction_signatures = 1 << 1, skip_transaction_dupe_check = 1 << 2,
  skip_block_size_check = 1 << 4, skip_tapos_check = 1 << 5, skip_merkle_check = 1 << 7, skip_assert_evaluation = 1 << 8,
  skip_undo_history_check = 1 << 9, skip_witness_schedule_check = 1 << 10
}
 

Public Member Functions

 database ()
 
 ~database ()
 
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. More...
 
void reindex (fc::path data_dir)
 Rebuild object graph from block history and open detabase. More...
 
void wipe (const fc::path &data_dir, bool include_blocks)
 wipe Delete database from disk, and potentially the raw chain as well. More...
 
void close (bool rewind=true)
 
bool is_known_block (const block_id_type &id) const
 
bool is_known_transaction (const transaction_id_type &id) const
 
block_id_type get_block_id_for_num (uint32_t block_num) const
 
optional< signed_blockfetch_block_by_id (const block_id_type &id) const
 
optional< signed_blockfetch_block_by_number (uint32_t num) const
 
const signed_transactionget_recent_transaction (const transaction_id_type &trx_id) const
 
std::vector< block_id_typeget_block_ids_on_fork (block_id_type head_of_fork) const
 
uint32_t witness_participation_rate () const
 
void add_checkpoints (const flat_map< uint32_t, block_id_type > &checkpts)
 
const flat_map< uint32_t, block_id_typeget_checkpoints () const
 
bool before_last_checkpoint () const
 
bool push_block (const signed_block &b, uint32_t skip=skip_nothing)
 
processed_transaction push_transaction (const precomputable_transaction &trx, uint32_t skip=skip_nothing)
 
bool _push_block (const signed_block &b)
 
processed_transaction _push_transaction (const precomputable_transaction &trx)
 
processed_transaction push_proposal (const proposal_object &proposal)
 
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)
 
signed_block _generate_block (const fc::time_point_sec when, witness_id_type witness_id, const fc::ecc::private_key &block_signing_private_key)
 
void pop_block ()
 
void clear_pending ()
 
uint32_t push_applied_operation (const operation &op)
 
void set_applied_operation_result (uint32_t op_id, const operation_result &r)
 
const vector< optional< operation_history_object > > & get_applied_operations () const
 
string to_pretty_string (const asset &a) const
 
witness_id_type get_scheduled_witness (uint32_t slot_num) const
 Get the witness scheduled for block production in a slot. More...
 
fc::time_point_sec get_slot_time (uint32_t slot_num) const
 
uint32_t get_slot_at_time (fc::time_point_sec when) const
 
void update_witness_schedule ()
 
const chain_id_typeget_chain_id () const
 
const asset_objectget_core_asset () const
 
const asset_dynamic_data_objectget_core_dynamic_data () const
 
const chain_property_objectget_chain_properties () const
 
const global_property_objectget_global_properties () const
 
const dynamic_global_property_objectget_dynamic_global_properties () const
 
const node_property_objectget_node_properties () const
 
const fee_schedulecurrent_fee_schedule () const
 
const account_statistics_objectget_account_stats_by_owner (account_id_type owner) const
 
const witness_schedule_objectget_witness_schedule_object () const
 
time_point_sec head_block_time () const
 
uint32_t head_block_num () const
 
block_id_type head_block_id () const
 
witness_id_type head_block_witness () const
 
node_property_objectnode_properties ()
 
vector< authorityget_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. More...
 
uint32_t last_non_undoable_block_num () const
 
void initialize_evaluators ()
 
void initialize_indexes ()
 Reset the object graph in-memory. More...
 
void init_genesis (const genesis_state_type &genesis_state=genesis_state_type())
 
template<typename EvaluatorType >
void register_evaluator ()
 
asset get_balance (account_id_type owner, asset_id_type asset_id) const
 Retrieve a particular account's balance in a given asset. More...
 
asset get_balance (const account_object &owner, const asset_object &asset_obj) const
 This is an overloaded method. More...
 
void adjust_balance (account_id_type account, asset delta)
 Adjust a particular account's balance in a given asset by a delta. More...
 
void deposit_market_fee_vesting_balance (const account_id_type &account_id, const asset &delta)
 
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. More...
 
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. More...
 
void deposit_cashback (const account_object &acct, share_type amount, bool require_vesting=true)
 
void deposit_witness_pay (const witness_object &wit, share_type amount)
 
void debug_dump ()
 
void apply_debug_updates ()
 
void debug_update (const fc::variant_object &update)
 
asset match (const call_order_object &call, const force_settlement_object &settle, const price &match_price, asset max_settlement, const price &fill_price)
 
bool fill_limit_order (const limit_order_object &order, const asset &pays, const asset &receives, bool cull_if_small, const price &fill_price, const bool is_maker)
 fills limit order More...
 
bool fill_call_order (const call_order_object &order, const asset &pays, const asset &receives, const price &fill_price, const bool is_maker, const asset &margin_fee)
 
bool fill_call_order (const call_order_object &order, const asset &pays, const asset &receives, const price &fill_price, const bool is_maker)
 
bool fill_settle_order (const force_settlement_object &settle, const asset &pays, const asset &receives, const price &fill_price, const bool is_maker)
 
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)
 
void pay_order (const account_object &receiver, const asset &receives, const asset &pays)
 
asset calculate_market_fee (const asset_object &trade_asset, const asset &trade_amount, const bool &is_maker)
 Calculate the market fee that is to be taken. More...
 
asset pay_market_fees (const account_object *seller, const asset_object &recv_asset, const asset &receives, const bool &is_maker)
 
asset pay_force_settle_fees (const asset_object &collecting_asset, const asset &collat_receives)
 
void enable_standby_votes_tracking (bool enable)
 Enable or disable tracking of votes of standby witnesses and committee members. More...
 
fc::future< void > precompute_parallel (const signed_block &block, const uint32_t skip=skip_nothing) const
 
fc::future< void > precompute_parallel (const precomputable_transaction &trx) const
 
void apply_block (const signed_block &next_block, uint32_t skip=skip_nothing)
 
processed_transaction apply_transaction (const signed_transaction &trx, uint32_t skip=skip_nothing)
 
operation_result apply_operation (transaction_evaluation_state &eval_state, const operation &op)
 
int match (const limit_order_object &taker, const limit_order_object &maker, const price &trade_price)
 
int match (const limit_order_object &taker, const call_order_object &maker, const price &trade_price, const price &feed_price, const uint16_t maintenance_collateral_ratio, const optional< price > &maintenance_collateralization, const price &call_pays_price)
 
int match (const limit_order_object &taker, const call_order_object &maker, const price &trade_price, const price &feed_price, const uint16_t maintenance_collateral_ratio, const optional< price > &maintenance_collateralization)
 
- Public Member Functions inherited from graphene::db::object_database
 object_database ()
 
 ~object_database ()
 
void reset_indexes ()
 
void open (const fc::path &data_dir)
 
void flush ()
 
void wipe (const fc::path &data_dir)
 
void close ()
 
template<typename T , typename F >
const T & create (F &&constructor)
 
const objectget_object (object_id_type id) const
 
const objectfind_object (object_id_type id) const
 
template<typename T >
const T & get (object_id_type id) const
 
template<typename T >
const T * find (object_id_type id) const
 
template<uint8_t SpaceID, uint8_t TypeID>
auto find (object_id< SpaceID, TypeID > id) const -> const object_downcast_t< decltype(id)> *
 
template<uint8_t SpaceID, uint8_t TypeID>
auto get (object_id< SpaceID, TypeID > id) const -> const object_downcast_t< decltype(id)> &
 
template<typename IndexType >
IndexType * add_index ()
 
template<typename IndexType , typename SecondaryIndexType , typename... Args>
SecondaryIndexType * add_secondary_index (Args...args)
 
void pop_undo ()
 
fc::path get_data_dir () const
 
template<typename IndexType >
const IndexType & get_index_type () const
 
template<typename T >
const indexget_index () const
 
const indexget_index (uint8_t space_id, uint8_t type_id) const
 
const indexget_index (object_id_type id) const
 
const objectinsert (object &&obj)
 
void remove (const object &obj)
 
template<typename T , typename Lambda >
void modify (const T &obj, const Lambda &m)
 

Public Attributes

fc::signal< void(const signed_block &)> applied_block
 
fc::signal< void(const signed_transaction &)> on_pending_transaction
 
fc::signal< void(const vector< object_id_type > &, const flat_set< account_id_type > &)> new_objects
 
fc::signal< void(const vector< object_id_type > &, const flat_set< account_id_type > &)> changed_objects
 
fc::signal< void(const vector< object_id_type > &, const vector< const object * > &, const flat_set< account_id_type > &)> removed_objects
 
- Public Attributes inherited from graphene::db::object_database
undo_database _undo_db
 

Protected Member Functions

void pop_undo ()
 
void notify_applied_block (const signed_block &block)
 
void notify_on_pending_transaction (const signed_transaction &tx)
 
void notify_changed_objects ()
 
- Protected Member Functions inherited from graphene::db::object_database
template<typename IndexType >
IndexType & get_mutable_index_type ()
 
template<typename T >
indexget_mutable_index ()
 
indexget_mutable_index (object_id_type id)
 
indexget_mutable_index (uint8_t space_id, uint8_t type_id)
 
void globally_settle_asset (const asset_object &bitasset, const price &settle_price)
 Market Helpers More...
 
void cancel_settle_order (const force_settlement_object &order, bool create_virtual_op=true)
 
void cancel_limit_order (const limit_order_object &order, bool create_virtual_op=true, bool skip_cancel_fee=false)
 
void revive_bitasset (const asset_object &bitasset)
 
void cancel_bid (const collateral_bid_object &bid, bool create_virtual_op=true)
 
void execute_bid (const collateral_bid_object &bid, share_type debt_covered, share_type collateral_from_fund, const price_feed &current_feed)
 
bool apply_order_before_hardfork_625 (const limit_order_object &new_order_object, bool allow_black_swan=true)
 Process a new limit order through the markets. More...
 
bool apply_order (const limit_order_object &new_order_object, bool allow_black_swan=true)
 
std::deque< precomputable_transaction_popped_tx
 
processed_transaction validate_transaction (const signed_transaction &trx)
 
generic_operation_result process_tickets ()
 

Additional Inherited Members

- Static Public Member Functions inherited from graphene::db::object_database
template<typename T >
static const T & cast (const object &obj)
 
template<typename T >
static T & cast (object &obj)
 

Detailed Description

tracks the blockchain state in an extensible manner

Definition at line 70 of file database.hpp.

Member Enumeration Documentation

Enumerator
skip_nothing 
skip_witness_signature 

used while reindexing

skip_transaction_signatures 

used by non-witness nodes

skip_transaction_dupe_check 

used while reindexing

skip_block_size_check 

used when applying locally generated transactions

skip_tapos_check 

used while reindexing – note this skips expiration check as well

skip_merkle_check 

used while reindexing

skip_assert_evaluation 

used while reindexing

skip_undo_history_check 

used while reindexing

skip_witness_schedule_check 

used while reindexing

Definition at line 78 of file database.hpp.

Constructor & Destructor Documentation

graphene::chain::database::database ( )

Definition at line 44 of file db_management.cpp.

graphene::chain::database::~database ( )

Definition at line 50 of file db_management.cpp.

Member Function Documentation

signed_block graphene::chain::database::_generate_block ( const fc::time_point_sec  when,
witness_id_type  witness_id,
const fc::ecc::private_key block_signing_private_key 
)

Definition at line 383 of file db_block.cpp.

bool graphene::chain::database::_push_block ( const signed_block b)

Definition at line 131 of file db_block.cpp.

processed_transaction graphene::chain::database::_push_transaction ( const precomputable_transaction trx)

Definition at line 279 of file db_block.cpp.

void graphene::chain::database::add_checkpoints ( const flat_map< uint32_t, block_id_type > &  checkpts)

Definition at line 799 of file db_block.cpp.

void graphene::chain::database::adjust_balance ( account_id_type  account,
asset  delta 
)

Adjust a particular account's balance in a given asset by a delta.

Parameters
accountID of account whose balance should be adjusted
deltaAsset ID and amount to adjust balance by

Definition at line 54 of file db_balance.cpp.

void graphene::chain::database::apply_block ( const signed_block next_block,
uint32_t  skip = skip_nothing 
)

Definition at line 555 of file db_block.cpp.

void graphene::chain::database::apply_debug_updates ( )

Definition at line 188 of file db_debug.cpp.

operation_result graphene::chain::database::apply_operation ( transaction_evaluation_state eval_state,
const operation op 
)

Definition at line 754 of file db_block.cpp.

bool graphene::chain::database::apply_order ( const limit_order_object new_order_object,
bool  allow_black_swan = true 
)

Definition at line 427 of file db_market.cpp.

bool graphene::chain::database::apply_order_before_hardfork_625 ( const limit_order_object new_order_object,
bool  allow_black_swan = true 
)

Process a new limit order through the markets.

Parameters
orderThe new order to process
Returns
true if order was completely filled; false otherwise

This function takes a new limit order, and runs the markets attempting to match it with existing orders already on the books.

Definition at line 359 of file db_market.cpp.

processed_transaction graphene::chain::database::apply_transaction ( const signed_transaction trx,
uint32_t  skip = skip_nothing 
)

Definition at line 663 of file db_block.cpp.

bool graphene::chain::database::before_last_checkpoint ( ) const

Definition at line 805 of file db_block.cpp.

asset graphene::chain::database::calculate_market_fee ( const asset_object trade_asset,
const asset trade_amount,
const bool &  is_maker 
)

Calculate the market fee that is to be taken.

Parameters
trade_assetthe asset (passed in to avoid a lookup)
trade_amountthe quantity that the fee calculation is based upon
is_makerTRUE if this is the fee for a maker, FALSE if taker

Definition at line 1342 of file db_market.cpp.

void graphene::chain::database::cancel_bid ( const collateral_bid_object bid,
bool  create_virtual_op = true 
)

Definition at line 178 of file db_market.cpp.

void graphene::chain::database::cancel_limit_order ( const limit_order_object order,
bool  create_virtual_op = true,
bool  skip_cancel_fee = false 
)

Definition at line 238 of file db_market.cpp.

void graphene::chain::database::cancel_settle_order ( const force_settlement_object order,
bool  create_virtual_op = true 
)

Definition at line 223 of file db_market.cpp.

bool graphene::chain::database::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 
)

Starting with the least collateralized orders, fill them if their call price is above the max(lowest bid,call_limit).

This method will return true if it filled a short or limit

Parameters
mia- the market issued asset that should be called.
enable_black_swan- when adjusting collateral, triggering a black swan is invalid and will throw if enable_black_swan is not set to true.
for_new_limit_order- true if this function is called when matching call orders with a new limit order. (Only relevent before hardfork 625. apply_order_before_hardfork_625() is only function that calls this with for_new_limit_order true.)
bitasset_ptr- an optional pointer to the bitasset_data object of the asset
Returns
true if a margin call was executed.

Definition at line 1100 of file db_market.cpp.

void graphene::chain::database::clear_pending ( )

Definition at line 520 of file db_block.cpp.

void graphene::chain::database::close ( bool  rewind = true)

Definition at line 227 of file db_management.cpp.

const fee_schedule & graphene::chain::database::current_fee_schedule ( ) const

Definition at line 59 of file db_getter.cpp.

void graphene::chain::database::debug_dump ( )

This method dumps the state of the blockchain in a semi-human readable form for the purpose of tracking down funds and mismatches in currency allocation

Definition at line 41 of file db_debug.cpp.

void graphene::chain::database::debug_update ( const fc::variant_object update)

Definition at line 198 of file db_debug.cpp.

void graphene::chain::database::deposit_cashback ( const account_object acct,
share_type  amount,
bool  require_vesting = true 
)

Definition at line 206 of file db_balance.cpp.

optional< vesting_balance_id_type > graphene::chain::database::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.

If the given optional VBID is not valid(), or it does not have a CDD vesting policy, or the owner / vesting_seconds of the policy does not match the parameter, then credit amount to newly created VBID and return it.

Otherwise, credit amount to ovbid.

Returns
ID of newly created VBO, but only if VBO was created.

Definition at line 156 of file db_balance.cpp.

void graphene::chain::database::deposit_market_fee_vesting_balance ( const account_id_type &  account_id,
const asset delta 
)

Definition at line 127 of file db_balance.cpp.

void graphene::chain::database::deposit_witness_pay ( const witness_object wit,
share_type  amount 
)

Definition at line 248 of file db_balance.cpp.

void graphene::chain::database::enable_standby_votes_tracking ( bool  enable)
inline

Enable or disable tracking of votes of standby witnesses and committee members.

Definition at line 518 of file database.hpp.

void graphene::chain::database::execute_bid ( const collateral_bid_object bid,
share_type  debt_covered,
share_type  collateral_from_fund,
const price_feed current_feed 
)

Definition at line 193 of file db_market.cpp.

optional< signed_block > graphene::chain::database::fetch_block_by_id ( const block_id_type id) const

Definition at line 67 of file db_block.cpp.

optional< signed_block > graphene::chain::database::fetch_block_by_number ( uint32_t  num) const

Definition at line 75 of file db_block.cpp.

bool graphene::chain::database::fill_call_order ( const call_order_object order,
const asset pays,
const asset receives,
const price fill_price,
const bool  is_maker,
const asset margin_fee 
)

Definition at line 943 of file db_market.cpp.

bool graphene::chain::database::fill_call_order ( const call_order_object order,
const asset pays,
const asset receives,
const price fill_price,
const bool  is_maker 
)
inline

Definition at line 473 of file database.hpp.

bool graphene::chain::database::fill_limit_order ( const limit_order_object order,
const asset pays,
const asset receives,
bool  cull_if_small,
const price fill_price,
const bool  is_maker 
)

fills limit order

Parameters
orderthe order
payswhat the account is paying
receiveswhat the account is receiving
cull_if_smalltake care of dust
fill_pricethe transaction price
is_makerTRUE if this order is maker, FALSE if taker
Returns
true if the order was completely filled and thus freed.

Definition at line 829 of file db_market.cpp.

bool graphene::chain::database::fill_settle_order ( const force_settlement_object settle,
const asset pays,
const asset receives,
const price fill_price,
const bool  is_maker 
)

Definition at line 1034 of file db_market.cpp.

signed_block graphene::chain::database::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 at line 368 of file db_block.cpp.

const account_statistics_object & graphene::chain::database::get_account_stats_by_owner ( account_id_type  owner) const

Definition at line 139 of file db_getter.cpp.

const vector< optional< operation_history_object > > & graphene::chain::database::get_applied_operations ( ) const

Definition at line 548 of file db_block.cpp.

asset graphene::chain::database::get_balance ( account_id_type  owner,
asset_id_type  asset_id 
) const

Retrieve a particular account's balance in a given asset.

Parameters
ownerAccount whose balance should be retrieved
asset_idID of the asset to get balance in
Returns
owner's balance in asset

Definition at line 35 of file db_balance.cpp.

asset graphene::chain::database::get_balance ( const account_object owner,
const asset_object asset_obj 
) const

This is an overloaded method.

Definition at line 44 of file db_balance.cpp.

block_id_type graphene::chain::database::get_block_id_for_num ( uint32_t  block_num) const

Definition at line 62 of file db_block.cpp.

std::vector< block_id_type > graphene::chain::database::get_block_ids_on_fork ( block_id_type  head_of_fork) const

Definition at line 92 of file db_block.cpp.

const chain_id_type & graphene::chain::database::get_chain_id ( ) const

Definition at line 84 of file db_getter.cpp.

const chain_property_object & graphene::chain::database::get_chain_properties ( ) const

Definition at line 49 of file db_getter.cpp.

const flat_map<uint32_t,block_id_type> graphene::chain::database::get_checkpoints ( ) const
inline

Definition at line 148 of file database.hpp.

const asset_object & graphene::chain::database::get_core_asset ( ) const

Definition at line 34 of file db_getter.cpp.

const asset_dynamic_data_object & graphene::chain::database::get_core_dynamic_data ( ) const

Definition at line 39 of file db_getter.cpp.

const dynamic_global_property_object & graphene::chain::database::get_dynamic_global_properties ( ) const

Definition at line 54 of file db_getter.cpp.

const global_property_object & graphene::chain::database::get_global_properties ( ) const

Definition at line 44 of file db_getter.cpp.

asset graphene::chain::database::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.

Parameters
ownerAccount whose balance should be retrieved
asset_idID of the asset to get balance in
Returns
owner's balance in asset

Definition at line 114 of file db_balance.cpp.

const node_property_object & graphene::chain::database::get_node_properties ( ) const

Definition at line 89 of file db_getter.cpp.

const signed_transaction & graphene::chain::database::get_recent_transaction ( const transaction_id_type trx_id) const

Definition at line 84 of file db_block.cpp.

witness_id_type graphene::chain::database::get_scheduled_witness ( uint32_t  slot_num) const

Get the witness scheduled for block production in a slot.

slot_num always corresponds to a time in the future.

If slot_num == 1, returns the next scheduled witness. If slot_num == 2, returns the next scheduled witness after 1 block gap.

Use the get_slot_time() and get_slot_at_time() functions to convert between slot_num and timestamp.

Passing slot_num == 0 returns GRAPHENE_NULL_WITNESS

Definition at line 36 of file db_witness_schedule.cpp.

uint32_t graphene::chain::database::get_slot_at_time ( fc::time_point_sec  when) const

Get the last slot which occurs AT or BEFORE the given time.

The return value is the greatest value N such that get_slot_time( N ) <= when.

If no such N exists, return 0.

Definition at line 74 of file db_witness_schedule.cpp.

fc::time_point_sec graphene::chain::database::get_slot_time ( uint32_t  slot_num) const

Get the time at which the given slot occurs.

If slot_num == 0, return time_point_sec().

If slot_num == N for N > 0, return the Nth next block-interval-aligned time greater than head_block_time().

Definition at line 44 of file db_witness_schedule.cpp.

vector< authority > graphene::chain::database::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.

Parameters
accountThe account whose authority is required
opThe operation requring the specified account's authority
rejected_authorities[Optional] A pointer to a map that should be populated with the custom authorities which were valid, but rejected because the operation did not comply with the restrictions
Returns
A vector of authorities which can be used to authorize op in place of account

Definition at line 99 of file db_getter.cpp.

const witness_schedule_object & graphene::chain::database::get_witness_schedule_object ( ) const

Definition at line 144 of file db_getter.cpp.

void graphene::chain::database::globally_settle_asset ( const asset_object mia,
const price settlement_price 
)

Market Helpers

All margin positions are force closed at the swan price Collateral received goes into a force-settlement fund No new margin positions can be created for this asset Force settlement happens without delay at the swan price, deducting from force-settlement fund No more asset updates may be issued.

Definition at line 57 of file db_market.cpp.

block_id_type graphene::chain::database::head_block_id ( ) const

Definition at line 74 of file db_getter.cpp.

uint32_t graphene::chain::database::head_block_num ( ) const

Definition at line 69 of file db_getter.cpp.

time_point_sec graphene::chain::database::head_block_time ( ) const

Definition at line 64 of file db_getter.cpp.

witness_id_type graphene::chain::database::head_block_witness ( ) const
void graphene::chain::database::init_genesis ( const genesis_state_type genesis_state = genesis_state_type())

Definition at line 242 of file db_init.cpp.

void graphene::chain::database::initialize_evaluators ( )

Definition at line 140 of file db_init.cpp.

void graphene::chain::database::initialize_indexes ( )

Reset the object graph in-memory.

Definition at line 197 of file db_init.cpp.

bool graphene::chain::database::is_known_block ( const block_id_type id) const
Returns
true if the block is in our fork DB or saved to disk as part of the official chain, otherwise return false

Definition at line 47 of file db_block.cpp.

bool graphene::chain::database::is_known_transaction ( const transaction_id_type id) const

Only return true if the transaction has not expired or been invalidated. If this method is called with a VERY old transaction we will return false, they should query things by blocks if they are that old.

Definition at line 56 of file db_block.cpp.

uint32_t graphene::chain::database::last_non_undoable_block_num ( ) const

Definition at line 127 of file db_getter.cpp.

int graphene::chain::database::match ( const limit_order_object usd,
const limit_order_object core,
const price match_price 
)

Matches the two orders, the first parameter is taker, the second is maker.

Returns
a bit field indicating which orders were filled (and thus removed)

0 - no orders were matched 1 - taker was filled 2 - maker was filled 3 - both were filled

Definition at line 605 of file db_market.cpp.

int graphene::chain::database::match ( const limit_order_object taker,
const call_order_object maker,
const price trade_price,
const price feed_price,
const uint16_t  maintenance_collateral_ratio,
const optional< price > &  maintenance_collateralization,
const price call_pays_price 
)

Definition at line 672 of file db_market.cpp.

int graphene::chain::database::match ( const limit_order_object taker,
const call_order_object maker,
const price trade_price,
const price feed_price,
const uint16_t  maintenance_collateral_ratio,
const optional< price > &  maintenance_collateralization 
)
inline

Definition at line 430 of file database.hpp.

asset graphene::chain::database::match ( const call_order_object call,
const force_settlement_object settle,
const price match_price,
asset  max_settlement,
const price fill_price 
)

Matches the two orders, the first parameter is taker, the second is maker.

Returns
the amount of asset settled

If the least collateralized call position lacks sufficient collateral to cover at the match price then this indicates a black swan event according to the price feed, but only the market can trigger a black swan. So now we must cancel the forced settlement object.

Definition at line 728 of file db_market.cpp.

node_property_object & graphene::chain::database::node_properties ( )

Definition at line 94 of file db_getter.cpp.

void graphene::chain::database::notify_applied_block ( const signed_block block)
protected

Definition at line 495 of file db_notify.cpp.

void graphene::chain::database::notify_changed_objects ( )
protected

Definition at line 505 of file db_notify.cpp.

void graphene::chain::database::notify_on_pending_transaction ( const signed_transaction tx)
protected

Definition at line 500 of file db_notify.cpp.

void graphene::chain::database::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.

Opens a database in the specified directory. If no initialized database is found, genesis_loader is called and its return value is used as the genesis state when initializing the new database

genesis_loader will not be called if an existing database is found.

Parameters
data_dirPath to open or create database in
genesis_loaderA callable object which returns the genesis state to initialize new databases on
db_versiona version string that changes when the internal database format and/or logic is modified

Definition at line 173 of file db_management.cpp.

asset graphene::chain::database::pay_force_settle_fees ( const asset_object collecting_asset,
const asset collat_receives 
)

Definition at line 1485 of file db_market.cpp.

asset graphene::chain::database::pay_market_fees ( const account_object seller,
const asset_object recv_asset,
const asset receives,
const bool &  is_maker 
)

Definition at line 1376 of file db_market.cpp.

void graphene::chain::database::pay_order ( const account_object receiver,
const asset receives,
const asset pays 
)

Definition at line 1330 of file db_market.cpp.

void graphene::chain::database::pop_block ( )

Removes the most recent block from the database and undoes any changes it made.

Definition at line 504 of file db_block.cpp.

void graphene::chain::database::pop_undo ( )
inlineprotected

Definition at line 545 of file database.hpp.

fc::future< void > graphene::chain::database::precompute_parallel ( const signed_block block,
const uint32_t  skip = skip_nothing 
) const

Precomputes digests, signatures and operation validations depending on skip flags. "Expensive" computations may be done in a parallel thread.

Parameters
blockthe block to preprocess
skipindicates which computations can be skipped
Returns
a future that will resolve to the input block with precomputations applied

Definition at line 829 of file db_block.cpp.

fc::future< void > graphene::chain::database::precompute_parallel ( const precomputable_transaction trx) const

Precomputes digests, signatures and operation validations. "Expensive" computations may be done in a parallel thread.

Parameters
trxthe transaction to preprocess
Returns
a future that will resolve to the input transaction with precomputations applied

Definition at line 866 of file db_block.cpp.

generic_operation_result graphene::chain::database::process_tickets ( )

Definition at line 605 of file db_update.cpp.

uint32_t graphene::chain::database::push_applied_operation ( const operation op)

This method is used to track appied operations during the evaluation of a block, these operations should include any operation actually included in a transaction as well as any implied/virtual operations that resulted, such as filling an order. The applied operations is cleared after applying each block and calling the block observers which may want to index these operations.

Returns
the op_id which can be used to set the result after it has finished being applied.

Definition at line 527 of file db_block.cpp.

bool graphene::chain::database::push_block ( const signed_block new_block,
uint32_t  skip = skip_nothing 
)

Push block "may fail" in which case every partial change is unwound. After push block is successful the block is appended to the chain database on disk.

Returns
true if we switched forks as a result of this push.

Definition at line 116 of file db_block.cpp.

processed_transaction graphene::chain::database::push_proposal ( const proposal_object proposal)
Exceptions
fc::exceptionif the proposed transaction fails to apply.

Definition at line 328 of file db_block.cpp.

processed_transaction graphene::chain::database::push_transaction ( const precomputable_transaction trx,
uint32_t  skip = skip_nothing 
)

Attempts to push the transaction into the pending queue

When called to push a locally generated transaction, set the skip_block_size_check bit on the skip argument. This will allow the transaction to be pushed even if it causes the pending block size to exceed the maximum block size. Although the transaction will probably not propagate further now, as the peers are likely to have their pending queues full as well, it will be kept in the queue to be propagated later when a new block flushes out the pending queues.

Definition at line 267 of file db_block.cpp.

template<typename EvaluatorType >
void graphene::chain::database::register_evaluator ( )
inline

Definition at line 305 of file database.hpp.

void graphene::chain::database::reindex ( fc::path  data_dir)

Rebuild object graph from block history and open detabase.

This method may be called after or instead of database::open, and will rebuild the object graph by replaying blockchain history. When this method exits successfully, the database will be open.

Definition at line 55 of file db_management.cpp.

void graphene::chain::database::revive_bitasset ( const asset_object bitasset)

Definition at line 129 of file db_market.cpp.

void graphene::chain::database::set_applied_operation_result ( uint32_t  op_id,
const operation_result r 
)

Definition at line 537 of file db_block.cpp.

string graphene::chain::database::to_pretty_string ( const asset a) const

Definition at line 49 of file db_balance.cpp.

void graphene::chain::database::update_witness_schedule ( )

High performance random generator http://xorshift.di.unimi.it/

Definition at line 104 of file db_witness_schedule.cpp.

processed_transaction graphene::chain::database::validate_transaction ( const signed_transaction trx)

This method validates transactions without adding it to the pending state.

Returns
true if the transaction would validate

Definition at line 304 of file db_block.cpp.

void graphene::chain::database::wipe ( const fc::path data_dir,
bool  include_blocks 
)

wipe Delete database from disk, and potentially the raw chain as well.

Parameters
include_blocksIf true, delete the raw chain as well as the database.

Will close the database before wiping. Database will be closed when this function returns.

Definition at line 162 of file db_management.cpp.

uint32_t graphene::chain::database::witness_participation_rate ( ) const

Calculate the percent of block production slots that were missed in the past 128 blocks, not including the current block.

Definition at line 98 of file db_witness_schedule.cpp.

Member Data Documentation

std::deque< precomputable_transaction > graphene::chain::database::_popped_tx

when popping a block, the transactions that were removed get cached here so they can be reapplied at the proper time

Definition at line 511 of file database.hpp.

fc::signal<void(const signed_block&)> graphene::chain::database::applied_block

This signal is emitted after all operations and virtual operation for a block have been applied but before the get_applied_operations() are cleared.

You may not yield from this callback because the blockchain is holding the write lock and may be in an "inconstant state" until after it is released.

Definition at line 197 of file database.hpp.

fc::signal<void(const vector<object_id_type>&, const flat_set<account_id_type>&)> graphene::chain::database::changed_objects

Emitted After a block has been applied and committed. The callback should not yield and should execute quickly.

Definition at line 215 of file database.hpp.

fc::signal<void(const vector<object_id_type>&, const flat_set<account_id_type>&)> graphene::chain::database::new_objects

Emitted After a block has been applied and committed. The callback should not yield and should execute quickly.

Definition at line 209 of file database.hpp.

fc::signal<void(const signed_transaction&)> graphene::chain::database::on_pending_transaction

This signal is emitted any time a new transaction is added to the pending block state.

Definition at line 203 of file database.hpp.

fc::signal<void(const vector<object_id_type>&, const vector<const object*>&, const flat_set<account_id_type>&)> graphene::chain::database::removed_objects

this signal is emitted any time an object is removed and contains a pointer to the last value of every object that was removed.

Definition at line 220 of file database.hpp.


The documentation for this class was generated from the following files: