|
Monero
|
handles core cryptonote functionality More...
#include <cryptonote_core.h>


Public Member Functions | |
| core (i_cryptonote_protocol *pprotocol) | |
| constructor | |
| bool | handle_get_objects (NOTIFY_REQUEST_GET_OBJECTS::request &arg, NOTIFY_RESPONSE_GET_OBJECTS::request &rsp, cryptonote_connection_context &context) |
| retrieves a set of blocks and their transactions, and possibly other transactions | |
| bool | on_idle () |
| calls various idle routines | |
| bool | handle_incoming_tx (const blobdata &tx_blob, tx_verification_context &tvc, relay_method tx_relay, bool relayed) |
| handles an incoming transaction | |
| bool | handle_single_incoming_block (const blobdata &block_blob, const block *b, block_verification_context &bvc, pool_supplement &extra_block_txs, bool update_miner_blocktemplate=true) |
| handles a single incoming block | |
| bool | handle_incoming_block (const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true) |
| handles an incoming block as part of a batch | |
| bool | handle_incoming_block (const blobdata &block_blob, const block *b, block_verification_context &bvc, pool_supplement &extra_block_txs, bool update_miner_blocktemplate=true) |
| bool | prepare_handle_incoming_blocks (const std::vector< block_complete_entry > &blocks_entry, std::vector< block > &blocks) |
| performs some preprocessing on a group of incoming blocks to speed up verification | |
| bool | cleanup_handle_incoming_blocks (bool force_sync=false) |
| incoming blocks post-processing, cleanup, and disk sync | |
| bool | check_incoming_block_size (const blobdata &block_blob) const |
| check the size of a block against the current maximum | |
| i_cryptonote_protocol * | get_protocol () |
| get the cryptonote protocol instance | |
| virtual bool | handle_block_found (block &b, block_verification_context &bvc) override |
| stores and relays a block found by a miner | |
| virtual bool | get_block_template (block &b, const account_public_address &adr, difficulty_type &diffic, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) override |
| creates a new block to mine against | |
| virtual bool | get_block_template (block &b, const crypto::hash *prev_block, const account_public_address &adr, difficulty_type &diffic, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) |
| bool | get_miner_data (uint8_t &major_version, uint64_t &height, crypto::hash &prev_id, crypto::hash &seed_hash, difficulty_type &difficulty, uint64_t &median_weight, uint64_t &already_generated_coins, std::vector< tx_block_template_backlog_entry > &tx_backlog) |
| gets data required to create a block template and start mining on it | |
| virtual void | on_transactions_relayed (epee::span< const cryptonote::blobdata > tx_blobs, relay_method tx_relay) final |
| called when a transaction is relayed. | |
| miner & | get_miner () |
| gets the miner instance | |
| const miner & | get_miner () const |
| gets the miner instance (const) | |
| bool | init (const boost::program_options::variables_map &vm, const test_options *test_options=NULL, const GetCheckpointsCallback &get_checkpoints=nullptr, bool allow_dns=true) |
| initializes the core as needed | |
| bool | set_genesis_block (const block &b) |
| clears the blockchain and starts a new one | |
| bool | deinit () |
| performs safe shutdown steps for core and core components | |
| void | test_drop_download () |
| sets to drop blocks downloaded (for testing) | |
| void | test_drop_download_height (uint64_t height) |
| sets to drop blocks downloaded below a certain height | |
| bool | get_test_drop_download () const |
| gets whether or not to drop blocks (for testing) | |
| bool | get_test_drop_download_height () const |
| gets whether or not to drop blocks | |
| virtual uint64_t | get_current_blockchain_height () const final |
| get the current height of the blockchain | |
| void | get_blockchain_top (uint64_t &height, crypto::hash &top_id) const |
| get the hash and height of the most recent block | |
| bool | get_blocks (uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block > > &blocks, std::vector< cryptonote::blobdata > &txs) const |
| bool | get_blocks (uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block > > &blocks) const |
| get blocks from blocks based on start height and count | |
| bool | get_blocks (uint64_t start_offset, size_t count, std::vector< block > &blocks) const |
| get blocks from blocks based on start height and count | |
| template<class t_ids_container, class t_blocks_container, class t_missed_container> | |
| bool | get_blocks (const t_ids_container &block_ids, t_blocks_container &blocks, t_missed_container &missed_bs) const |
| gets blocks based on a list of block hashes | |
| crypto::hash | get_block_id_by_height (uint64_t height) const |
| gets a block's hash given a height | |
| bool | get_transactions (const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs, bool pruned=false) const |
| bool | get_split_transactions_blobs (const std::vector< crypto::hash > &txs_ids, std::vector< std::tuple< crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata > > &txs, std::vector< crypto::hash > &missed_txs) const |
| bool | get_transactions (const std::vector< crypto::hash > &txs_ids, std::vector< transaction > &txs, std::vector< crypto::hash > &missed_txs, bool pruned=false) const |
| bool | get_block_by_hash (const crypto::hash &h, block &blk, bool *orphan=NULL) const |
| gets the block with a given hash | |
| bool | get_alternative_blocks (std::vector< block > &blocks) const |
| compiles a list of all blocks stored as alternative chains | |
| size_t | get_alternative_blocks_count () const |
| returns the number of alternative blocks stored | |
| void | set_cryptonote_protocol (i_cryptonote_protocol *pprotocol) |
| set the pointer to the cryptonote protocol object to use | |
| const checkpoints & | get_checkpoints () const |
| get a set of blockchain checkpoint hashes | |
| void | set_checkpoints (checkpoints &&chk_pts) |
| assign a set of blockchain checkpoint hashes | |
| void | set_checkpoints_file_path (const std::string &path) |
| set the file path to read from when loading checkpoints | |
| void | set_enforce_dns_checkpoints (bool enforce_dns) |
| set whether or not we enforce DNS checkpoints | |
| void | disable_dns_checkpoints (bool disable=true) |
| set whether or not to enable or disable DNS checkpoints | |
| bool | pool_has_tx (const crypto::hash &txid) const |
| checks if the pool has a transaction with the given hash | |
| bool | get_pool_transactions (std::vector< transaction > &txs, bool include_sensitive_txes=false) const |
| get a list of all transactions in the pool | |
| bool | get_txpool_backlog (std::vector< tx_backlog_entry > &backlog, bool include_sensitive_txes=false) const |
| bool | get_pool_transaction_hashes (std::vector< crypto::hash > &txs, bool include_sensitive_txes=false) const |
| get a list of all transactions in the pool | |
| bool | get_pool_transactions_info (const std::vector< crypto::hash > &txids, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > &txs, bool include_sensitive_txes=false) const |
| bool | get_pool_info (time_t start_time, bool include_sensitive_txes, size_t max_tx_count, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > &added_txs, std::vector< crypto::hash > &remaining_added_txids, std::vector< crypto::hash > &removed_txs, bool &incremental) const |
| get info necessary for update of pool-related info in a wallet, preferably incremental | |
| bool | get_pool_transaction_stats (struct txpool_stats &stats, bool include_sensitive_txes=false) const |
| get a list of all transactions in the pool | |
| bool | get_pool_transaction (const crypto::hash &id, cryptonote::blobdata &tx, relay_category tx_category) const |
| get a specific transaction from the pool | |
| bool | get_pool_transactions_and_spent_keys_info (std::vector< tx_info > &tx_infos, std::vector< spent_key_image_info > &key_image_infos, bool include_sensitive_txes=false) const |
| bool | get_pool_for_rpc (std::vector< cryptonote::rpc::tx_in_pool > &tx_infos, cryptonote::rpc::key_images_with_tx_hashes &key_image_infos) const |
| get information about all transactions and key images in the pool | |
| size_t | get_pool_transactions_count (bool include_sensitive_txes=false) const |
| get the total number of transactions in the pool | |
| size_t | get_blockchain_total_transactions () const |
| gets the total number of transactions on the main chain | |
| bool | have_block_unlocked (const crypto::hash &id, int *where=NULL) const |
| bool | have_block (const crypto::hash &id, int *where=NULL) const |
| bool | get_short_chain_history (std::list< crypto::hash > &ids, uint64_t ¤t_height) const |
| gets the hashes for a subset of the blockchain | |
| bool | find_blockchain_supplement (const std::list< crypto::hash > &qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp) const |
| bool | find_blockchain_supplement (const uint64_t req_start_block, const std::list< crypto::hash > &qblock_ids, std::vector< std::pair< std::pair< cryptonote::blobdata, crypto::hash >, std::vector< std::pair< crypto::hash, cryptonote::blobdata > > > > &blocks, uint64_t &total_height, uint64_t &start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const |
| bool | get_tx_outputs_gindexs (const crypto::hash &tx_id, std::vector< uint64_t > &indexs) const |
| gets the global indices for outputs from a given transaction | |
| bool | get_tx_outputs_gindexs (const crypto::hash &tx_id, size_t n_txes, std::vector< std::vector< uint64_t > > &indexs) const |
| crypto::hash | get_tail_id () const |
| get the hash of the most recent block on the blockchain | |
| difficulty_type | get_block_cumulative_difficulty (uint64_t height) const |
| bool | get_outs (const COMMAND_RPC_GET_OUTPUTS_BIN::request &req, COMMAND_RPC_GET_OUTPUTS_BIN::response &res) const |
| gets specific outputs to mix with | |
| bool | get_output_distribution (uint64_t amount, uint64_t from_height, uint64_t to_height, uint64_t &start_height, std::vector< uint64_t > &distribution, uint64_t &base) const |
| gets per block distribution of outputs of a given amount | |
| void | pause_mine () |
| void | resume_mine () |
| Blockchain & | get_blockchain_storage () |
| gets the Blockchain instance | |
| const Blockchain & | get_blockchain_storage () const |
| gets the Blockchain instance (const) | |
| std::string | print_pool (bool short_format) const |
| get a string containing human-readable pool information | |
| virtual bool | is_synchronized () const final |
| gets the core synchronization status | |
| void | on_synchronized () |
| void | safesyncmode (const bool onoff) |
| Put DB in safe sync mode. | |
| void | set_target_blockchain_height (uint64_t target_blockchain_height) |
| sets the target blockchain height | |
| uint64_t | get_target_blockchain_height () const |
| gets the target blockchain height | |
| uint8_t | get_ideal_hard_fork_version () const |
| returns the newest hardfork version known to the blockchain | |
| uint8_t | get_ideal_hard_fork_version (uint64_t height) const |
| return the ideal hard fork version for a given block height | |
| uint8_t | get_hard_fork_version (uint64_t height) const |
| return the hard fork version for a given block height | |
| uint64_t | get_earliest_ideal_height_for_version (uint8_t version) const |
| return the earliest block a given version may activate | |
| std::time_t | get_start_time () const |
| gets start_time | |
| bool | update_checkpoints (const bool skip_dns=false) |
| tells the Blockchain to update its checkpoints | |
| void | graceful_exit () |
| tells the daemon to wind down operations and stop running | |
| void | stop () |
| stops the daemon running | |
| bool | is_key_image_spent (const crypto::key_image &key_im) const |
| check if a key image is already spent on the blockchain | |
| bool | are_key_images_spent (const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const |
| check if multiple key images are spent | |
| bool | are_key_images_spent_in_pool (const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const |
| check if multiple key images are spent in the transaction pool | |
| size_t | get_block_sync_size (uint64_t height) const |
| get the number of blocks to sync in one go | |
| std::pair< boost::multiprecision::uint128_t, boost::multiprecision::uint128_t > | get_coinbase_tx_sum (const uint64_t start_offset, const size_t count) |
| get the sum of coinbase tx amounts between blocks | |
| network_type | get_nettype () const |
| get the network type we're on | |
| bool | is_update_available () const |
| check whether an update is known to be available or not | |
| uint64_t | prevalidate_block_hashes (uint64_t height, const std::vector< crypto::hash > &hashes, const std::vector< uint64_t > &weights) |
| check a set of hashes against the precompiled hash set | |
| uint64_t | get_free_space () const |
| get free disk space on the blockchain partition | |
| bool | offline () const |
| get whether the core is running offline | |
| uint32_t | get_blockchain_pruning_seed () const |
| get the blockchain pruning seed | |
| bool | prune_blockchain (uint32_t pruning_seed=0) |
| prune the blockchain | |
| bool | update_blockchain_pruning () |
| incrementally prunes blockchain | |
| bool | check_blockchain_pruning () |
| checks the blockchain pruning if enabled | |
| bool | is_within_compiled_block_hash_area (uint64_t height) const |
| checks whether a given block height is included in the precompiled block hash area | |
| bool | has_block_weights (uint64_t height, uint64_t nblocks) const |
| checks whether block weights are known for the given range | |
| void | flush_invalid_blocks () |
| flushes the invalid block cache | |
| bool | get_txpool_complement (const std::vector< crypto::hash > &hashes, std::vector< cryptonote::blobdata > &txes) |
| returns the set of transactions in the txpool which are not in the argument | |
| Public Member Functions inherited from cryptonote::i_core_events | |
| virtual | ~i_core_events () noexcept |
Static Public Member Functions | |
| static void | init_options (boost::program_options::options_description &desc) |
| adds command line options to the given options set | |
| static bool | check_tx_semantic (const transaction &tx, tx_verification_context &tvc, uint8_t hf_version) |
| validates some simple properties of a transaction | |
| static bool | check_tx_inputs_keyimages_diff (const transaction &tx) |
| verify that each input key image in a transaction is unique | |
| static bool | check_tx_inputs_ring_members_diff (const transaction &tx, const uint8_t hf_version) |
| verify that each ring uses distinct members | |
| static bool | check_tx_inputs_keyimages_domain (const transaction &tx) |
| verify that each input key image in a transaction is in the valid domain | |
Private Types | |
| enum | { UPDATES_DISABLED , UPDATES_NOTIFY , UPDATES_DOWNLOAD , UPDATES_UPDATE } |
Private Member Functions | |
| bool | add_new_tx (transaction &tx, const crypto::hash &tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context &tvc, relay_method tx_relay, bool relayed) |
| bool | add_new_tx (transaction &tx, tx_verification_context &tvc, relay_method tx_relay, bool relayed) |
| add a new transaction to the transaction pool | |
| bool | add_new_block (const block &b, block_verification_context &bvc, pool_supplement &extra_block_txs) |
| adds a block to the blockchain | |
| bool | load_state_data () |
| load any core state stored on disk | |
| bool | update_miner_block_template () |
| bool | handle_command_line (const boost::program_options::variables_map &vm) |
| act on a set of command line options given | |
| bool | relay_txpool_transactions () |
| attempts to relay any transactions in the mempool which need it | |
| bool | notify_txpool_event (const epee::span< const cryptonote::blobdata > tx_blobs, epee::span< const crypto::hash > tx_hashes, epee::span< const cryptonote::transaction > txs, const std::vector< bool > &just_broadcasted) const |
| sends notification of txpool events to subscribers | |
| bool | check_updates () |
| checks DNS versions | |
| bool | check_disk_space () |
| checks free disk space | |
| bool | check_block_rate () |
| checks block rate, and warns if it's too slow | |
| bool | recalculate_difficulties () |
| recalculate difficulties after the last difficulty checklpoint to circumvent the annoying 'difficulty drift' bug | |
Private Attributes | |
| bool | m_test_drop_download = true |
| whether or not to drop incoming blocks (for testing) | |
| uint64_t | m_test_drop_download_height = 0 |
| height under which to drop incoming blocks, if doing so | |
| tx_memory_pool | m_mempool |
| transaction pool instance | |
| Blockchain | m_blockchain_storage |
| Blockchain instance. | |
| i_cryptonote_protocol * | m_pprotocol |
| cryptonote protocol instance | |
| epee::critical_section | m_incoming_tx_lock |
| incoming transaction lock | |
| miner | m_miner |
| miner instance | |
| std::string | m_config_folder |
| folder to look in for configs and other files | |
| cryptonote_protocol_stub | m_protocol_stub |
| cryptonote protocol stub instance | |
| epee::math_helper::once_a_time_seconds< 60 *60 *12, false > | m_store_blockchain_interval |
| interval for manual storing of Blockchain, if enabled | |
| epee::math_helper::once_a_time_seconds< 60 *60 *2, true > | m_fork_moaner |
| interval for checking HardFork status | |
| epee::math_helper::once_a_time_seconds< 60 *60 *12, true > | m_check_updates_interval |
| interval for checking for new versions | |
| epee::math_helper::once_a_time_seconds< 60 *10, true > | m_check_disk_space_interval |
| interval for checking for disk space | |
| epee::math_helper::once_a_time_seconds< 90, false > | m_block_rate_interval |
| interval for checking block rate | |
| epee::math_helper::once_a_time_seconds< 60 *60 *5, true > | m_blockchain_pruning_interval |
| interval for incremental blockchain pruning | |
| epee::math_helper::once_a_time_seconds< 60 *60 *24 *7, false > | m_diff_recalc_interval |
| interval for recalculating difficulties | |
| std::atomic< bool > | m_starter_message_showed |
| has the "daemon will sync now" message been shown? | |
| uint64_t | m_target_blockchain_height |
| blockchain height target | |
| network_type | m_nettype |
| which network are we on? | |
| std::atomic< bool > | m_update_available |
| std::string | m_checkpoints_path |
| path to json checkpoints file | |
| time_t | m_last_dns_checkpoints_update |
| time when dns checkpoints were last updated | |
| time_t | m_last_json_checkpoints_update |
| time when json checkpoints were last updated | |
| std::atomic_flag | m_checkpoints_updating |
| set if checkpoints are currently updating to avoid multiple threads attempting to update at once | |
| bool | m_disable_dns_checkpoints |
| size_t | block_sync_size |
| time_t | start_time |
| enum cryptonote::core:: { ... } | check_updates_level |
| tools::download_async_handle | m_update_download |
| size_t | m_last_update_length |
| boost::mutex | m_update_mutex |
| bool | m_offline |
| std::shared_ptr< tools::Notify > | m_block_rate_notify |
Additional Inherited Members | |
| Protected Member Functions inherited from cryptonote::i_miner_handler | |
| ~i_miner_handler () | |
handles core cryptonote functionality
This class coordinates cryptonote functionality including, but not limited to, communication among the Blockchain, the transaction pool, any miners, and the network.
| cryptonote::core::core | ( | i_cryptonote_protocol * | pprotocol | ) |
constructor
sets member variables into a usable state
| pprotocol | pre-constructed protocol object to store and use |
|
private |
adds a block to the blockchain
Adds a new block to the blockchain. If the block's parent is not the current top of the blockchain, the block may be added to an alternate chain. If the block does not belong, is already in the blockchain or an alternate chain, or is invalid, return false.
| bl_ | the block to be added |
| bvc | metadata about the block addition's success/failure |
| extra_block_txs | txs belonging to this block that may not be in the mempool |
|
private |
| tx_hash | the transaction's hash |
| blob | the transaction as a blob |
| tx_weight | the weight of the transaction |
| tx_relay | how the transaction was received |
| relayed | whether or not the transaction was relayed to us |
|
private |
add a new transaction to the transaction pool
Adds a new transaction to the transaction pool.
| tx | the transaction to add |
| tvc | return-by-reference metadata about the transaction's verification process |
| tx_relay | how the transaction was received |
| relayed | whether or not the transaction was relayed to us |
| bool cryptonote::core::are_key_images_spent | ( | const std::vector< crypto::key_image > & | key_im, |
| std::vector< bool > & | spent ) const |
check if multiple key images are spent
plural version of is_key_image_spent()
| key_im | list of key images to check |
| spent | return-by-reference result for each image checked |
| bool cryptonote::core::are_key_images_spent_in_pool | ( | const std::vector< crypto::key_image > & | key_im, |
| std::vector< bool > & | spent ) const |
check if multiple key images are spent in the transaction pool
| key_im | list of key images to check |
| spent | return-by-reference result for each image checked |
|
private |
checks block rate, and warns if it's too slow
| bool cryptonote::core::check_blockchain_pruning | ( | ) |
checks the blockchain pruning if enabled
|
private |
checks free disk space
check the size of a block against the current maximum
| block_blob | the block to check |
|
static |
verify that each input key image in a transaction is unique
| tx | the transaction to check |
|
static |
verify that each input key image in a transaction is in the valid domain
| tx | the transaction to check |
|
static |
verify that each ring uses distinct members
| tx | the transaction to check |
| hf_version | the hard fork version rules to use |
|
static |
validates some simple properties of a transaction
Currently checks: tx has inputs, tx inputs all of supported type(s), tx outputs valid (type, key, amount), input and output total amounts don't overflow, output amount <= input amount, tx not too large, each input has a different key image.
| tx | the transaction to check |
| tvc | tx verification context where extra fail flags are stored |
| hf_version | hard fork version |
|
private |
checks DNS versions
| bool cryptonote::core::cleanup_handle_incoming_blocks | ( | bool | force_sync = false | ) |
incoming blocks post-processing, cleanup, and disk sync
| force_sync | if true, and Blockchain is handling syncing to disk, always sync |
| bool cryptonote::core::deinit | ( | ) |
performs safe shutdown steps for core and core components
Uninitializes the miner instance, transaction pool, and Blockchain
|
inline |
set whether or not to enable or disable DNS checkpoints
| disble | whether to disable DNS checkpoints |
| bool cryptonote::core::find_blockchain_supplement | ( | const std::list< crypto::hash > & | qblock_ids, |
| bool | clip_pruned, | ||
| NOTIFY_RESPONSE_CHAIN_ENTRY::request & | resp ) const |
| bool cryptonote::core::find_blockchain_supplement | ( | const uint64_t | req_start_block, |
| const std::list< crypto::hash > & | qblock_ids, | ||
| std::vector< std::pair< std::pair< cryptonote::blobdata, crypto::hash >, std::vector< std::pair< crypto::hash, cryptonote::blobdata > > > > & | blocks, | ||
| uint64_t & | total_height, | ||
| uint64_t & | start_height, | ||
| bool | pruned, | ||
| bool | get_miner_tx_hash, | ||
| size_t | max_block_count, | ||
| size_t | max_tx_count ) const |
| void cryptonote::core::flush_invalid_blocks | ( | ) |
flushes the invalid block cache
| bool cryptonote::core::get_alternative_blocks | ( | std::vector< block > & | blocks | ) | const |
compiles a list of all blocks stored as alternative chains
| blocks | return-by-reference container to put result blocks in |
| size_t cryptonote::core::get_alternative_blocks_count | ( | ) | const |
returns the number of alternative blocks stored
| bool cryptonote::core::get_block_by_hash | ( | const crypto::hash & | h, |
| block & | blk, | ||
| bool * | orphan = NULL ) const |
gets the block with a given hash
| h | the hash to look for |
| blk | return-by-reference variable to put result block in |
| orphan | if non-NULL, will be set to true if not in the main chain, false otherwise |
| difficulty_type cryptonote::core::get_block_cumulative_difficulty | ( | uint64_t | height | ) | const |
| crypto::hash cryptonote::core::get_block_id_by_height | ( | uint64_t | height | ) | const |
gets a block's hash given a height
| height | the height of the block |
| size_t cryptonote::core::get_block_sync_size | ( | uint64_t | height | ) | const |
get the number of blocks to sync in one go
|
overridevirtual |
creates a new block to mine against
| b | return-by-reference block to be filled in |
| from_block | optional block hash to start mining from (main chain tip if NULL) |
| miner_address | address new coins for the block will go to |
| di | return-by-reference tells the miner what the difficulty target is |
| height | return-by-reference tells the miner what height it's mining against |
| expected_reward | return-by-reference the total reward awarded to the miner finding this block, including transaction fees |
| ex_nonce | extra data to be added to the miner transaction's extra |
Implements cryptonote::i_miner_handler.
|
virtual |
| uint32_t cryptonote::core::get_blockchain_pruning_seed | ( | ) | const |
get the blockchain pruning seed
|
inline |
gets the Blockchain instance
|
inline |
gets the Blockchain instance (const)
| void cryptonote::core::get_blockchain_top | ( | uint64_t & | height, |
| crypto::hash & | top_id ) const |
get the hash and height of the most recent block
| height | return-by-reference height of the block |
| top_id | return-by-reference hash of the block |
| size_t cryptonote::core::get_blockchain_total_transactions | ( | ) | const |
gets the total number of transactions on the main chain
|
inline |
gets blocks based on a list of block hashes
| t_ids_container | a standard-iterable container |
| t_blocks_container | a standard-iterable container |
| t_missed_container | a standard-iterable container |
| block_ids | a container of block hashes for which to get the corresponding blocks |
| blocks | return-by-reference a container to store result blocks in |
| missed_bs | return-by-reference a container to store missed blocks in |
| bool cryptonote::core::get_blocks | ( | uint64_t | start_offset, |
| size_t | count, | ||
| std::vector< block > & | blocks ) const |
get blocks from blocks based on start height and count
| start_offset | the height on the blockchain to start at |
| count | the number of blocks to get, if there are as many after start_offset |
| blocks | return-by-reference container to put result blocks in |
| bool cryptonote::core::get_blocks | ( | uint64_t | start_offset, |
| size_t | count, | ||
| std::vector< std::pair< cryptonote::blobdata, block > > & | blocks ) const |
get blocks from blocks based on start height and count
| start_offset | the height on the blockchain to start at |
| count | the number of blocks to get, if there are as many after start_offset |
| blocks | return-by-reference container to put result blocks in |
| bool cryptonote::core::get_blocks | ( | uint64_t | start_offset, |
| size_t | count, | ||
| std::vector< std::pair< cryptonote::blobdata, block > > & | blocks, | ||
| std::vector< cryptonote::blobdata > & | txs ) const |
| const checkpoints & cryptonote::core::get_checkpoints | ( | ) | const |
get a set of blockchain checkpoint hashes
| std::pair< boost::multiprecision::uint128_t, boost::multiprecision::uint128_t > cryptonote::core::get_coinbase_tx_sum | ( | const uint64_t | start_offset, |
| const size_t | count ) |
get the sum of coinbase tx amounts between blocks
|
finalvirtual |
return the earliest block a given version may activate
| uint64_t cryptonote::core::get_free_space | ( | ) | const |
get free disk space on the blockchain partition
return the hard fork version for a given block height
| uint8_t cryptonote::core::get_ideal_hard_fork_version | ( | ) | const |
returns the newest hardfork version known to the blockchain
return the ideal hard fork version for a given block height
|
inline |
gets the miner instance
gets the miner instance (const)
| bool cryptonote::core::get_miner_data | ( | uint8_t & | major_version, |
| uint64_t & | height, | ||
| crypto::hash & | prev_id, | ||
| crypto::hash & | seed_hash, | ||
| difficulty_type & | difficulty, | ||
| uint64_t & | median_weight, | ||
| uint64_t & | already_generated_coins, | ||
| std::vector< tx_block_template_backlog_entry > & | tx_backlog ) |
gets data required to create a block template and start mining on it
| major_version | current hardfork version |
| height | current blockchain height |
| prev_id | hash of the top block |
| seed_hash | seed hash used for RandomX initialization |
| difficulty | current mining difficulty |
| median_weight | current median block weight |
| already_generated_coins | current emission |
| tx_backlog | transactions in mempool ready to be mined |
|
inline |
get the network type we're on
| bool cryptonote::core::get_output_distribution | ( | uint64_t | amount, |
| uint64_t | from_height, | ||
| uint64_t | to_height, | ||
| uint64_t & | start_height, | ||
| std::vector< uint64_t > & | distribution, | ||
| uint64_t & | base ) const |
gets per block distribution of outputs of a given amount
| amount | the amount to get a ditribution for |
| from_height | the height before which we do not care about the data |
| to_height | the height after which we do not care about the data |
| return-by-reference | start_height the height of the first rct output |
| return-by-reference | distribution the start offset of the first rct output in this block (same as previous if none) |
| return-by-reference | base how many outputs of that amount are before the stated distribution |
get per block distribution of outputs of a given amount
| bool cryptonote::core::get_outs | ( | const COMMAND_RPC_GET_OUTPUTS_BIN::request & | req, |
| COMMAND_RPC_GET_OUTPUTS_BIN::response & | res ) const |
gets specific outputs to mix with
This function takes an RPC request for outputs to mix with and creates an RPC response with the resultant output indices.
Outputs to mix with are specified in the request.
| req | the outputs to return |
| res | return-by-reference the resultant output indices and keys |
| bool cryptonote::core::get_pool_for_rpc | ( | std::vector< cryptonote::rpc::tx_in_pool > & | tx_infos, |
| cryptonote::rpc::key_images_with_tx_hashes & | key_image_infos ) const |
get information about all transactions and key images in the pool
see documentation on tx_in_pool and key_images_with_tx_hashes for more details
| tx_infos | [out] the transactions' information |
| key_image_infos | [out] the spent key images' information |
| bool cryptonote::core::get_pool_info | ( | time_t | start_time, |
| bool | include_sensitive_txes, | ||
| size_t | max_tx_count, | ||
| std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > & | added_txs, | ||
| std::vector< crypto::hash > & | remaining_added_txids, | ||
| std::vector< crypto::hash > & | removed_txs, | ||
| bool & | incremental ) const |
get info necessary for update of pool-related info in a wallet, preferably incremental
| include_sensitive_txes | include private transactions |
| max_tx_count | max allowed added_txs in response |
| bool cryptonote::core::get_pool_transaction | ( | const crypto::hash & | id, |
| cryptonote::blobdata & | tx, | ||
| relay_category | tx_category ) const |
get a specific transaction from the pool
| h | the hash of the transaction to get |
| tx | return-by-reference the transaction blob requested |
| tx_relay | last relay method us |
| bool cryptonote::core::get_pool_transaction_hashes | ( | std::vector< crypto::hash > & | txs, |
| bool | include_sensitive_txes = false ) const |
get a list of all transactions in the pool
| txs | return-by-reference the list of transactions |
| include_sensitive | return stempool, anonymity-pool, and unrelayed txes |
| include_sensitive_txes | include private transactions |
| bool cryptonote::core::get_pool_transaction_stats | ( | struct txpool_stats & | stats, |
| bool | include_sensitive_txes = false ) const |
get a list of all transactions in the pool
| txs | return-by-reference the list of transactions |
| include_sensitive | return stempool, anonymity-pool, and unrelayed txes |
| include_sensitive_txes | include private transactions |
| bool cryptonote::core::get_pool_transactions | ( | std::vector< transaction > & | txs, |
| bool | include_sensitive_txes = false ) const |
get a list of all transactions in the pool
| txs | return-by-reference the list of transactions |
| include_sensitive | return stempool, anonymity-pool, and unrelayed txes |
| include_sensitive_txes | include private transactions |
| bool cryptonote::core::get_pool_transactions_and_spent_keys_info | ( | std::vector< tx_info > & | tx_infos, |
| std::vector< spent_key_image_info > & | key_image_infos, | ||
| bool | include_sensitive_txes = false ) const |
| include_sensitive_txes | include private transactions |
| size_t cryptonote::core::get_pool_transactions_count | ( | bool | include_sensitive_txes = false | ) | const |
get the total number of transactions in the pool
| include_sensitive_txes | include private transactions |
| bool cryptonote::core::get_pool_transactions_info | ( | const std::vector< crypto::hash > & | txids, |
| std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > & | txs, | ||
| bool | include_sensitive_txes = false ) const |
| include_sensitive_txes | include private transactions |
|
inline |
get the cryptonote protocol instance
| bool cryptonote::core::get_short_chain_history | ( | std::list< crypto::hash > & | ids, |
| uint64_t & | current_height ) const |
gets the hashes for a subset of the blockchain
puts into list <ids> a list of hashes representing certain blocks from the blockchain in reverse chronological order
the blocks chosen, at the time of this writing, are: the most recent 11 powers of 2 less recent from there, so 13, 17, 25, etc...
| ids | return-by-reference list to put the resulting hashes in |
| current_height | the current blockchain height, return-by-reference |
| bool cryptonote::core::get_split_transactions_blobs | ( | const std::vector< crypto::hash > & | txs_ids, |
| std::vector< std::tuple< crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata > > & | txs, | ||
| std::vector< crypto::hash > & | missed_txs ) const |
| std::time_t cryptonote::core::get_start_time | ( | ) | const |
gets start_time
| crypto::hash cryptonote::core::get_tail_id | ( | ) | const |
get the hash of the most recent block on the blockchain
| uint64_t cryptonote::core::get_target_blockchain_height | ( | ) | const |
gets the target blockchain height
| target_blockchain_height | the target height |
| bool cryptonote::core::get_test_drop_download | ( | ) | const |
gets whether or not to drop blocks (for testing)
| bool cryptonote::core::get_test_drop_download_height | ( | ) | const |
gets whether or not to drop blocks
If the current blockchain height <= our block drop threshold and test drop blocks is set, return true
| bool cryptonote::core::get_transactions | ( | const std::vector< crypto::hash > & | txs_ids, |
| std::vector< cryptonote::blobdata > & | txs, | ||
| std::vector< crypto::hash > & | missed_txs, | ||
| bool | pruned = false ) const |
| bool cryptonote::core::get_transactions | ( | const std::vector< crypto::hash > & | txs_ids, |
| std::vector< transaction > & | txs, | ||
| std::vector< crypto::hash > & | missed_txs, | ||
| bool | pruned = false ) const |
| bool cryptonote::core::get_tx_outputs_gindexs | ( | const crypto::hash & | tx_id, |
| size_t | n_txes, | ||
| std::vector< std::vector< uint64_t > > & | indexs ) const |
| bool cryptonote::core::get_tx_outputs_gindexs | ( | const crypto::hash & | tx_id, |
| std::vector< uint64_t > & | indexs ) const |
gets the global indices for outputs from a given transaction
This function gets the global indices for all outputs belonging to a specific transaction.
| tx_id | the hash of the transaction to fetch indices for |
| indexs | return-by-reference the global indices for the transaction's outputs |
| n_txes | how many txes in a row to get results for |
| bool cryptonote::core::get_txpool_backlog | ( | std::vector< tx_backlog_entry > & | backlog, |
| bool | include_sensitive_txes = false ) const |
| include_sensitive_txes | include private transactions |
| bool cryptonote::core::get_txpool_complement | ( | const std::vector< crypto::hash > & | hashes, |
| std::vector< cryptonote::blobdata > & | txes ) |
returns the set of transactions in the txpool which are not in the argument
| hashes | hashes of transactions to exclude from the result |
| void cryptonote::core::graceful_exit | ( | ) |
tells the daemon to wind down operations and stop running
Currently this function raises SIGTERM, allowing the installed signal handlers to do the actual stopping.
|
overridevirtual |
stores and relays a block found by a miner
Updates the miner's target block, attempts to store the found block in Blockchain, and – on success – relays that block to the network.
| b | the block found |
| bvc | returns the block verification flags |
Implements cryptonote::i_miner_handler.
|
private |
| bool cryptonote::core::handle_get_objects | ( | NOTIFY_REQUEST_GET_OBJECTS::request & | arg, |
| NOTIFY_RESPONSE_GET_OBJECTS::request & | rsp, | ||
| cryptonote_connection_context & | context ) |
retrieves a set of blocks and their transactions, and possibly other transactions
the request object encapsulates a list of block hashes and a (possibly empty) list of transaction hashes. for each block hash, the block is fetched along with all of that block's transactions. Any transactions requested separately are fetched afterwards.
| arg | the request |
| rsp | return-by-reference the response to fill in |
| context | connection context associated with the request |
| bool cryptonote::core::handle_incoming_block | ( | const blobdata & | block_blob, |
| const block * | b, | ||
| block_verification_context & | bvc, | ||
| bool | update_miner_blocktemplate = true ) |
handles an incoming block as part of a batch
periodic update to checkpoints is triggered here Attempts to add the block to the Blockchain and, on success, optionally updates the miner's block template.
Prerequisite: There must be an active write transaction for the blockchain storage on this thread. Typically, this is done by calling prepare_handle_incoming_blocks() on this thread before calls to handle_incoming_block(). Then, after calls to handle_incoming_block(), a call to cleanup_handle_incoming_blocks() is made on this thread to either abort or commit the write transaction.
| block_blob | the block to be added |
| block | the block to be added, or NULL |
| bvc | return-by-reference metadata context about the block's validity |
| extra_block_txs | txs belonging to this block that may not be in the mempool |
| update_miner_blocktemplate | whether or not to update the miner's block template |
| bool cryptonote::core::handle_incoming_block | ( | const blobdata & | block_blob, |
| const block * | b, | ||
| block_verification_context & | bvc, | ||
| pool_supplement & | extra_block_txs, | ||
| bool | update_miner_blocktemplate = true ) |
| bool cryptonote::core::handle_incoming_tx | ( | const blobdata & | tx_blob, |
| tx_verification_context & | tvc, | ||
| relay_method | tx_relay, | ||
| bool | relayed ) |
handles an incoming transaction
Parses an incoming transaction and, if nothing is obviously wrong, passes it along to the transaction pool
| tx_blob | the tx to handle |
| tvc | metadata about the transaction's validity |
| tx_relay | how the transaction was received |
| relayed | whether or not the transaction was relayed to us |
| bool cryptonote::core::handle_single_incoming_block | ( | const blobdata & | block_blob, |
| const block * | b, | ||
| block_verification_context & | bvc, | ||
| pool_supplement & | extra_block_txs, | ||
| bool | update_miner_blocktemplate = true ) |
handles a single incoming block
periodic update to checkpoints is triggered here Attempts to add the block to the Blockchain and, on success, optionally updates the miner's block template.
Unlike handle_incoming_block(), a write transaction is created in this method, which means the caller doesn't have to call prepare_handle_incoming_blocks() nor cleanup_handle_incoming_blocks() surrounding this call.
| block_blob | the block to be added |
| block | the block to be added, or NULL |
| bvc | return-by-reference metadata context about the block's validity |
| extra_block_txs | txs belonging to this block that may not be in the mempool |
| update_miner_blocktemplate | whether or not to update the miner's block template |
checks whether block weights are known for the given range
| bool cryptonote::core::have_block | ( | const crypto::hash & | id, |
| int * | where = NULL ) const |
| bool cryptonote::core::have_block_unlocked | ( | const crypto::hash & | id, |
| int * | where = NULL ) const |
| bool cryptonote::core::init | ( | const boost::program_options::variables_map & | vm, |
| const test_options * | test_options = NULL, | ||
| const GetCheckpointsCallback & | get_checkpoints = nullptr, | ||
| bool | allow_dns = true ) |
initializes the core as needed
This function initializes the transaction pool, the Blockchain, and a miner instance with parameters given on the command line (or defaults)
| vm | command line parameters |
| test_options | configuration options for testing |
| get_checkpoints | if set, will be called to get checkpoints data, must return checkpoints data pointer and size or nullptr if there ain't any checkpoints for specific network type |
| allow_dns | whether or not to allow DNS requests |
|
static |
adds command line options to the given options set
As of now, there are no command line options specific to core, so this function simply returns.
| desc | return-by-reference the command line options set to add to |
| bool cryptonote::core::is_key_image_spent | ( | const crypto::key_image & | key_im | ) | const |
check if a key image is already spent on the blockchain
Whenever a transaction output is used as an input for another transaction (a true input, not just one of a mixing set), a key image is generated and stored in the transaction in order to prevent double spending. If this key image is seen again, the transaction using it is rejected.
| key_im | the key image to search for |
|
finalvirtual |
gets the core synchronization status
Implements cryptonote::i_core_events.
|
inline |
check whether an update is known to be available or not
This does not actually trigger a check, but returns the result of the last check
| bool cryptonote::core::is_within_compiled_block_hash_area | ( | uint64_t | height | ) | const |
checks whether a given block height is included in the precompiled block hash area
| height | the height to check for |
|
private |
load any core state stored on disk
currently does nothing, but may have state to load in the future.
|
private |
sends notification of txpool events to subscribers
|
inline |
get whether the core is running offline
| bool cryptonote::core::on_idle | ( | ) |
| void cryptonote::core::on_synchronized | ( | ) |
|
finalvirtual |
called when a transaction is relayed.
Implements cryptonote::i_core_events.
| void cryptonote::core::pause_mine | ( | ) |
| bool cryptonote::core::pool_has_tx | ( | const crypto::hash & | txid | ) | const |
checks if the pool has a transaction with the given hash
| id | the hash to look for |
| tx_category | a filter for txes |
| bool cryptonote::core::prepare_handle_incoming_blocks | ( | const std::vector< block_complete_entry > & | blocks_entry, |
| std::vector< block > & | blocks ) |
performs some preprocessing on a group of incoming blocks to speed up verification
| blocks_entry | a list of incoming blocks |
| blocks | the parsed blocks |
| uint64_t cryptonote::core::prevalidate_block_hashes | ( | uint64_t | height, |
| const std::vector< crypto::hash > & | hashes, | ||
| const std::vector< uint64_t > & | weights ) |
check a set of hashes against the precompiled hash set
| std::string cryptonote::core::print_pool | ( | bool | short_format | ) | const |
get a string containing human-readable pool information
| short_format | whether to use a shortened format for the info |
| bool cryptonote::core::prune_blockchain | ( | uint32_t | pruning_seed = 0 | ) |
prune the blockchain
| pruning_seed | the seed to use to prune the chain (0 for default, highly recommended) |
|
private |
recalculate difficulties after the last difficulty checklpoint to circumvent the annoying 'difficulty drift' bug
|
private |
attempts to relay any transactions in the mempool which need it
| void cryptonote::core::resume_mine | ( | ) |
| void cryptonote::core::safesyncmode | ( | const bool | onoff | ) |
Put DB in safe sync mode.
2note see Blockchain::safesyncmode
| void cryptonote::core::set_checkpoints | ( | checkpoints && | chk_pts | ) |
assign a set of blockchain checkpoint hashes
| chk_pts | the set of checkpoints to assign |
| void cryptonote::core::set_checkpoints_file_path | ( | const std::string & | path | ) |
set the file path to read from when loading checkpoints
| path | the path to set ours as |
| void cryptonote::core::set_cryptonote_protocol | ( | i_cryptonote_protocol * | pprotocol | ) |
set the pointer to the cryptonote protocol object to use
| pprotocol | the pointer to set ours as |
| void cryptonote::core::set_enforce_dns_checkpoints | ( | bool | enforce_dns | ) |
set whether or not we enforce DNS checkpoints
| enforce_dns | enforce DNS checkpoints or not |
clears the blockchain and starts a new one
| b | the first block in the new chain (the genesis block) |
| void cryptonote::core::set_target_blockchain_height | ( | uint64_t | target_blockchain_height | ) |
sets the target blockchain height
| target_blockchain_height | the height to set |
| void cryptonote::core::stop | ( | ) |
stops the daemon running
| void cryptonote::core::test_drop_download | ( | ) |
sets to drop blocks downloaded (for testing)
| void cryptonote::core::test_drop_download_height | ( | uint64_t | height | ) |
sets to drop blocks downloaded below a certain height
| height | height below which to drop blocks |
| bool cryptonote::core::update_blockchain_pruning | ( | ) |
incrementally prunes blockchain
tells the Blockchain to update its checkpoints
This function will check if enough time has passed since the last time checkpoints were updated and tell the Blockchain to update its checkpoints if it is time. If updating checkpoints fails, the daemon is told to shut down.
|
private |
|
private |
| enum { ... } cryptonote::core::check_updates_level |
|
private |
interval for checking block rate
|
private |
|
private |
interval for incremental blockchain pruning
|
private |
Blockchain instance.
|
private |
interval for checking for disk space
|
private |
interval for checking for new versions
|
private |
path to json checkpoints file
|
private |
set if checkpoints are currently updating to avoid multiple threads attempting to update at once
|
private |
folder to look in for configs and other files
|
private |
interval for recalculating difficulties
|
private |
|
private |
interval for checking HardFork status
|
private |
incoming transaction lock
|
private |
time when dns checkpoints were last updated
|
private |
time when json checkpoints were last updated
|
private |
|
private |
transaction pool instance
|
private |
miner instance
|
private |
which network are we on?
|
private |
|
private |
cryptonote protocol instance
|
private |
cryptonote protocol stub instance
|
private |
has the "daemon will sync now" message been shown?
|
private |
interval for manual storing of Blockchain, if enabled
|
private |
blockchain height target
|
private |
whether or not to drop incoming blocks (for testing)
|
private |
height under which to drop incoming blocks, if doing so
|
private |
|
private |
|
private |
|
private |