Electroneum
cryptonote::core Class Reference

handles core cryptonote functionality More...

#include <cryptonote_core.h>

Inheritance diagram for cryptonote::core:
Collaboration diagram for cryptonote::core:

Public Member Functions

 core (i_cryptonote_protocol *pprotocol)
 constructor More...
 
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 More...
 
bool on_idle ()
 calls various idle routines More...
 
bool handle_incoming_tx (const blobdata &tx_blob, tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
 handles an incoming transaction More...
 
bool handle_incoming_txs (const std::vector< blobdata > &tx_blobs, std::vector< tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
 handles a list of incoming transactions More...
 
bool handle_incoming_block (const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
 handles an incoming block More...
 
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 More...
 
bool cleanup_handle_incoming_blocks (bool force_sync=false)
 incoming blocks post-processing, cleanup, and disk sync More...
 
bool check_incoming_block_size (const blobdata &block_blob) const
 check the size of a block against the current maximum More...
 
i_cryptonote_protocolget_protocol ()
 get the cryptonote protocol instance More...
 
virtual bool handle_block_found (block &b, block_verification_context &bvc)
 stores and relays a block found by a miner More...
 
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)
 creates a new block to mine against More...
 
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)
 
virtual void on_transaction_relayed (const cryptonote::blobdata &tx)
 called when a transaction is relayed More...
 
minerget_miner ()
 gets the miner instance More...
 
const minerget_miner () const
 gets the miner instance (const) More...
 
bool init (const boost::program_options::variables_map &vm, const test_options *test_options=NULL, const GetCheckpointsCallback &get_checkpoints=nullptr)
 initializes the core as needed More...
 
bool set_genesis_block (const block &b)
 clears the blockchain and starts a new one More...
 
bool deinit ()
 performs safe shutdown steps for core and core components More...
 
void test_drop_download ()
 sets to drop blocks downloaded (for testing) More...
 
void test_drop_download_height (uint64_t height)
 sets to drop blocks downloaded below a certain height More...
 
bool get_test_drop_download () const
 gets whether or not to drop blocks (for testing) More...
 
bool get_test_drop_download_height () const
 gets whether or not to drop blocks More...
 
uint64_t get_current_blockchain_height () const
 get the current height of the blockchain More...
 
void get_blockchain_top (uint64_t &height, crypto::hash &top_id) const
 get the hash and height of the most recent block More...
 
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 More...
 
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 More...
 
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 More...
 
crypto::hash get_block_id_by_height (uint64_t height) const
 gets a block's hash given a height More...
 
bool get_transactions (const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs) 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) const
 
bool get_block_by_hash (const crypto::hash &h, block &blk, bool *orphan=NULL) const
 gets the block with a given hash More...
 
bool get_alternative_blocks (std::vector< block > &blocks) const
 compiles a list of all blocks stored as alternative chains More...
 
size_t get_alternative_blocks_count () const
 returns the number of alternative blocks stored More...
 
void set_cryptonote_protocol (i_cryptonote_protocol *pprotocol)
 set the pointer to the cryptonote protocol object to use More...
 
void set_checkpoints (checkpoints &&chk_pts)
 assign a set of blockchain checkpoint hashes More...
 
void set_checkpoints_file_path (const std::string &path)
 set the file path to read from when loading checkpoints More...
 
void set_enforce_dns_checkpoints (bool enforce_dns)
 set whether or not we enforce DNS checkpoints More...
 
void disable_dns_checkpoints (bool disable=true)
 set whether or not to enable or disable DNS checkpoints More...
 
bool pool_has_tx (const crypto::hash &txid) const
 checks if the pool has a transaction with the given hash More...
 
bool get_pool_transactions (std::vector< transaction > &txs, bool include_unrelayed_txes=true) const
 get a list of all transactions in the pool More...
 
bool get_txpool_backlog (std::vector< tx_backlog_entry > &backlog) const
 
bool get_pool_transaction_hashes (std::vector< crypto::hash > &txs, bool include_unrelayed_txes=true) const
 get a list of all transactions in the pool More...
 
bool get_pool_transaction_stats (struct txpool_stats &stats, bool include_unrelayed_txes=true) const
 get a list of all transactions in the pool More...
 
bool get_pool_transaction (const crypto::hash &id, cryptonote::blobdata &tx) const
 get a specific transaction from the pool More...
 
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_unrelayed_txes=true) 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 More...
 
size_t get_pool_transactions_count () const
 get the total number of transactions in the pool More...
 
size_t get_blockchain_total_transactions () const
 gets the total number of transactions on the main chain More...
 
bool have_block (const crypto::hash &id) const
 checks if a block is known about with a given hash More...
 
bool get_short_chain_history (std::list< crypto::hash > &ids) const
 gets the hashes for a subset of the blockchain More...
 
bool find_blockchain_supplement (const std::list< crypto::hash > &qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp) const
 get recent block hashes for a foreign chain More...
 
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_count) const
 
bool get_stat_info (core_stat_info &st_inf) const
 gets some stats about the daemon More...
 
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 More...
 
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 More...
 
void set_block_cumulative_difficulty (uint64_t height, difficulty_type diff)
 
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 More...
 
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 More...
 
void pause_mine ()
 
void resume_mine ()
 
Blockchainget_blockchain_storage ()
 gets the Blockchain instance More...
 
const Blockchainget_blockchain_storage () const
 gets the Blockchain instance (const) More...
 
std::string print_pool (bool short_format) const
 get a string containing human-readable pool information More...
 
void on_synchronized ()
 
void safesyncmode (const bool onoff)
 Put DB in safe sync mode. More...
 
void set_target_blockchain_height (uint64_t target_blockchain_height)
 sets the target blockchain height More...
 
uint64_t get_target_blockchain_height () const
 gets the target blockchain height More...
 
uint8_t get_ideal_hard_fork_version () const
 returns the newest hardfork version known to the blockchain More...
 
uint8_t get_ideal_hard_fork_version (uint64_t height) const
 return the ideal hard fork version for a given block height More...
 
uint8_t get_hard_fork_version (uint64_t height) const
 return the hard fork version for a given block height More...
 
uint64_t get_earliest_ideal_height_for_version (uint8_t version) const
 return the earliest block a given version may activate More...
 
std::time_t get_start_time () const
 gets start_time More...
 
bool update_checkpoints ()
 tells the Blockchain to update its checkpoints More...
 
std::string get_validators_list ()
 Get a serialized representation of the list of validators. More...
 
electroneum::basic::list_update_outcome set_validators_list (std::string v_list, bool isEmergencyUpdate)
 set the list of validators according to the serialized string passed in as parameter More...
 
bool isValidatorsListValid ()
 get Validators List state More...
 
void graceful_exit ()
 tells the daemon to wind down operations and stop running More...
 
void stop ()
 stops the daemon running More...
 
bool is_key_image_spent (const crypto::key_image &key_im) const
 check if a key image is already spent on the blockchain More...
 
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 More...
 
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 More...
 
size_t get_block_sync_size (uint64_t height) const
 get the number of blocks to sync in one go More...
 
std::pair< uint64_t, uint64_tget_coinbase_tx_sum (const uint64_t start_offset, const size_t count)
 get the sum of coinbase tx amounts between blocks More...
 
network_type get_nettype () const
 get the network type we're on More...
 
bool is_update_available () const
 check whether an update is known to be available or not More...
 
bool fluffy_blocks_enabled () const
 get whether fluffy blocks are enabled More...
 
bool pad_transactions () const
 get whether transaction relay should be padded More...
 
uint64_t get_free_space () const
 get free disk space on the blockchain partition More...
 
bool offline () const
 get whether the core is running offline More...
 
uint32_t get_blockchain_pruning_seed () const
 get the blockchain pruning seed More...
 
bool prune_blockchain (uint32_t pruning_seed=0)
 prune the blockchain More...
 
bool update_blockchain_pruning ()
 incrementally prunes blockchain More...
 
bool check_blockchain_pruning ()
 checks the blockchain pruning if enabled More...
 
bool set_validator_key (std::string key)
 set validator key More...
 
std::vector< std::string > generate_ed25519_keypair ()
 
std::string sign_message (std::string sk, std::string msg)
 
uint64_t get_balance (const address_parse_info &addr)
 
std::vector< address_outputsget_address_batch_history (const address_parse_info &addr, const uint64_t &start_tx_id=0, const uint64_t &batch_size=100, bool desc=false)
 

Static Public Member Functions

static void init_options (boost::program_options::options_description &desc)
 adds command line options to the given options set More...
 

Additional Inherited Members

- Protected Member Functions inherited from cryptonote::i_miner_handler
 ~i_miner_handler ()
 

Detailed Description

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.

Definition at line 85 of file cryptonote_core.h.

Constructor & Destructor Documentation

◆ core()

cryptonote::core::core ( i_cryptonote_protocol pprotocol)

constructor

sets member variables into a usable state

Parameters
pprotocolpre-constructed protocol object to store and use

Definition at line 248 of file cryptonote_core.cpp.

248  :
249  m_mempool(m_blockchain_storage),
250  m_blockchain_storage(m_mempool),
251  m_miner(this),
252  m_miner_address(boost::value_initialized<account_public_address>()),
253  m_starter_message_showed(false),
254  m_target_blockchain_height(0),
255  m_checkpoints_path(""),
256  m_last_dns_checkpoints_update(0),
257  m_last_json_checkpoints_update(0),
258  m_disable_dns_checkpoints(false),
259  m_update_download(0),
260  m_nettype(UNDEFINED),
261  m_update_available(false),
262  m_pad_transactions(false)
263  {
264  m_checkpoints_updating.clear();
265  set_cryptonote_protocol(pprotocol);
266  }
void set_cryptonote_protocol(i_cryptonote_protocol *pprotocol)
set the pointer to the cryptonote protocol object to use
Here is the call graph for this function:

Member Function Documentation

◆ are_key_images_spent()

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()

Parameters
key_imlist of key images to check
spentreturn-by-reference result for each image checked
Returns
true

Definition at line 1135 of file cryptonote_core.cpp.

1136  {
1137  spent.clear();
1138  for(auto& ki: key_im)
1139  {
1140  spent.push_back(m_blockchain_storage.have_tx_keyimg_as_spent(ki));
1141  }
1142  return true;
1143  }
bool have_tx_keyimg_as_spent(const crypto::key_image &key_im) const
check if a key image is already spent on the blockchain
Definition: blockchain.cpp:174
Here is the call graph for this function:
Here is the caller graph for this function:

◆ are_key_images_spent_in_pool()

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

Parameters
key_imlist of key images to check
spentreturn-by-reference result for each image checked
Returns
true

Definition at line 1155 of file cryptonote_core.cpp.

1156  {
1157  spent.clear();
1158  return m_mempool.check_for_key_images(key_im, spent);
1159  }
bool check_for_key_images(const std::vector< crypto::key_image > &key_images, std::vector< bool > spent) const
check for presence of key images in the pool
Definition: tx_pool.cpp:980
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_blockchain_pruning()

bool cryptonote::core::check_blockchain_pruning ( )

checks the blockchain pruning if enabled

Returns
true on success, false otherwise

Definition at line 1952 of file cryptonote_core.cpp.

1953  {
1954  return m_blockchain_storage.check_blockchain_pruning();
1955  }
Here is the call graph for this function:

◆ check_incoming_block_size()

bool cryptonote::core::check_incoming_block_size ( const blobdata block_blob) const

check the size of a block against the current maximum

Parameters
block_blobthe block to check
Returns
whether or not the block is too big

Definition at line 1516 of file cryptonote_core.cpp.

1517  {
1518  // note: we assume block weight is always >= block blob size, so we check incoming
1519  // blob size against the block weight limit, which acts as a sanity check without
1520  // having to parse/weigh first; in fact, since the block blob is the block header
1521  // plus the tx hashes, the weight will typically be much larger than the blob size
1522  if(block_blob.size() > m_blockchain_storage.get_current_cumulative_block_weight_limit() + BLOCK_SIZE_SANITY_LEEWAY)
1523  {
1524  LOG_PRINT_L1("WRONG BLOCK BLOB, sanity check failed on size " << block_blob.size() << ", rejected");
1525  return false;
1526  }
1527  return true;
1528  }
uint64_t get_current_cumulative_block_weight_limit() const
gets the block weight limit based on recent blocks
#define BLOCK_SIZE_SANITY_LEEWAY
#define LOG_PRINT_L1(x)
Definition: misc_log_ex.h:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_handle_incoming_blocks()

bool cryptonote::core::cleanup_handle_incoming_blocks ( bool  force_sync = false)

incoming blocks post-processing, cleanup, and disk sync

Parameters
force_syncif true, and Blockchain is handling syncing to disk, always sync
Returns
true
Note
see Blockchain::cleanup_handle_incoming_blocks

Definition at line 1456 of file cryptonote_core.cpp.

1457  {
1458  bool success = false;
1459  try {
1460  success = m_blockchain_storage.cleanup_handle_incoming_blocks(force_sync);
1461  }
1462  catch (...) {}
1463  m_incoming_tx_lock.unlock();
1464  return success;
1465  }
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
expect< void > success() noexcept
Definition: expect.h:397
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deinit()

bool cryptonote::core::deinit ( )

performs safe shutdown steps for core and core components

Uninitializes the miner instance, transaction pool, and Blockchain

Returns
true

Definition at line 783 of file cryptonote_core.cpp.

784  {
785  m_miner.stop();
786  m_mempool.deinit();
787  m_blockchain_storage.deinit();
788  return true;
789  }
bool deinit()
Uninitializes the blockchain state.
Definition: blockchain.cpp:546
bool deinit()
attempts to save the transaction pool state to disk
Definition: tx_pool.cpp:1623
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disable_dns_checkpoints()

void cryptonote::core::disable_dns_checkpoints ( bool  disable = true)
inline

set whether or not to enable or disable DNS checkpoints

Parameters
disblewhether to disable DNS checkpoints

Definition at line 436 of file cryptonote_core.h.

436 { m_disable_dns_checkpoints = disable; }

◆ find_blockchain_supplement() [1/2]

bool cryptonote::core::find_blockchain_supplement ( const std::list< crypto::hash > &  qblock_ids,
NOTIFY_RESPONSE_CHAIN_ENTRY::request resp 
) const

get recent block hashes for a foreign chain

Find the split point between us and foreign blockchain and return (by reference) the most recent common block hash along with up to BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT additional (more recent) hashes.

Parameters
qblock_idsthe foreign chain's "short history" (see get_short_chain_history)
respreturn-by-reference the split height and subsequent blocks' hashes
Returns
true if a block found in common, else false
Note
see Blockchain::find_blockchain_supplement(const std::list<crypto::hash>&, NOTIFY_RESPONSE_CHAIN_ENTRY::request&) const

Definition at line 1317 of file cryptonote_core.cpp.

1318  {
1319  return m_blockchain_storage.find_blockchain_supplement(qblock_ids, resp);
1320  }
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, std::vector< crypto::hash > &hashes, uint64_t &start_height, uint64_t &current_height, bool clip_pruned) const
get recent block hashes for a foreign chain
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_blockchain_supplement() [2/2]

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_count 
) const

Note
see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::vector<std::pair<cryptonote::blobdata, std::vector<transaction> > >&, uint64_t&, uint64_t&, size_t) const

Definition at line 1322 of file cryptonote_core.cpp.

1323  {
1324  return m_blockchain_storage.find_blockchain_supplement(req_start_block, qblock_ids, blocks, total_height, start_height, pruned, get_miner_tx_hash, max_count);
1325  }
Here is the call graph for this function:

◆ fluffy_blocks_enabled()

bool cryptonote::core::fluffy_blocks_enabled ( ) const
inline

get whether fluffy blocks are enabled

Returns
whether fluffy blocks are enabled

Definition at line 803 of file cryptonote_core.h.

803 { return m_fluffy_blocks_enabled; }

◆ generate_ed25519_keypair()

std::vector< std::string > cryptonote::core::generate_ed25519_keypair ( )

Definition at line 2002 of file cryptonote_core.cpp.

2002  {
2004  }
std::vector< std::string > create_ed25519_keypair()
Definition: crypto.h:386
Here is the call graph for this function:

◆ get_address_batch_history()

std::vector< address_outputs > cryptonote::core::get_address_batch_history ( const address_parse_info addr,
const uint64_t start_tx_id = 0,
const uint64_t batch_size = 100,
bool  desc = false 
)

Definition at line 2018 of file cryptonote_core.cpp.

2019  {
2020  crypto::public_key combined_key = crypto::addKeys(addr.address.m_view_public_key, addr.address.m_spend_public_key);
2021  return m_blockchain_storage.get_db().get_addr_output_batch(combined_key, start_tx_id, batch_size, desc);
2022  }
virtual std::vector< address_outputs > get_addr_output_batch(const crypto::public_key &combined_key, uint64_t start_db_index=0, uint64_t batch_size=100, bool desc=false)=0
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:953
public_key addKeys(const public_key &A, const public_key &B)
Definition: crypto.h:337
POD_CLASS public_key
Definition: crypto.h:76
Here is the call graph for this function:

◆ get_alternative_blocks()

bool cryptonote::core::get_alternative_blocks ( std::vector< block > &  blocks) const

compiles a list of all blocks stored as alternative chains

Parameters
blocksreturn-by-reference container to put result blocks in
Returns
true
Note
see Blockchain::get_alternative_blocks(std::vector<block>&) const

Definition at line 487 of file cryptonote_core.cpp.

488  {
489  return m_blockchain_storage.get_alternative_blocks(blocks);
490  }
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_alternative_blocks_count()

size_t cryptonote::core::get_alternative_blocks_count ( ) const

returns the number of alternative blocks stored

Returns
the number of alternative blocks stored
Note
see Blockchain::get_alternative_blocks_count() const

Definition at line 492 of file cryptonote_core.cpp.

493  {
494  return m_blockchain_storage.get_alternative_blocks_count();
495  }
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_balance()

uint64_t cryptonote::core::get_balance ( const address_parse_info addr)

Definition at line 2012 of file cryptonote_core.cpp.

2013  {
2014  crypto::public_key combined_key = crypto::addKeys(addr.address.m_view_public_key, addr.address.m_spend_public_key);
2015  return m_blockchain_storage.get_db().get_balance(combined_key);
2016  }
virtual uint64_t get_balance(const crypto::public_key &combined_key)=0
Here is the call graph for this function:

◆ get_block_by_hash()

bool cryptonote::core::get_block_by_hash ( const crypto::hash h,
block blk,
bool orphan = NULL 
) const

gets the block with a given hash

Parameters
hthe hash to look for
blkreturn-by-reference variable to put result block in
orphanif non-NULL, will be set to true if not in the main chain, false otherwise
Returns
true if the block was found, else false
Note
see Blockchain::get_block_by_hash

Definition at line 1618 of file cryptonote_core.cpp.

1619  {
1620  return m_blockchain_storage.get_block_by_hash(h, blk, orphan);
1621  }
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan=NULL) const
gets the block with a given hash
Definition: blockchain.cpp:814
Here is the call graph for this function:

◆ get_block_cumulative_difficulty()

difficulty_type cryptonote::core::get_block_cumulative_difficulty ( uint64_t  height) const

Note
see Blockchain::get_block_cumulative_difficulty

Definition at line 1540 of file cryptonote_core.cpp.

1541  {
1542  return m_blockchain_storage.get_db().get_block_cumulative_difficulty(height);
1543  }
uint64_t height
Definition: blockchain.cpp:91
virtual difficulty_type get_block_cumulative_difficulty(const uint64_t &height) const =0
fetch a block's cumulative difficulty
Here is the call graph for this function:

◆ get_block_id_by_height()

crypto::hash cryptonote::core::get_block_id_by_height ( uint64_t  height) const

gets a block's hash given a height

Parameters
heightthe height of the block
Returns
the hash of the block at the requested height, or a zeroed hash if there is no such block
Note
see Blockchain::get_block_id_by_height

Definition at line 1613 of file cryptonote_core.cpp.

1614  {
1615  return m_blockchain_storage.get_block_id_by_height(height);
1616  }
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition: blockchain.cpp:787
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_sync_size()

size_t cryptonote::core::get_block_sync_size ( uint64_t  height) const

get the number of blocks to sync in one go

Returns
the number of blocks to sync in one go

Definition at line 1145 of file cryptonote_core.cpp.

1146  {
1147  static const uint64_t quick_height = m_nettype == TESTNET ? 801219 : m_nettype == MAINNET ? 1220516 : 0;
1148  if (block_sync_size > 0)
1149  return block_sync_size;
1150  if (height >= quick_height)
1153  }
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4
unsigned __int64 uint64_t
Definition: stdint.h:136

◆ get_block_template() [1/2]

bool cryptonote::core::get_block_template ( block b,
const account_public_address adr,
difficulty_type diffic,
uint64_t height,
uint64_t expected_reward,
const blobdata ex_nonce 
)
virtual

creates a new block to mine against

Parameters
breturn-by-reference block to be filled in
from_blockoptional block hash to start mining from (main chain tip if NULL)
miner_addressaddress new coins for the block will go to
direturn-by-reference tells the miner what the difficulty target is
heightreturn-by-reference tells the miner what height it's mining against
expected_rewardreturn-by-reference the total reward awarded to the miner finding this block, including transaction fees
ex_nonceextra data to be added to the miner transaction's extra
Returns
true if block template filled in successfully, else false
Note
see Blockchain::create_block_template

Implements cryptonote::i_miner_handler.

Definition at line 1307 of file cryptonote_core.cpp.

1308  {
1309  return m_blockchain_storage.create_block_template(b, adr, diffic, height, expected_reward, ex_nonce);
1310  }
bool create_block_template(block &b, const account_public_address &miner_address, difficulty_type &di, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce)
creates a new block to mine against
Here is the call graph for this function:

◆ get_block_template() [2/2]

bool cryptonote::core::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 
)
virtual

Definition at line 1312 of file cryptonote_core.cpp.

1313  {
1314  return m_blockchain_storage.create_block_template(b, prev_block, adr, diffic, height, expected_reward, ex_nonce);
1315  }
Here is the call graph for this function:

◆ get_blockchain_pruning_seed()

uint32_t cryptonote::core::get_blockchain_pruning_seed ( ) const

get the blockchain pruning seed

Returns
the blockchain pruning seed

Definition at line 1974 of file cryptonote_core.cpp.

1975  {
1977  }
uint32_t get_blockchain_pruning_seed() const
Definition: blockchain.h:1007
Blockchain & get_blockchain_storage()
gets the Blockchain instance
Here is the call graph for this function:

◆ get_blockchain_storage() [1/2]

Blockchain& cryptonote::core::get_blockchain_storage ( )
inline

gets the Blockchain instance

Returns
a reference to the Blockchain instance

Definition at line 611 of file cryptonote_core.h.

611 {return m_blockchain_storage;}
Here is the caller graph for this function:

◆ get_blockchain_storage() [2/2]

const Blockchain& cryptonote::core::get_blockchain_storage ( ) const
inline

gets the Blockchain instance (const)

Returns
a const reference to the Blockchain instance

Definition at line 618 of file cryptonote_core.h.

618 {return m_blockchain_storage;}

◆ get_blockchain_top()

void cryptonote::core::get_blockchain_top ( uint64_t height,
crypto::hash top_id 
) const

get the hash and height of the most recent block

Parameters
heightreturn-by-reference height of the block
top_idreturn-by-reference hash of the block

Definition at line 441 of file cryptonote_core.cpp.

442  {
443  top_id = m_blockchain_storage.get_tail_id(height);
444  }
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition: blockchain.cpp:723
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_blockchain_total_transactions()

size_t cryptonote::core::get_blockchain_total_transactions ( ) const

gets the total number of transactions on the main chain

Returns
the number of transactions on the main chain
Note
see Blockchain::get_total_transactions

Definition at line 1250 of file cryptonote_core.cpp.

1251  {
1252  return m_blockchain_storage.get_total_transactions();
1253  }
size_t get_total_transactions() const
gets the total number of transactions on the main chain
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_blocks() [1/4]

template<class t_ids_container , class t_blocks_container , class t_missed_container >
bool cryptonote::core::get_blocks ( const t_ids_container &  block_ids,
t_blocks_container &  blocks,
t_missed_container &  missed_bs 
) const
inline

gets blocks based on a list of block hashes

Template Parameters
t_ids_containera standard-iterable container
t_blocks_containera standard-iterable container
t_missed_containera standard-iterable container
Parameters
block_idsa container of block hashes for which to get the corresponding blocks
blocksreturn-by-reference a container to store result blocks in
missed_bsreturn-by-reference a container to store missed blocks in
Returns
false if an unexpected exception occurs, else true
Note
see Blockchain::get_blocks(const t_ids_container&, t_blocks_container&, t_missed_container&) const

Definition at line 349 of file cryptonote_core.h.

350  {
351  return m_blockchain_storage.get_blocks(block_ids, blocks, missed_bs);
352  }
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
get blocks and transactions from blocks based on start height and count

◆ get_blocks() [2/4]

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

Parameters
start_offsetthe height on the blockchain to start at
countthe number of blocks to get, if there are as many after start_offset
blocksreturn-by-reference container to put result blocks in
Returns
false if start_offset > blockchain height, else true
Note
see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const

Definition at line 456 of file cryptonote_core.cpp.

457  {
458  std::vector<std::pair<cryptonote::blobdata, cryptonote::block>> bs;
459  if (!m_blockchain_storage.get_blocks(start_offset, count, bs))
460  return false;
461  for (const auto &b: bs)
462  blocks.push_back(b.second);
463  return true;
464  }
mdb_size_t count(MDB_cursor *cur)
Here is the call graph for this function:

◆ get_blocks() [3/4]

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

Parameters
start_offsetthe height on the blockchain to start at
countthe number of blocks to get, if there are as many after start_offset
blocksreturn-by-reference container to put result blocks in
Returns
false if start_offset > blockchain height, else true
Note
see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&) const

Definition at line 451 of file cryptonote_core.cpp.

452  {
453  return m_blockchain_storage.get_blocks(start_offset, count, blocks);
454  }
Here is the call graph for this function:

◆ get_blocks() [4/4]

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

Note
see Blockchain::get_blocks(uint64_t, size_t, std::vector<std::pair<cryptonote::blobdata,block>>&, std::vector<transaction>&) const

Definition at line 446 of file cryptonote_core.cpp.

447  {
448  return m_blockchain_storage.get_blocks(start_offset, count, blocks, txs);
449  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_coinbase_tx_sum()

std::pair< uint64_t, uint64_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

Returns
the number of blocks to sync in one go

Definition at line 1161 of file cryptonote_core.cpp.

1162  {
1163  uint64_t emission_amount = 0;
1164  uint64_t total_fee_amount = 0;
1165  if (count)
1166  {
1167  const uint64_t end = start_offset + count - 1;
1168  m_blockchain_storage.for_blocks_range(start_offset, end,
1169  [this, &emission_amount, &total_fee_amount](uint64_t, const crypto::hash& hash, const block& b){
1170  std::vector<transaction> txs;
1171  std::vector<crypto::hash> missed_txs;
1172  uint64_t coinbase_amount = get_outs_etn_amount(b.miner_tx);
1173  this->get_transactions(b.tx_hashes, txs, missed_txs);
1174  uint64_t tx_fee_amount = 0;
1175  for(const auto& tx: txs)
1176  {
1177  tx_fee_amount += get_tx_fee(tx);
1178  }
1179 
1180  emission_amount += coinbase_amount - tx_fee_amount;
1181  total_fee_amount += tx_fee_amount;
1182  return true;
1183  });
1184  }
1185 
1186  return std::pair<uint64_t, uint64_t>(emission_amount, total_fee_amount);
1187  }
bool for_blocks_range(const uint64_t &h1, const uint64_t &h2, std::function< bool(uint64_t, const crypto::hash &, const block &)>) const
perform a check on all blocks in the blockchain in the given range
bool get_transactions(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs) const
POD_CLASS hash
Definition: hash.h:50
uint64_t get_outs_etn_amount(const transaction &tx)
bool get_tx_fee(const transaction &tx, uint64_t &fee)
Here is the call graph for this function:

◆ get_current_blockchain_height()

uint64_t cryptonote::core::get_current_blockchain_height ( ) const

get the current height of the blockchain

Returns
the height
Note
see Blockchain::get_current_blockchain_height()

Definition at line 436 of file cryptonote_core.cpp.

437  {
438  return m_blockchain_storage.get_current_blockchain_height();
439  }
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
Definition: blockchain.cpp:319
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_earliest_ideal_height_for_version()

uint64_t cryptonote::core::get_earliest_ideal_height_for_version ( uint8_t  version) const

return the earliest block a given version may activate

Returns
what it says above

Definition at line 1711 of file cryptonote_core.cpp.

1712  {
1714  }
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
returns the earliest block a given version may activate
Definition: blockchain.h:855
version
Supported socks variants.
Definition: socks.h:58
Here is the call graph for this function:

◆ get_free_space()

uint64_t cryptonote::core::get_free_space ( ) const

get free disk space on the blockchain partition

Returns
free space in bytes

Definition at line 1967 of file cryptonote_core.cpp.

1968  {
1969  boost::filesystem::path path(m_config_folder);
1970  boost::filesystem::space_info si = boost::filesystem::space(path);
1971  return si.available;
1972  }
Here is the caller graph for this function:

◆ get_hard_fork_version()

uint8_t cryptonote::core::get_hard_fork_version ( uint64_t  height) const

return the hard fork version for a given block height

Returns
what it says above

Definition at line 1706 of file cryptonote_core.cpp.

1707  {
1709  }
uint8_t get_hard_fork_version(uint64_t height) const
returns the actual hardfork version for a given block height
Definition: blockchain.h:848
Here is the call graph for this function:

◆ get_ideal_hard_fork_version() [1/2]

uint8_t cryptonote::core::get_ideal_hard_fork_version ( ) const

returns the newest hardfork version known to the blockchain

Returns
the version

Definition at line 1696 of file cryptonote_core.cpp.

1697  {
1699  }
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition: blockchain.h:822
Here is the call graph for this function:

◆ get_ideal_hard_fork_version() [2/2]

uint8_t cryptonote::core::get_ideal_hard_fork_version ( uint64_t  height) const

return the ideal hard fork version for a given block height

Returns
what it says above

Definition at line 1701 of file cryptonote_core.cpp.

1702  {
1704  }
Here is the call graph for this function:

◆ get_miner() [1/2]

miner& cryptonote::core::get_miner ( )
inline

gets the miner instance

Returns
a reference to the miner instance

Definition at line 229 of file cryptonote_core.h.

229 {return m_miner;}
Here is the caller graph for this function:

◆ get_miner() [2/2]

const miner& cryptonote::core::get_miner ( ) const
inline

gets the miner instance (const)

Returns
a const reference to the miner instance

Definition at line 236 of file cryptonote_core.h.

236 {return m_miner;}

◆ get_nettype()

network_type cryptonote::core::get_nettype ( ) const
inline

get the network type we're on

Returns
which network are we on?

Definition at line 786 of file cryptonote_core.h.

786 { return m_nettype; };
Here is the caller graph for this function:

◆ get_output_distribution()

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

Parameters
amountthe amount to get a ditribution for
from_heightthe height before which we do not care about the data
to_heightthe height after which we do not care about the data
return-by-referencestart_height the height of the first rct output
return-by-referencedistribution the start offset of the first rct output in this block (same as previous if none)
return-by-referencebase how many outputs of that amount are before the stated distribution

get per block distribution of outputs of a given amount

Definition at line 1332 of file cryptonote_core.cpp.

1333  {
1334  return m_blockchain_storage.get_output_distribution(amount, from_height, to_height, start_height, distribution, base);
1335  }
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_outs()

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.

Parameters
reqthe outputs to return
resreturn-by-reference the resultant output indices and keys
Returns
true
Note
see Blockchain::get_outs

Definition at line 1327 of file cryptonote_core.cpp.

1328  {
1329  return m_blockchain_storage.get_outs(req, res);
1330  }
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
const char * res
Definition: hmac_keccak.cpp:41
Here is the call graph for this function:

◆ get_pool_for_rpc()

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

Parameters
tx_infos[out] the transactions' information
key_image_infos[out] the spent key images' information
Returns
true
Note
see tx_memory_pool::get_pool_for_rpc

Definition at line 1598 of file cryptonote_core.cpp.

1599  {
1600  return m_mempool.get_pool_for_rpc(tx_infos, key_image_infos);
1601  }
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
Definition: tx_pool.cpp:931
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pool_transaction()

bool cryptonote::core::get_pool_transaction ( const crypto::hash id,
cryptonote::blobdata tx 
) const

get a specific transaction from the pool

Parameters
hthe hash of the transaction to get
txreturn-by-reference the transaction blob requested
Returns
true if the transaction is found, otherwise false
Note
see tx_memory_pool::get_transaction

Definition at line 1583 of file cryptonote_core.cpp.

1584  {
1585  return m_mempool.get_transaction(id, tx);
1586  }
bool get_transaction(const crypto::hash &h, cryptonote::blobdata &txblob) const
get a specific transaction from the pool
Definition: tx_pool.cpp:995
Here is the call graph for this function:

◆ get_pool_transaction_hashes()

bool cryptonote::core::get_pool_transaction_hashes ( std::vector< crypto::hash > &  txs,
bool  include_unrelayed_txes = true 
) const

get a list of all transactions in the pool

Parameters
txsreturn-by-reference the list of transactions
include_unrelayed_txesinclude unrelayed txes in the result
include_unrelayed_txesinclude unrelayed txes in result
Note
see tx_memory_pool::get_transactions

Definition at line 1571 of file cryptonote_core.cpp.

1572  {
1573  m_mempool.get_transaction_hashes(txs, include_sensitive_data);
1574  return true;
1575  }
void get_transaction_hashes(std::vector< crypto::hash > &txs, bool include_unrelayed_txes=true) const
get a list of all transaction hashes in the pool
Definition: tx_pool.cpp:752
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pool_transaction_stats()

bool cryptonote::core::get_pool_transaction_stats ( struct txpool_stats stats,
bool  include_unrelayed_txes = true 
) const

get a list of all transactions in the pool

Parameters
txsreturn-by-reference the list of transactions
include_unrelayed_txesinclude unrelayed txes in the result
include_unrelayed_txesinclude unrelayed txes in result
Note
see tx_memory_pool::get_transactions

Definition at line 1577 of file cryptonote_core.cpp.

1578  {
1579  m_mempool.get_transaction_stats(stats, include_sensitive_data);
1580  return true;
1581  }
void get_transaction_stats(struct txpool_stats &stats, bool include_unrelayed_txes=true) const
get a summary statistics of all transaction hashes in the pool
Definition: tx_pool.cpp:775
Here is the call graph for this function:

◆ get_pool_transactions()

bool cryptonote::core::get_pool_transactions ( std::vector< transaction > &  txs,
bool  include_unrelayed_txes = true 
) const

get a list of all transactions in the pool

Parameters
txsreturn-by-reference the list of transactions
include_unrelayed_txesinclude unrelayed txes in the result
include_unrelayed_txesinclude unrelayed txes in result
Note
see tx_memory_pool::get_transactions

Definition at line 1565 of file cryptonote_core.cpp.

1566  {
1567  m_mempool.get_transactions(txs, include_sensitive_data);
1568  return true;
1569  }
void get_transactions(std::vector< transaction > &txs, bool include_unrelayed_txes=true) const
get a list of all transactions in the pool
Definition: tx_pool.cpp:733
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pool_transactions_and_spent_keys_info()

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_unrelayed_txes = true 
) const

Parameters
include_unrelayed_txesinclude unrelayed txes in result
Note
see tx_memory_pool::get_pool_transactions_and_spent_keys_info

Definition at line 1593 of file cryptonote_core.cpp.

1594  {
1595  return m_mempool.get_transactions_and_spent_keys_info(tx_infos, key_image_infos, include_sensitive_data);
1596  }
bool get_transactions_and_spent_keys_info(std::vector< tx_info > &tx_infos, std::vector< spent_key_image_info > &key_image_infos, bool include_sensitive_data=true) const
get information about all transactions and key images in the pool
Definition: tx_pool.cpp:855
Here is the call graph for this function:

◆ get_pool_transactions_count()

size_t cryptonote::core::get_pool_transactions_count ( ) const

get the total number of transactions in the pool

Returns
the number of transactions in the pool
Note
see tx_memory_pool::get_transactions_count

Definition at line 1545 of file cryptonote_core.cpp.

1546  {
1547  return m_mempool.get_transactions_count();
1548  }
size_t get_transactions_count(bool include_unrelayed_txes=true) const
get the total number of transactions in the pool
Definition: tx_pool.cpp:726
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_protocol()

i_cryptonote_protocol* cryptonote::core::get_protocol ( )
inline

get the cryptonote protocol instance

Returns
the instance

Definition at line 192 of file cryptonote_core.h.

192 {return m_pprotocol;}

◆ get_short_chain_history()

bool cryptonote::core::get_short_chain_history ( std::list< crypto::hash > &  ids) 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...

Parameters
idsreturn-by-reference list to put the resulting hashes in
Returns
true
Note
see Blockchain::get_short_chain_history

Definition at line 1603 of file cryptonote_core.cpp.

1604  {
1605  return m_blockchain_storage.get_short_chain_history(ids);
1606  }
bool get_short_chain_history(std::list< crypto::hash > &ids) const
gets the hashes for a subset of the blockchain
Definition: blockchain.cpp:745
Here is the call graph for this function:

◆ get_split_transactions_blobs()

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

Note
see Blockchain::get_transactions

Definition at line 471 of file cryptonote_core.cpp.

472  {
473  return m_blockchain_storage.get_split_transactions_blobs(txs_ids, txs, missed_txs);
474  }
bool get_split_transactions_blobs(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Here is the call graph for this function:

◆ get_start_time()

std::time_t cryptonote::core::get_start_time ( ) const

gets start_time

Definition at line 1984 of file cryptonote_core.cpp.

1985  {
1986  return start_time;
1987  }
Here is the caller graph for this function:

◆ get_stat_info()

bool cryptonote::core::get_stat_info ( core_stat_info st_inf) const

gets some stats about the daemon

Parameters
st_infreturn-by-reference container for the stats requested
Returns
true

Definition at line 1048 of file cryptonote_core.cpp.

1049  {
1050  st_inf.mining_speed = m_miner.get_speed();
1051  st_inf.alternative_blocks = m_blockchain_storage.get_alternative_blocks_count();
1052  st_inf.blockchain_height = m_blockchain_storage.get_current_blockchain_height();
1053  st_inf.tx_pool_size = m_mempool.get_transactions_count();
1054  st_inf.top_block_id_str = epee::string_tools::pod_to_hex(m_blockchain_storage.get_tail_id());
1055  return true;
1056  }
uint64_t get_speed() const
Definition: miner.cpp:422
std::string pod_to_hex(const t_pod_type &s)
Definition: string_tools.h:317
Here is the call graph for this function:

◆ get_tail_id()

crypto::hash cryptonote::core::get_tail_id ( ) const

get the hash of the most recent block on the blockchain

Returns
the hash
Note
see Blockchain::get_tail_id

Definition at line 1530 of file cryptonote_core.cpp.

1531  {
1532  return m_blockchain_storage.get_tail_id();
1533  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_target_blockchain_height()

uint64_t cryptonote::core::get_target_blockchain_height ( ) const

gets the target blockchain height

Parameters
target_blockchain_heightthe target height

Definition at line 1962 of file cryptonote_core.cpp.

1963  {
1964  return m_target_blockchain_height;
1965  }
Here is the caller graph for this function:

◆ get_test_drop_download()

bool cryptonote::core::get_test_drop_download ( ) const

gets whether or not to drop blocks (for testing)

Returns
whether or not to drop blocks

Definition at line 801 of file cryptonote_core.cpp.

802  {
803  return m_test_drop_download;
804  }

◆ get_test_drop_download_height()

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

Returns
see above

Definition at line 806 of file cryptonote_core.cpp.

807  {
808  if (m_test_drop_download_height == 0)
809  return true;
810 
811  if (get_blockchain_storage().get_current_blockchain_height() <= m_test_drop_download_height)
812  return true;
813 
814  return false;
815  }
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
Here is the call graph for this function:

◆ get_transactions() [1/2]

bool cryptonote::core::get_transactions ( const std::vector< crypto::hash > &  txs_ids,
std::vector< cryptonote::blobdata > &  txs,
std::vector< crypto::hash > &  missed_txs 
) const

Note
see Blockchain::get_transactions

Definition at line 466 of file cryptonote_core.cpp.

467  {
468  return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs);
469  }
bool get_transactions_blobs(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs, bool pruned=false) const
gets transactions based on a list of transaction hashes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_transactions() [2/2]

bool cryptonote::core::get_transactions ( const std::vector< crypto::hash > &  txs_ids,
std::vector< transaction > &  txs,
std::vector< crypto::hash > &  missed_txs 
) const

Note
see Blockchain::get_transactions

Definition at line 482 of file cryptonote_core.cpp.

483  {
484  return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs);
485  }
bool get_transactions(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Here is the call graph for this function:

◆ get_tx_outputs_gindexs() [1/2]

bool cryptonote::core::get_tx_outputs_gindexs ( const crypto::hash tx_id,
size_t  n_txes,
std::vector< std::vector< uint64_t >> &  indexs 
) const

Definition at line 1342 of file cryptonote_core.cpp.

1343  {
1344  return m_blockchain_storage.get_tx_outputs_gindexs(tx_id, n_txes, indexs);
1345  }
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
Here is the call graph for this function:

◆ get_tx_outputs_gindexs() [2/2]

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.

Parameters
tx_idthe hash of the transaction to fetch indices for
indexsreturn-by-reference the global indices for the transaction's outputs
n_txeshow many txes in a row to get results for
Returns
false if the transaction does not exist, or if no indices are found, otherwise true
Note
see Blockchain::get_tx_outputs_gindexs

Definition at line 1337 of file cryptonote_core.cpp.

1338  {
1339  return m_blockchain_storage.get_tx_outputs_gindexs(tx_id, indexs);
1340  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_txpool_backlog()

bool cryptonote::core::get_txpool_backlog ( std::vector< tx_backlog_entry > &  backlog) const

Note
see tx_memory_pool::get_txpool_backlog

Definition at line 476 of file cryptonote_core.cpp.

477  {
478  m_mempool.get_transaction_backlog(backlog);
479  return true;
480  }
void get_transaction_backlog(std::vector< tx_backlog_entry > &backlog, bool include_unrelayed_txes=true) const
get (weight, fee, receive time) for all transaction in the pool
Definition: tx_pool.cpp:763
Here is the call graph for this function:

◆ get_validators_list()

std::string cryptonote::core::get_validators_list ( )

Get a serialized representation of the list of validators.

Returns
serialized string

Definition at line 319 of file cryptonote_core.cpp.

319  {
320  return m_validators->getSerializedValidatorList();
321  }

◆ graceful_exit()

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.

Definition at line 2024 of file cryptonote_core.cpp.

2025  {
2026  raise(SIGTERM);
2027  }
Here is the caller graph for this function:

◆ handle_block_found()

bool cryptonote::core::handle_block_found ( block b,
block_verification_context bvc 
)
virtual

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.

Parameters
bthe block found
bvcreturns the block verification flags
Returns
true if the block was added to the main chain, otherwise false

Implements cryptonote::i_miner_handler.

Definition at line 1370 of file cryptonote_core.cpp.

1371  {
1372  bvc = boost::value_initialized<block_verification_context>();
1373  m_miner.pause();
1374  std::vector<block_complete_entry> blocks;
1375  try
1376  {
1377  blocks.push_back(get_block_complete_entry(b, m_mempool));
1378  }
1379  catch (const std::exception &e)
1380  {
1381  m_miner.resume();
1382  return false;
1383  }
1384  std::vector<block> pblocks;
1385  if (!prepare_handle_incoming_blocks(blocks, pblocks))
1386  {
1387  MERROR("Block found, but failed to prepare to add");
1388  m_miner.resume();
1389  return false;
1390  }
1391  m_blockchain_storage.add_new_block(b, bvc);
1393 
1394  CHECK_AND_ASSERT_MES(!bvc.m_verification_failed, false, "Mined block failed verification");
1395  if(bvc.m_added_to_main_chain)
1396  {
1397  cryptonote_connection_context exclude_context = boost::value_initialized<cryptonote_connection_context>();
1399  arg.current_blockchain_height = m_blockchain_storage.get_current_blockchain_height();
1400  std::vector<crypto::hash> missed_txs;
1401  std::vector<cryptonote::blobdata> txs;
1402  m_blockchain_storage.get_transactions_blobs(b.tx_hashes, txs, missed_txs);
1403  if(missed_txs.size() && m_blockchain_storage.get_block_id_by_height(get_block_height(b)) != get_block_hash(b))
1404  {
1405  LOG_PRINT_L1("Block found but, seems that reorganize just happened after that, do not relay this block");
1406  return true;
1407  }
1408  CHECK_AND_ASSERT_MES(txs.size() == b.tx_hashes.size() && !missed_txs.size(), false, "can't find some transactions in found block:" << get_block_hash(b) << " txs.size()=" << txs.size()
1409  << ", b.tx_hashes.size()=" << b.tx_hashes.size() << ", missed_txs.size()" << missed_txs.size());
1410 
1411  block_to_blob(b, arg.b.block);
1412  //pack transactions
1413  for(auto& tx: txs)
1414  arg.b.txs.push_back(tx);
1415 
1416  m_pprotocol->relay_block(arg, exclude_context);
1417 
1418  if(m_fallback_to_pow) {
1419  m_miner.resume();
1420  }
1421  } else {
1422  update_miner_block_template();
1423  m_miner.resume();
1424  }
1425  return true;
1426  }
bool add_new_block(const block &bl_, block_verification_context &bvc)
adds a block to the blockchain
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
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
#define MERROR(x)
Definition: misc_log_ex.h:73
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:181
block_complete_entry get_block_complete_entry(block &b, tx_memory_pool &pool)
bool get_block_hash(const block &b, crypto::hash &res)
uint64_t get_block_height(const block &b)
blobdata block_to_blob(const block &b)
epee::misc_utils::struct_init< request_t > request
virtual bool relay_block(NOTIFY_NEW_BLOCK::request &arg, cryptonote_connection_context &exclude_context)=0
Here is the call graph for this function:

◆ handle_get_objects()

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.

Parameters
argthe request
rspreturn-by-reference the response to fill in
Returns
true unless any blocks or transactions are missing
Note
see Blockchain::handle_get_objects()
Parameters
contextconnection context associated with the request

Definition at line 1608 of file cryptonote_core.cpp.

1609  {
1610  return m_blockchain_storage.handle_get_objects(arg, rsp);
1611  }
bool handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request &arg, NOTIFY_RESPONSE_GET_OBJECTS::request &rsp)
retrieves a set of blocks and their transactions, and possibly other transactions
Here is the call graph for this function:

◆ handle_incoming_block()

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

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.

Parameters
block_blobthe block to be added
blockthe block to be added, or NULL
bvcreturn-by-reference metadata context about the block's validity
update_miner_blocktemplatewhether or not to update the miner's block template
Returns
false if loading new checkpoints fails, or the block is not added, otherwise true

Definition at line 1468 of file cryptonote_core.cpp.

1469  {
1470  TRY_ENTRY();
1471 
1472  bvc = boost::value_initialized<block_verification_context>();
1473 
1474  if (!check_incoming_block_size(block_blob))
1475  {
1476  bvc.m_verification_failed = true;
1477  return false;
1478  }
1479 
1480  if (((size_t)-1) <= 0xffffffff && block_blob.size() >= 0x3fffffff)
1481  MWARNING("This block's size is " << block_blob.size() << ", closing on the 32 bit limit");
1482 
1483  // load json & DNS checkpoints every 10min/hour respectively,
1484  // and verify them with respect to what blocks we already have
1485  CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints.");
1486 
1487  block lb;
1488  if (!b)
1489  {
1490  crypto::hash block_hash;
1491  if(!parse_and_validate_block_from_blob(block_blob, lb, block_hash))
1492  {
1493  LOG_PRINT_L1("Failed to parse and validate new block");
1494  bvc.m_verification_failed = true;
1495  return false;
1496  }
1497  b = &lb;
1498  }
1499 
1500  add_new_block(*b, bvc);
1501 
1502  if(bvc.m_added_to_main_chain) {
1503  m_miner.resume();
1504 
1505  if(update_miner_blocktemplate)
1506  update_miner_block_template();
1507  }
1508 
1509  return true;
1510 
1511  CATCH_ENTRY_L0("core::handle_incoming_block()", false);
1512  }
bool update_checkpoints()
tells the Blockchain to update its checkpoints
bool check_incoming_block_size(const blobdata &block_blob) const
check the size of a block against the current maximum
#define MWARNING(x)
Definition: misc_log_ex.h:74
#define CATCH_ENTRY_L0(lacation, return_val)
Definition: misc_log_ex.h:165
#define TRY_ENTRY()
Definition: misc_log_ex.h:151
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b, crypto::hash *block_hash)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_incoming_tx()

bool cryptonote::core::handle_incoming_tx ( const blobdata tx_blob,
tx_verification_context tvc,
bool  keeped_by_block,
bool  relayed,
bool  do_not_relay 
)

handles an incoming transaction

Parses an incoming transaction and, if nothing is obviously wrong, passes it along to the transaction pool

Parameters
tx_blobthe tx to handle
tvcmetadata about the transaction's validity
keeped_by_blockif the transaction has been in a block
relayedwhether or not the transaction was relayed to us
do_not_relaywhether to prevent the transaction from being relayed
Returns
true if the transaction was accepted, false otherwise

Definition at line 1038 of file cryptonote_core.cpp.

1039  {
1040  std::vector<cryptonote::blobdata> tx_blobs;
1041  tx_blobs.push_back(tx_blob);
1042  std::vector<tx_verification_context> tvcv(1);
1043  bool r = handle_incoming_txs(tx_blobs, tvcv, keeped_by_block, relayed, do_not_relay);
1044  tvc = tvcv[0];
1045  return r;
1046  }
bool handle_incoming_txs(const std::vector< blobdata > &tx_blobs, std::vector< tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles a list of incoming transactions
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_incoming_txs()

bool cryptonote::core::handle_incoming_txs ( const std::vector< blobdata > &  tx_blobs,
std::vector< tx_verification_context > &  tvc,
bool  keeped_by_block,
bool  relayed,
bool  do_not_relay 
)

handles a list of incoming transactions

Parses incoming transactions and, if nothing is obviously wrong, passes them along to the transaction pool

Parameters
tx_blobsthe txs to handle
tvcmetadata about the transactions' validity
keeped_by_blockif the transactions have been in a block
relayedwhether or not the transactions were relayed to us
do_not_relaywhether to prevent the transactions from being relayed
Returns
true if the transactions were accepted, false otherwise

Definition at line 940 of file cryptonote_core.cpp.

941  {
942  TRY_ENTRY();
943  CRITICAL_REGION_LOCAL(m_incoming_tx_lock);
944 
945  struct result { bool res; cryptonote::transaction tx; crypto::hash hash; };
946  std::vector<result> results(tx_blobs.size());
947 
948  tvc.resize(tx_blobs.size());
951  std::vector<blobdata>::const_iterator it = tx_blobs.begin();
952  for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
953  tpool.submit(&waiter, [&, i, it] {
954  try
955  {
956  results[i].res = handle_incoming_tx_pre(*it, tvc[i], results[i].tx, results[i].hash, keeped_by_block, relayed, do_not_relay);
957  }
958  catch (const std::exception &e)
959  {
960  MERROR_VER("Exception in handle_incoming_tx_pre: " << e.what());
961  tvc[i].m_verification_failed = true;
962  results[i].res = false;
963  }
964  });
965  }
966  waiter.wait(&tpool);
967  it = tx_blobs.begin();
968  std::vector<bool> already_have(tx_blobs.size(), false);
969  for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
970  if (!results[i].res)
971  continue;
972  if(m_mempool.have_tx(results[i].hash))
973  {
974  LOG_PRINT_L2("tx " << results[i].hash << "already have transaction in tx_pool");
975  already_have[i] = true;
976  }
977  else if(m_blockchain_storage.have_tx(results[i].hash))
978  {
979  LOG_PRINT_L2("tx " << results[i].hash << " already have transaction in blockchain");
980  already_have[i] = true;
981  }
982  else
983  {
984  tpool.submit(&waiter, [&, i, it] {
985  try
986  {
987  results[i].res = handle_incoming_tx_post(*it, tvc[i], results[i].tx, results[i].hash, keeped_by_block, relayed, do_not_relay);
988  }
989  catch (const std::exception &e)
990  {
991  MERROR_VER("Exception in handle_incoming_tx_post: " << e.what());
992  tvc[i].m_verification_failed = true;
993  results[i].res = false;
994  }
995  });
996  }
997  }
998  waiter.wait(&tpool);
999 
1000  std::vector<tx_verification_batch_info> tx_info;
1001  tx_info.reserve(tx_blobs.size());
1002  for (size_t i = 0; i < tx_blobs.size(); i++) {
1003  if (!results[i].res || already_have[i])
1004  continue;
1005  tx_info.push_back({&results[i].tx, results[i].hash, tvc[i], results[i].res});
1006  }
1007  if (!tx_info.empty())
1008  handle_incoming_tx_accumulated_batch(tx_info, keeped_by_block);
1009 
1010  bool ok = true;
1011  it = tx_blobs.begin();
1012  for (size_t i = 0; i < tx_blobs.size(); i++, ++it) {
1013  if (!results[i].res)
1014  {
1015  ok = false;
1016  continue;
1017  }
1018  if (keeped_by_block)
1020  if (already_have[i])
1021  continue;
1022 
1023  const size_t weight = get_transaction_weight(results[i].tx, it->size());
1024  ok &= add_new_tx(results[i].tx, results[i].hash, tx_blobs[i], weight, tvc[i], keeped_by_block, relayed, do_not_relay);
1025  if(tvc[i].m_verification_failed)
1026  {MERROR_VER("Transaction verification failed: " << results[i].hash);}
1027  else if(tvc[i].m_verification_impossible)
1028  {MERROR_VER("Transaction verification impossible: " << results[i].hash);}
1029 
1030  if(tvc[i].m_added_to_pool)
1031  MDEBUG("tx added: " << results[i].hash);
1032  }
1033  return ok;
1034 
1035  CATCH_ENTRY_L0("core::handle_incoming_txs()", false);
1036  }
void on_new_tx_from_block(const cryptonote::transaction &tx)
called when we see a tx originating from a block
bool have_tx(const crypto::hash &id) const
search the blockchain for a transaction by hash
Definition: blockchain.cpp:164
bool have_tx(const crypto::hash &id) const
checks if the pool has a transaction with the given hash
Definition: tx_pool.cpp:1025
void wait(threadpool *tpool)
Definition: threadpool.cpp:115
A global thread pool.
Definition: threadpool.h:43
static threadpool & getInstance()
Definition: threadpool.h:45
void submit(waiter *waiter, std::function< void()> f, bool leaf=false)
Definition: threadpool.cpp:69
#define MERROR_VER(x)
#define MDEBUG(x)
Definition: misc_log_ex.h:76
#define LOG_PRINT_L2(x)
Definition: misc_log_ex.h:101
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
Here is the call graph for this function:
Here is the caller graph for this function:

◆ have_block()

bool cryptonote::core::have_block ( const crypto::hash id) const

checks if a block is known about with a given hash

This function checks the main chain, alternate chains, and invalid blocks for a block with the given hash

Parameters
idthe hash to search for
Returns
true if the block is known, else false
Note
see Blockchain::have_block

Definition at line 1550 of file cryptonote_core.cpp.

1551  {
1552  return m_blockchain_storage.have_block(id);
1553  }
bool have_block(const crypto::hash &id) const
checks if a block is known about with a given hash
Here is the call graph for this function:

◆ init()

bool cryptonote::core::init ( const boost::program_options::variables_map &  vm,
const test_options test_options = NULL,
const GetCheckpointsCallback get_checkpoints = nullptr 
)

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)

Parameters
vmcommand line parameters
test_optionsconfiguration options for testing
get_checkpointsif 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
Returns
false if one of the init steps fails, otherwise true

Definition at line 497 of file cryptonote_core.cpp.

498  {
499  start_time = std::time(nullptr);
500 
501  const bool regtest = command_line::get_arg(vm, arg_regtest_on);
502  if (test_options != NULL || regtest)
503  {
504  m_nettype = FAKECHAIN;
505  }
506 
507  m_fallback_to_pow = command_line::get_arg(vm, arg_fallback_to_pow);
508  m_fallback_to_pow_checkpoint_height = command_line::get_arg(vm, arg_fallback_to_pow_checkpoint_height);
509  m_fallback_to_pow_checkpoint_hash = command_line::get_arg(vm, arg_fallback_to_pow_checkpoint_hash);
510 
511  bool r = handle_command_line(vm);
512 
515  bool db_salvage = command_line::get_arg(vm, cryptonote::arg_db_salvage) != 0;
516  bool fast_sync = command_line::get_arg(vm, arg_fast_block_sync) != 0;
517  uint64_t blocks_threads = command_line::get_arg(vm, arg_prep_blocks_threads);
518  std::string check_updates_string = command_line::get_arg(vm, arg_check_updates);
519  size_t max_txpool_weight = command_line::get_arg(vm, arg_max_txpool_weight);
520  bool prune_blockchain = command_line::get_arg(vm, arg_prune_blockchain);
521  std::string validator_key = command_line::get_arg(vm, arg_validator_key);
522 
523  bool is_validator_key_valid = std::count_if(validator_key.begin(), validator_key.end(), [](int c) {return !std::isxdigit(c);}) == 0;
524  if(!is_validator_key_valid || validator_key.size() % 2 != 0) {
525  validator_key.clear();
526  }
527 
528  boost::filesystem::path folder(m_config_folder);
529  if (m_nettype == FAKECHAIN)
530  folder /= "fake";
531 
532  // make sure the data directory exists, and try to lock it
533  CHECK_AND_ASSERT_MES (boost::filesystem::exists(folder) || boost::filesystem::create_directories(folder), false,
534  std::string("Failed to create directory ").append(folder.string()).c_str());
535 
536  // check for blockchain.bin
537  try
538  {
539  const boost::filesystem::path old_files = folder;
540  if (boost::filesystem::exists(old_files / "blockchain.bin"))
541  {
542  MWARNING("Found old-style blockchain.bin in " << old_files.string());
543  MWARNING("Electroneum now uses a new format. You can either remove blockchain.bin to start syncing");
544  MWARNING("the blockchain anew, or use electroneum-blockchain-export and electroneum-blockchain-import to");
545  MWARNING("convert your existing blockchain.bin to the new format. See README.md for instructions.");
546  return false;
547  }
548  }
549  // folder might not be a directory, etc, etc
550  catch (...) { }
551 
552  std::unique_ptr<BlockchainDB> db(new_db(db_type));
553  if (db == NULL)
554  {
555  LOG_ERROR("Attempted to use non-existent database type");
556  return false;
557  }
558 
559  folder /= db->get_db_name();
560  MGINFO("Loading blockchain from folder " << folder.string() << " ...");
561 
562  const std::string filename = folder.string();
563  // default to fast:async:1 if overridden
565  bool sync_on_blocks = true;
566  uint64_t sync_threshold = 1;
567 
568  if (m_nettype == FAKECHAIN)
569  {
570  // reset the db by removing the database file before opening it
571  if (!db->remove_data_file(filename))
572  {
573  MERROR("Failed to remove data file in " << filename);
574  return false;
575  }
576  }
577 
578  try
579  {
580  uint64_t db_flags = 0;
581 
582  std::vector<std::string> options;
583  boost::trim(db_sync_mode);
584  boost::split(options, db_sync_mode, boost::is_any_of(" :"));
585  const bool db_sync_mode_is_default = command_line::is_arg_defaulted(vm, cryptonote::arg_db_sync_mode);
586 
587  for(const auto &option : options)
588  MDEBUG("option: " << option);
589 
590  // default to fast:async:1
591  uint64_t DEFAULT_FLAGS = DBF_FAST;
592 
593  if(options.size() == 0)
594  {
595  // default to fast:async:1
596  db_flags = DEFAULT_FLAGS;
597  }
598 
599  bool safemode = false;
600  if(options.size() >= 1)
601  {
602  if(options[0] == "safe")
603  {
604  safemode = true;
605  db_flags = DBF_SAFE;
606  sync_mode = db_sync_mode_is_default ? db_defaultsync : db_nosync;
607  }
608  else if(options[0] == "fast")
609  {
610  db_flags = DBF_FAST;
611  sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
612  }
613  else if(options[0] == "fastest")
614  {
615  db_flags = DBF_FASTEST;
616  sync_threshold = 1000; // default to fastest:async:1000
617  sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
618  }
619  else
620  db_flags = DEFAULT_FLAGS;
621  }
622 
623  if(options.size() >= 2 && !safemode)
624  {
625  if(options[1] == "sync")
626  sync_mode = db_sync_mode_is_default ? db_defaultsync : db_sync;
627  else if(options[1] == "async")
628  sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
629  }
630 
631  if(options.size() >= 3 && !safemode)
632  {
633  char *endptr;
634  uint64_t threshold = strtoull(options[2].c_str(), &endptr, 0);
635  if (*endptr == '\0' || !strcmp(endptr, "blocks"))
636  {
637  sync_on_blocks = true;
638  sync_threshold = threshold;
639  }
640  else if (!strcmp(endptr, "bytes"))
641  {
642  sync_on_blocks = false;
643  sync_threshold = threshold;
644  }
645  else
646  {
647  LOG_ERROR("Invalid db sync mode: " << options[2]);
648  return false;
649  }
650  }
651 
652  if (db_salvage)
653  db_flags |= DBF_SALVAGE;
654 
655  db->open(filename, db_flags);
656  if(!db->m_open)
657  return false;
658  }
659  catch (const DB_ERROR& e)
660  {
661  LOG_ERROR("Error opening database: " << e.what());
662  return false;
663  }
664 
665  m_blockchain_storage.set_user_options(blocks_threads,
666  sync_on_blocks, sync_threshold, sync_mode, fast_sync, validator_key);
667 
668  try
669  {
670  if (!command_line::is_arg_defaulted(vm, arg_block_notify))
671  m_blockchain_storage.set_block_notify(std::shared_ptr<tools::Notify>(new tools::Notify(command_line::get_arg(vm, arg_block_notify).c_str())));
672  }
673  catch (const std::exception &e)
674  {
675  MERROR("Failed to parse block notify spec: " << e.what());
676  }
677 
678  try
679  {
680  if (!command_line::is_arg_defaulted(vm, arg_reorg_notify))
681  m_blockchain_storage.set_reorg_notify(std::shared_ptr<tools::Notify>(new tools::Notify(command_line::get_arg(vm, arg_reorg_notify).c_str())));
682  }
683  catch (const std::exception &e)
684  {
685  MERROR("Failed to parse reorg notify spec: " << e.what());
686  }
687 
688  try
689  {
690  if (!command_line::is_arg_defaulted(vm, arg_block_rate_notify))
691  m_block_rate_notify.reset(new tools::Notify(command_line::get_arg(vm, arg_block_rate_notify).c_str()));
692  }
693  catch (const std::exception &e)
694  {
695  MERROR("Failed to parse block rate notify spec: " << e.what());
696  }
697 
698  const std::pair<uint8_t, uint64_t> regtest_hard_forks[3] = {std::make_pair(1, 0), std::make_pair(Blockchain::get_hard_fork_heights(MAINNET).back().version, 1), std::make_pair(0, 0)};
699  const cryptonote::test_options regtest_test_options = {
700  regtest_hard_forks,
701  0
702  };
703  const difficulty_type fixed_difficulty = command_line::get_arg(vm, arg_fixed_difficulty);
704  const bool ignore_bsig = command_line::get_arg(vm, arg_skip_block_sig_verification);
705 
706  r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, regtest ? &regtest_test_options : test_options, fixed_difficulty, get_checkpoints, ignore_bsig, m_fallback_to_pow);
707 
708  r = m_mempool.init(max_txpool_weight);
709  CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
710 
711  // now that we have a valid m_blockchain_storage, we can clean out any
712  // transactions in the pool that do not conform to the current fork
713  m_mempool.validate(m_blockchain_storage.get_current_hard_fork_version());
714 
715  bool show_time_stats = command_line::get_arg(vm, arg_show_time_stats) != 0;
716  m_blockchain_storage.set_show_time_stats(show_time_stats);
717  CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
718 
719  block_sync_size = command_line::get_arg(vm, arg_block_sync_size);
720 
721  MGINFO("Loading checkpoints");
722 
723  // load json & DNS checkpoints, and verify them
724  // with respect to what blocks we already have
725  CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints.");
726 
727  // DNS versions checking
728  if (check_updates_string == "disabled")
729  check_updates_level = UPDATES_DISABLED;
730  else if (check_updates_string == "notify")
731  check_updates_level = UPDATES_NOTIFY;
732  else if (check_updates_string == "download")
733  check_updates_level = UPDATES_DOWNLOAD;
734  else if (check_updates_string == "update")
735  check_updates_level = UPDATES_UPDATE;
736  else {
737  MERROR("Invalid argument to --dns-versions-check: " << check_updates_string);
738  return false;
739  }
740 
741  check_updates_level = UPDATES_DISABLED;
742 
743  r = m_miner.init(vm, m_nettype, m_fallback_to_pow);
744  CHECK_AND_ASSERT_MES(r, false, "Failed to initialize miner instance");
745 
746  if (prune_blockchain)
747  {
748  // display a message if the blockchain is not pruned yet
749  if (!m_blockchain_storage.get_blockchain_pruning_seed())
750  {
751  MGINFO("Pruning blockchain...");
752  CHECK_AND_ASSERT_MES(m_blockchain_storage.prune_blockchain(), false, "Failed to prune blockchain");
753  }
754  else
755  {
756  CHECK_AND_ASSERT_MES(m_blockchain_storage.update_blockchain_pruning(), false, "Failed to update blockchain pruning");
757  }
758  }
759 
760  if(!m_fallback_to_pow) {
761  m_validators = std::unique_ptr<electroneum::basic::Validators>(new electroneum::basic::Validators(m_blockchain_storage.get_db(), m_pprotocol, m_nettype == TESTNET));
762  m_blockchain_storage.set_validators_list_instance(m_validators);
763 
764  if(m_blockchain_storage.get_current_blockchain_height() >= ((m_nettype == TESTNET ? 446674 : 589169) - 720 )) { //V8 Height - 1 day
765  m_validators->enable();
766  }
767  }
768 
769  return load_state_data();
770  }
time_t time
Definition: blockchain.cpp:93
uint8_t threshold
Definition: blockchain.cpp:92
#define DBF_SAFE
#define DBF_FAST
#define DBF_FASTEST
#define DBF_SALVAGE
uint8_t get_current_hard_fork_version() const
gets the current hardfork version in use/voted for
Definition: blockchain.h:815
bool init(BlockchainDB *db, const network_type nettype=MAINNET, bool offline=false, const cryptonote::test_options *test_options=NULL, difficulty_type fixed_difficulty=0, const GetCheckpointsCallback &get_checkpoints=nullptr, bool ignore_bsig=false, bool fallback_to_pow=false)
Initialize the Blockchain state.
Definition: blockchain.cpp:331
bool prune_blockchain(uint32_t pruning_seed=0)
void set_show_time_stats(bool stats)
set whether or not to show/print time statistics
Definition: blockchain.h:794
static const std::vector< HardFork::Params > & get_hard_fork_heights(network_type nettype)
gets the hardfork heights of given network
void set_block_notify(const std::shared_ptr< tools::Notify > &notify)
sets a block notify object to call for every new block
Definition: blockchain.h:775
void set_reorg_notify(const std::shared_ptr< tools::Notify > &notify)
sets a reorg notify object to call for every reorg
Definition: blockchain.h:782
void set_validators_list_instance(std::unique_ptr< electroneum::basic::Validators > &v)
Definition: blockchain.h:1041
void set_user_options(uint64_t maxthreads, bool sync_on_blocks, uint64_t sync_threshold, blockchain_db_sync_mode sync_mode, bool fast_sync, std::string validator_key)
Update the validators public key by fetching data from electroneum's endpoint.
bool prune_blockchain(uint32_t pruning_seed=0)
prune the blockchain
bool init(const boost::program_options::variables_map &vm, network_type nettype, bool fallback_to_pow=false)
Definition: miner.cpp:291
bool init(size_t max_txpool_weight=0)
loads pool state (if any) from disk, and initializes pool
Definition: tx_pool.cpp:1554
size_t validate(uint8_t version)
remove transactions from the pool which are no longer valid
Definition: tx_pool.cpp:1490
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
#define MGINFO(x)
Definition: misc_log_ex.h:80
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
Definition: command_line.h:265
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
Definition: command_line.h:271
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:43
const command_line::arg_descriptor< bool > arg_db_salvage
const command_line::arg_descriptor< bool > arg_regtest_on
const command_line::arg_descriptor< difficulty_type > arg_fixed_difficulty
const command_line::arg_descriptor< bool > arg_fallback_to_pow
BlockchainDB * new_db(const std::string &db_type)
blockchain_db_sync_mode
Definition: blockchain.h:78
@ db_async
handle syncing calls instead of the backing db, asynchronously
Definition: blockchain.h:81
@ db_nosync
Leave syncing up to the backing db (safest, but slowest because of disk I/O)
Definition: blockchain.h:82
@ db_sync
handle syncing calls instead of the backing db, synchronously
Definition: blockchain.h:80
@ db_defaultsync
user didn't specify, use db_async
Definition: blockchain.h:79
const command_line::arg_descriptor< std::string > arg_fallback_to_pow_checkpoint_hash
const command_line::arg_descriptor< std::string > arg_db_type
const command_line::arg_descriptor< uint64_t > arg_fallback_to_pow_checkpoint_height
const command_line::arg_descriptor< bool > arg_skip_block_sig_verification
const command_line::arg_descriptor< std::string > arg_db_sync_mode
std::string & trim(std::string &str)
Definition: string_tools.h:288
::std::string string
Definition: gtest-port.h:1097
Definition: options.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_options()

void cryptonote::core::init_options ( boost::program_options::options_description &  desc)
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.

Parameters
descreturn-by-reference the command line options set to add to

Definition at line 346 of file cryptonote_core.cpp.

347  {
349 
350  command_line::add_arg(desc, arg_test_drop_download);
351  command_line::add_arg(desc, arg_test_drop_download_height);
352 
358  command_line::add_arg(desc, arg_dns_checkpoints);
359  command_line::add_arg(desc, arg_prep_blocks_threads);
360  command_line::add_arg(desc, arg_fast_block_sync);
361  command_line::add_arg(desc, arg_show_time_stats);
362  command_line::add_arg(desc, arg_block_sync_size);
363  command_line::add_arg(desc, arg_check_updates);
364  command_line::add_arg(desc, arg_fluffy_blocks);
365  command_line::add_arg(desc, arg_no_fluffy_blocks);
366  command_line::add_arg(desc, arg_test_dbg_lock_sleep);
370  command_line::add_arg(desc, arg_max_txpool_weight);
371  command_line::add_arg(desc, arg_pad_transactions);
372  command_line::add_arg(desc, arg_block_notify);
373  command_line::add_arg(desc, arg_prune_blockchain);
374  command_line::add_arg(desc, arg_reorg_notify);
375  command_line::add_arg(desc, arg_block_rate_notify);
376  command_line::add_arg(desc, arg_validator_key);
380 
381  miner::init_options(desc);
383  }
static void init_options(boost::program_options::options_description &desc)
init command line options
static void init_options(boost::program_options::options_description &desc)
Definition: miner.cpp:279
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
Definition: command_line.h:188
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
const command_line::arg_descriptor< bool > arg_offline
const command_line::arg_descriptor< bool, false > arg_testnet_on
const command_line::arg_descriptor< bool, false > arg_stagenet_on
const command_line::arg_descriptor< bool > arg_disable_dns_checkpoints
const command_line::arg_descriptor< size_t > arg_block_download_max_size
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_key_image_spent()

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.

Parameters
key_imthe key image to search for
Returns
true if the key image is already spent in the blockchain, else false
Note
see Blockchain::have_tx_keyimg_as_spent

Definition at line 1130 of file cryptonote_core.cpp.

1131  {
1132  return m_blockchain_storage.have_tx_keyimg_as_spent(key_image);
1133  }
POD_CLASS key_image
Definition: crypto.h:102
Here is the call graph for this function:

◆ is_update_available()

bool cryptonote::core::is_update_available ( ) const
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

Returns
whether an update is known to be available or not

Definition at line 796 of file cryptonote_core.h.

796 { return m_update_available; }
Here is the caller graph for this function:

◆ isValidatorsListValid()

bool cryptonote::core::isValidatorsListValid ( )

get Validators List state

Returns
true if valid, false if invalid or expired

Definition at line 327 of file cryptonote_core.cpp.

327  {
328  return m_validators->isValid();
329  }

◆ offline()

bool cryptonote::core::offline ( ) const
inline

get whether the core is running offline

Returns
whether the core is running offline

Definition at line 824 of file cryptonote_core.h.

824 { return m_offline; }
Here is the caller graph for this function:

◆ on_idle()

bool cryptonote::core::on_idle ( )

calls various idle routines

Note
see miner::on_idle and tx_memory_pool::on_idle
Returns
true

Definition at line 1634 of file cryptonote_core.cpp.

1635  {
1636  if(!m_starter_message_showed)
1637  {
1638  std::string main_message;
1639  if (m_offline)
1640  main_message = "The daemon is running offline and will not attempt to sync to the Electroneum network.";
1641  else
1642  main_message = "The daemon will start synchronizing with the network. This may take a long time to complete.";
1643  MGINFO_YELLOW(ENDL << "**********************************************************************" << ENDL
1644  << main_message << ENDL
1645  << ENDL
1646  << "You can set the level of process detailization through \"set_log <level|categories>\" command," << ENDL
1647  << "where <level> is between 0 (no details) and 4 (very verbose), or custom category based levels (eg, *:WARNING)." << ENDL
1648  << ENDL
1649  << "Use the \"help\" command to see the list of available commands." << ENDL
1650  << "Use \"help <command>\" to see a command's documentation." << ENDL
1651  << "**********************************************************************" << ENDL);
1652  m_starter_message_showed = true;
1653  }
1654  //Don't moan about forks for now, but keep implementation around incase we need to use it at a later stage
1655  //m_fork_moaner.do_call(boost::bind(&core::check_fork_time, this));
1656  m_txpool_auto_relayer.do_call(boost::bind(&core::relay_txpool_transactions, this));
1657  m_check_updates_interval.do_call(boost::bind(&core::check_updates, this));
1658  m_check_disk_space_interval.do_call(boost::bind(&core::check_disk_space, this));
1659  m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
1660  m_blockchain_pruning_interval.do_call(boost::bind(&core::update_blockchain_pruning, this));
1661  m_miner.on_idle();
1662  m_mempool.on_idle();
1663 
1664  if(!m_fallback_to_pow) {
1665  m_validators->on_idle();
1666  }
1667 
1668  return true;
1669  }
bool update_blockchain_pruning()
incrementally prunes blockchain
bool on_idle()
Definition: miner.cpp:178
void on_idle()
action to take periodically
Definition: tx_pool.cpp:587
bool do_call(functor_t functr)
Definition: math_helper.h:263
#define MGINFO_YELLOW(x)
Definition: misc_log_ex.h:83
#define ENDL
Definition: misc_log_ex.h:149
Here is the call graph for this function:

◆ on_synchronized()

void cryptonote::core::on_synchronized ( )

Note
see miner::on_synchronized

Definition at line 1428 of file cryptonote_core.cpp.

1429  {
1430  m_miner.on_synchronized();
1431  }
void on_synchronized()
Definition: miner.cpp:488
Here is the call graph for this function:

◆ on_transaction_relayed()

void cryptonote::core::on_transaction_relayed ( const cryptonote::blobdata tx)
virtual

called when a transaction is relayed

Definition at line 1293 of file cryptonote_core.cpp.

1294  {
1295  std::vector<std::pair<crypto::hash, cryptonote::blobdata>> txs;
1297  crypto::hash tx_hash;
1298  if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash))
1299  {
1300  LOG_ERROR("Failed to parse relayed transaction");
1301  return;
1302  }
1303  txs.push_back(std::make_pair(tx_hash, std::move(tx_blob)));
1304  m_mempool.set_relayed(txs);
1305  }
void set_relayed(const std::vector< std::pair< crypto::hash, cryptonote::blobdata >> &txs)
tell the pool that certain transactions were just relayed
Definition: tx_pool.cpp:699
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
const T & move(const T &t)
Definition: gtest-port.h:1317
Here is the call graph for this function:

◆ pad_transactions()

bool cryptonote::core::pad_transactions ( ) const
inline

get whether transaction relay should be padded

Returns
whether transaction relay should be padded

Definition at line 810 of file cryptonote_core.h.

810 { return m_pad_transactions; }

◆ pause_mine()

void cryptonote::core::pause_mine ( )

Note
see miner::pause

Definition at line 1347 of file cryptonote_core.cpp.

1348  {
1349  m_miner.pause();
1350  }
Here is the call graph for this function:

◆ pool_has_tx()

bool cryptonote::core::pool_has_tx ( const crypto::hash txid) const

checks if the pool has a transaction with the given hash

Parameters
idthe hash to look for
Returns
true if the transaction is in the pool, otherwise false
Note
see tx_memory_pool::have_tx

Definition at line 1588 of file cryptonote_core.cpp.

1589  {
1590  return m_mempool.have_tx(id);
1591  }
Here is the call graph for this function:

◆ prepare_handle_incoming_blocks()

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

Parameters
blocks_entrya list of incoming blocks
blocksthe parsed blocks
Returns
false on erroneous blocks, else true
Note
see Blockchain::prepare_handle_incoming_blocks

Definition at line 1444 of file cryptonote_core.cpp.

1445  {
1446  m_incoming_tx_lock.lock();
1447  if (!m_blockchain_storage.prepare_handle_incoming_blocks(blocks_entry, blocks))
1448  {
1450  return false;
1451  }
1452  return true;
1453  }
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_pool()

std::string cryptonote::core::print_pool ( bool  short_format) const

get a string containing human-readable pool information

Parameters
short_formatwhether to use a shortened format for the info
Returns
the string
Note
see tx_memory_pool::print_pool

Definition at line 1623 of file cryptonote_core.cpp.

1624  {
1625  return m_mempool.print_pool(short_format);
1626  }
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
Definition: tx_pool.cpp:1325
Here is the call graph for this function:

◆ prune_blockchain()

bool cryptonote::core::prune_blockchain ( uint32_t  pruning_seed = 0)

prune the blockchain

Parameters
pruning_seedthe seed to use to prune the chain (0 for default, highly recommended)
Returns
true iff success

Definition at line 1979 of file cryptonote_core.cpp.

1980  {
1981  return get_blockchain_storage().prune_blockchain(pruning_seed);
1982  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resume_mine()

void cryptonote::core::resume_mine ( )

Note
see miner::resume

Definition at line 1352 of file cryptonote_core.cpp.

1353  {
1354  m_miner.resume();
1355  }
Here is the call graph for this function:

◆ safesyncmode()

void cryptonote::core::safesyncmode ( const bool  onoff)

Put DB in safe sync mode.

2note see Blockchain::safesyncmode

Definition at line 1433 of file cryptonote_core.cpp.

1434  {
1435  m_blockchain_storage.safesyncmode(onoff);
1436  }
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Here is the call graph for this function:

◆ set_block_cumulative_difficulty()

void cryptonote::core::set_block_cumulative_difficulty ( uint64_t  height,
difficulty_type  diff 
)

Note
see Blockchain::set_block_cumulative_difficulty

Definition at line 1535 of file cryptonote_core.cpp.

1536  {
1537  return m_blockchain_storage.get_db().set_block_cumulative_difficulty(height, diff);
1538  }
virtual void set_block_cumulative_difficulty(uint64_t height, difficulty_type diff)=0
sets a block's cumulative difficulty
Here is the call graph for this function:

◆ set_checkpoints()

void cryptonote::core::set_checkpoints ( checkpoints &&  chk_pts)

assign a set of blockchain checkpoint hashes

Parameters
chk_ptsthe set of checkpoints to assign
Note
see Blockchain::set_checkpoints()

Definition at line 275 of file cryptonote_core.cpp.

276  {
277  m_blockchain_storage.set_checkpoints(std::move(chk_pts));
278  }
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition: blockchain.h:175
Here is the call graph for this function:

◆ set_checkpoints_file_path()

void cryptonote::core::set_checkpoints_file_path ( const std::string &  path)

set the file path to read from when loading checkpoints

Parameters
paththe path to set ours as

Definition at line 280 of file cryptonote_core.cpp.

281  {
282  m_checkpoints_path = path;
283  }

◆ set_cryptonote_protocol()

void cryptonote::core::set_cryptonote_protocol ( i_cryptonote_protocol pprotocol)

set the pointer to the cryptonote protocol object to use

Parameters
pprotocolthe pointer to set ours as

Definition at line 267 of file cryptonote_core.cpp.

268  {
269  if(pprotocol)
270  m_pprotocol = pprotocol;
271  else
272  m_pprotocol = &m_protocol_stub;
273  }
Here is the caller graph for this function:

◆ set_enforce_dns_checkpoints()

void cryptonote::core::set_enforce_dns_checkpoints ( bool  enforce_dns)

set whether or not we enforce DNS checkpoints

Parameters
enforce_dnsenforce DNS checkpoints or not

Definition at line 285 of file cryptonote_core.cpp.

286  {
287  m_blockchain_storage.set_enforce_dns_checkpoints(enforce_dns);
288  }
void set_enforce_dns_checkpoints(bool enforce)
configure whether or not to enforce DNS-based checkpoints
Here is the call graph for this function:

◆ set_genesis_block()

bool cryptonote::core::set_genesis_block ( const block b)

clears the blockchain and starts a new one

Parameters
bthe first block in the new chain (the genesis block)
Returns
true on success, else false
Note
see Blockchain::reset_and_set_genesis_block

Definition at line 772 of file cryptonote_core.cpp.

773  {
774  return m_blockchain_storage.reset_and_set_genesis_block(b);
775  }
bool reset_and_set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition: blockchain.cpp:698
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_target_blockchain_height()

void cryptonote::core::set_target_blockchain_height ( uint64_t  target_blockchain_height)

sets the target blockchain height

Parameters
target_blockchain_heightthe height to set

Definition at line 1957 of file cryptonote_core.cpp.

1958  {
1959  m_target_blockchain_height = target_blockchain_height;
1960  }

◆ set_validator_key()

bool cryptonote::core::set_validator_key ( std::string  key)

set validator key

Parameters
keykey to set as new validator key
Returns
whether this new key was set or not

Definition at line 1989 of file cryptonote_core.cpp.

1989  {
1990  bool is_validator_key_valid = std::count_if(key.begin(), key.end(), [](int c) {return !std::isxdigit(c);}) == 0;
1991  if(!is_validator_key_valid || key.size() % 2 != 0) {
1992  return false;
1993  }
1994 
1995  m_miner.pause();
1996  m_blockchain_storage.set_validator_key(key);
1997  m_miner.resume();
1998 
1999  return true;
2000  }
void set_validator_key(std::string key)
set validator key
Definition: blockchain.h:1039
const char * key
Definition: hmac_keccak.cpp:39
Here is the call graph for this function:

◆ set_validators_list()

electroneum::basic::list_update_outcome cryptonote::core::set_validators_list ( std::string  v_list,
bool  isEmergencyUpdate 
)

set the list of validators according to the serialized string passed in as parameter

Parameters
v_listserialized validators list string
Returns
true if successfull

Definition at line 323 of file cryptonote_core.cpp.

323  {
324  return m_validators->setValidatorsList(v_list, true, isEmergencyUpdate);
325  }

◆ sign_message()

std::string cryptonote::core::sign_message ( std::string  sk,
std::string  msg 
)

Definition at line 2007 of file cryptonote_core.cpp.

2007  {
2008  std::string b_str = crypto::sign_message(msg, sk);
2009  return boost::algorithm::hex(b_str);
2010  }
std::string sign_message(const std::string &message, const std::string &privateKey)
Definition: crypto.h:374
Here is the call graph for this function:

◆ stop()

void cryptonote::core::stop ( )

stops the daemon running

Note
see graceful_exit()

Definition at line 331 of file cryptonote_core.cpp.

332  {
333  m_miner.stop();
334  m_blockchain_storage.cancel();
335 
337  {
338  boost::lock_guard<boost::mutex> lock(m_update_mutex);
339  handle = m_update_download;
340  m_update_download = 0;
341  }
342  if (handle)
343  tools::download_cancel(handle);
344  }
std::shared_ptr< download_thread_control > download_async_handle
Definition: download.h:36
bool download_cancel(const download_async_handle &control)
Definition: download.cpp:299
Here is the call graph for this function:

◆ test_drop_download()

void cryptonote::core::test_drop_download ( )

sets to drop blocks downloaded (for testing)

Definition at line 791 of file cryptonote_core.cpp.

792  {
793  m_test_drop_download = false;
794  }

◆ test_drop_download_height()

void cryptonote::core::test_drop_download_height ( uint64_t  height)

sets to drop blocks downloaded below a certain height

Parameters
heightheight below which to drop blocks

Definition at line 796 of file cryptonote_core.cpp.

797  {
798  m_test_drop_download_height = height;
799  }

◆ update_blockchain_pruning()

bool cryptonote::core::update_blockchain_pruning ( )

incrementally prunes blockchain

Returns
true on success, false otherwise

Definition at line 1947 of file cryptonote_core.cpp.

1948  {
1949  return m_blockchain_storage.update_blockchain_pruning();
1950  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_checkpoints()

bool cryptonote::core::update_checkpoints ( )

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.

Note
see Blockchain::update_checkpoints()

Definition at line 290 of file cryptonote_core.cpp.

291  {
292  if (m_nettype != MAINNET || m_disable_dns_checkpoints) return true;
293 
294  if (m_checkpoints_updating.test_and_set()) return true;
295 
296  bool res = true;
297  if (time(NULL) - m_last_dns_checkpoints_update >= 3600)
298  {
299  res = m_blockchain_storage.update_checkpoints(m_checkpoints_path, true);
300  m_last_dns_checkpoints_update = time(NULL);
301  m_last_json_checkpoints_update = time(NULL);
302  }
303  else if (time(NULL) - m_last_json_checkpoints_update >= 600)
304  {
305  res = m_blockchain_storage.update_checkpoints(m_checkpoints_path, false);
306  m_last_json_checkpoints_update = time(NULL);
307  }
308 
309  m_checkpoints_updating.clear();
310 
311  // if anything fishy happened getting new checkpoints, bring down the house
312  if (!res)
313  {
314  graceful_exit();
315  }
316  return res;
317  }
bool update_checkpoints(const std::string &file_path, bool check_dns)
loads new checkpoints from a file and optionally from DNS
void graceful_exit()
tells the daemon to wind down operations and stop running
Here is the call graph for this function:
Here is the caller graph for this function:

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