Monero
Loading...
Searching...
No Matches
cryptonote_core.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31#pragma once
32
33#include <ctime>
34
35#include <boost/function.hpp>
36#include <boost/program_options/options_description.hpp>
37#include <boost/program_options/variables_map.hpp>
38
43#include "common/download.h"
44#include "common/command_line.h"
45#include "tx_pool.h"
46#include "blockchain.h"
49#include "warnings.h"
50#include "crypto/hash.h"
51#include "span.h"
52#include "rpc/fwd.h"
53
56
58
59namespace cryptonote
60{
61 struct test_options {
62 const std::pair<uint8_t, uint64_t> *hard_forks;
64 };
65
74
75 /************************************************************************/
76 /* */
77 /************************************************************************/
78
86 class core final: public i_miner_handler, public i_core_events
87 {
88 public:
89
97 core(i_cryptonote_protocol* pprotocol);
98
106
114 bool on_idle();
115
129 bool handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
130
151 bool handle_single_incoming_block(const blobdata& block_blob,
152 const block *b,
154 pool_supplement& extra_block_txs,
155 bool update_miner_blocktemplate = true);
156
179 bool handle_incoming_block(const blobdata& block_blob, const block *b,
181 bool update_miner_blocktemplate = true);
182
183 bool handle_incoming_block(const blobdata& block_blob, const block *b,
184 block_verification_context& bvc, pool_supplement& extra_block_txs,
185 bool update_miner_blocktemplate = true);
186
192 bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
193
199 bool cleanup_handle_incoming_blocks(bool force_sync = false);
200
208 bool check_incoming_block_size(const blobdata& block_blob) const;
209
216
217 //-------------------- i_miner_handler -----------------------
218
231 virtual bool handle_block_found(block& b, block_verification_context &bvc) override;
232
238 virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) override;
239 virtual bool get_block_template(block& b, const crypto::hash *prev_block, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash);
240
246 bool get_miner_data(uint8_t& major_version, uint64_t& height, crypto::hash& prev_id, crypto::hash& seed_hash, difficulty_type& difficulty, uint64_t& median_weight, uint64_t& already_generated_coins, std::vector<tx_block_template_backlog_entry>& tx_backlog);
247
253
254
261
267 const miner& get_miner()const{return m_miner;}
268
277 static void init_options(boost::program_options::options_description& desc);
278
286 static network_type get_network_type_from_args(const boost::program_options::variables_map& vm);
287
301 bool init(const boost::program_options::variables_map& vm, const test_options *test_options = NULL, const GetCheckpointsCallback& get_checkpoints = nullptr, bool allow_dns = true);
302
308 bool set_genesis_block(const block& b);
309
317 bool deinit();
318
322 void test_drop_download();
323
330
336 bool get_test_drop_download() const;
337
347
353 virtual uint64_t get_current_blockchain_height() const final;
354
361 void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
362
368 bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks, std::vector<cryptonote::blobdata>& txs) const;
369
375 bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks) const;
376
382 bool get_blocks(uint64_t start_offset, size_t count, std::vector<block>& blocks) const;
383
389 template<class t_ids_container, class t_blocks_container, class t_missed_container>
390 bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) const
391 {
392 return m_blockchain_storage.get_blocks(block_ids, blocks, missed_bs);
393 }
394
401
407 bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
408
414 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;
415
421 bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
422
428 bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
429
435 bool get_alternative_blocks(std::vector<block>& blocks) const;
436
442 size_t get_alternative_blocks_count() const;
443
450
456 const checkpoints& get_checkpoints() const;
457
463 void set_checkpoints(checkpoints&& chk_pts);
464
470 void set_checkpoints_file_path(const std::string& path);
471
477 void set_enforce_dns_checkpoints(bool enforce_dns);
478
484 void disable_dns_checkpoints(bool disable = true) { m_disable_dns_checkpoints = disable; }
485
491 bool pool_has_tx(const crypto::hash &txid) const;
492
499 bool get_pool_transactions(std::vector<transaction>& txs, bool include_sensitive_txes = false) const;
500
507 bool get_txpool_backlog(std::vector<tx_backlog_entry>& backlog, bool include_sensitive_txes = false) const;
508
515 bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_sensitive_txes = false) const;
516
523 bool get_pool_transactions_info(const std::vector<crypto::hash>& txids, std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>>& txs, bool include_sensitive_txes = false) const;
524
532 bool get_pool_info(time_t start_time, bool include_sensitive_txes, size_t max_tx_count, std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>>& added_txs, std::vector<crypto::hash>& remaining_added_txids, std::vector<crypto::hash>& removed_txs, bool& incremental) const;
533
540 bool get_pool_transaction_stats(struct txpool_stats& stats, bool include_sensitive_txes = false) const;
541
547 bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx, relay_category tx_category) const;
548
555 bool get_pool_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos, bool include_sensitive_txes = false) const;
556
562 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;
563
570 size_t get_pool_transactions_count(bool include_sensitive_txes = false) const;
571
578
584 bool have_block_unlocked(const crypto::hash& id, int *where = NULL) const;
585 bool have_block(const crypto::hash& id, int *where = NULL) const;
586
592 bool get_short_chain_history(std::list<crypto::hash>& ids, uint64_t& current_height) const;
593
599 bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
600
606 bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const;
607
613 bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs) const;
614 bool get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes, std::vector<std::vector<uint64_t>>& indexs) const;
615
622
629
636
642 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;
643
649 void pause_mine();
650
656 void resume_mine();
657
664
671
677 std::string print_pool(bool short_format) const;
678
684 virtual bool is_synchronized() const final;
685
691 void on_synchronized();
692
698 void safesyncmode(const bool onoff);
699
705 void set_target_blockchain_height(uint64_t target_blockchain_height);
706
713
720
727
734
741
746 std::time_t get_start_time() const;
747
758 bool update_checkpoints(const bool skip_dns = false);
759
766 void graceful_exit();
767
773 void stop();
774
780 bool is_key_image_spent(const crypto::key_image& key_im) const;
781
792 bool are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
793
802 bool are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
803
809 size_t get_block_sync_size(uint64_t height) const;
810
816 std::pair<boost::multiprecision::uint128_t, boost::multiprecision::uint128_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);
817
823 network_type get_nettype() const { return m_nettype; };
824
834
840 uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights);
841
847 uint64_t get_free_space() const;
848
854 bool offline() const { return m_offline; }
855
862
870 bool prune_blockchain(uint32_t pruning_seed = 0);
871
878
885
892
896 bool has_block_weights(uint64_t height, uint64_t nblocks) const;
897
902
910 bool get_txpool_complement(std::vector<crypto::hash> hashes, std::vector<cryptonote::blobdata> &txes);
911
930 uint8_t hf_version);
931
940
949 static bool check_tx_inputs_ring_members_diff(const transaction& tx, const uint8_t hf_version);
950
960
961 private:
962
973 bool add_new_tx(transaction& tx, const crypto::hash& tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
974
989 bool add_new_tx(transaction& tx, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
990
997 pool_supplement& extra_block_txs);
998
1006 bool load_state_data();
1007
1016
1024 bool handle_command_line(const boost::program_options::variables_map& vm);
1025
1032
1038 bool notify_txpool_event(const epee::span<const cryptonote::blobdata> tx_blobs, epee::span<const crypto::hash> tx_hashes, epee::span<const cryptonote::transaction> txs, const std::vector<bool> &just_broadcasted) const;
1039
1045 bool check_updates();
1046
1052 bool check_disk_space();
1053
1059 bool check_block_rate();
1060
1067
1069
1071
1074
1076
1078
1079 //m_miner and m_miner_addres are probably temporary here
1081
1082 std::string m_config_folder;
1083
1085
1093
1094 std::atomic<bool> m_starter_message_showed;
1095
1097
1099
1100 std::atomic<bool> m_update_available;
1101
1105
1106 std::atomic_flag m_checkpoints_updating;
1108
1110
1112
1113 enum {
1119
1122 boost::mutex m_update_mutex;
1123
1125
1126 std::shared_ptr<tools::Notify> m_block_rate_notify;
1127 };
1128}
1129
cryptonote::block b
Definition block.cpp:40
static uint64_t h
Definition blockchain_stats.cpp:55
Definition blockchain.h:103
A container for blockchain checkpoints.
Definition checkpoints.h:53
epee::math_helper::once_a_time_seconds< 60 *60 *5, true > m_blockchain_pruning_interval
interval for incremental blockchain pruning
Definition cryptonote_core.h:1091
size_t block_sync_size
Definition cryptonote_core.h:1109
static bool check_tx_inputs_keyimages_diff(const transaction &tx)
verify that each input key image in a transaction is unique
Definition cryptonote_core.cpp:1024
bool pool_has_tx(const crypto::hash &txid) const
checks if the pool has a transaction with the given hash
Definition cryptonote_core.cpp:1541
static bool check_tx_semantic(const transaction &tx, tx_verification_context &tvc, uint8_t hf_version)
validates some simple properties of a transaction
Definition cryptonote_core.cpp:836
bool check_updates()
checks DNS versions
Definition cryptonote_core.cpp:1639
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Definition cryptonote_core.cpp:1351
bool update_blockchain_pruning()
incrementally prunes blockchain
Definition cryptonote_core.cpp:1868
bool get_transactions(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs, bool pruned=false) const
Definition cryptonote_core.cpp:432
bool is_within_compiled_block_hash_area(uint64_t height) const
checks whether a given block height is included in the precompiled block hash area
Definition cryptonote_core.cpp:1910
bool m_offline
Definition cryptonote_core.h:1124
tx_memory_pool m_mempool
transaction pool instance
Definition cryptonote_core.h:1072
virtual void on_transactions_relayed(epee::span< const cryptonote::blobdata > tx_blobs, relay_method tx_relay) final
called when a transaction is relayed.
Definition cryptonote_core.cpp:1185
void get_blockchain_top(uint64_t &height, crypto::hash &top_id) const
get the hash and height of the most recent block
Definition cryptonote_core.cpp:407
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
Definition cryptonote_core.cpp:1561
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Definition cryptonote_core.cpp:458
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector< crypto::hash > &hashes, const std::vector< uint64_t > &weights)
check a set of hashes against the precompiled hash set
Definition cryptonote_core.cpp:1888
void stop()
stops the daemon running
Definition cryptonote_core.cpp:299
epee::math_helper::once_a_time_seconds< 60 *60 *2, true > m_fork_moaner
interval for checking HardFork status
Definition cryptonote_core.h:1087
bool get_pool_transactions_info(const std::vector< crypto::hash > &txids, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > &txs, bool include_sensitive_txes=false) const
Definition cryptonote_core.cpp:1508
bool is_key_image_spent(const crypto::key_image &key_im) const
check if a key image is already spent on the blockchain
Definition cryptonote_core.cpp:933
bool has_block_weights(uint64_t height, uint64_t nblocks) const
checks whether block weights are known for the given range
Definition cryptonote_core.cpp:1915
void set_cryptonote_protocol(i_cryptonote_protocol *pprotocol)
set the pointer to the cryptonote protocol object to use
Definition cryptonote_core.cpp:243
uint8_t get_hard_fork_version(uint64_t height) const
return the hard fork version for a given block height
Definition cryptonote_core.cpp:1629
bool check_disk_space()
checks free disk space
Definition cryptonote_core.cpp:1769
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition cryptonote_core.cpp:314
epee::math_helper::once_a_time_seconds< 60 *60 *12, true > m_check_updates_interval
interval for checking for new versions
Definition cryptonote_core.h:1088
bool get_test_drop_download_height() const
gets whether or not to drop blocks
Definition cryptonote_core.cpp:774
void pause_mine()
Definition cryptonote_core.cpp:1259
std::shared_ptr< tools::Notify > m_block_rate_notify
Definition cryptonote_core.h:1126
time_t m_last_json_checkpoints_update
time when json checkpoints were last updated
Definition cryptonote_core.h:1104
bool handle_command_line(const boost::program_options::variables_map &vm)
act on a set of command line options given
Definition cryptonote_core.cpp:359
bool update_miner_block_template()
Definition cryptonote_core.cpp:1581
void flush_invalid_blocks()
flushes the invalid block cache
Definition cryptonote_core.cpp:1858
const Blockchain & get_blockchain_storage() const
gets the Blockchain instance (const)
Definition cryptonote_core.h:670
void graceful_exit()
tells the daemon to wind down operations and stop running
Definition cryptonote_core.cpp:1925
static network_type get_network_type_from_args(const boost::program_options::variables_map &vm)
resolves the network type based on command line arguments
Definition cryptonote_core.cpp:349
epee::math_helper::once_a_time_seconds< 90, false > m_block_rate_interval
interval for checking block rate
Definition cryptonote_core.h:1090
void test_drop_download_height(uint64_t height)
sets to drop blocks downloaded below a certain height
Definition cryptonote_core.cpp:764
void resume_mine()
Definition cryptonote_core.cpp:1264
bool get_pool_info(time_t start_time, bool include_sensitive_txes, size_t max_tx_count, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details > > &added_txs, std::vector< crypto::hash > &remaining_added_txids, std::vector< crypto::hash > &removed_txs, bool &incremental) const
get info necessary for update of pool-related info in a wallet, preferably incremental
Definition cryptonote_core.cpp:1525
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
Definition cryptonote_core.cpp:989
bool on_idle()
calls various idle routines
Definition cryptonote_core.cpp:1587
uint64_t get_free_space() const
get free disk space on the blockchain partition
Definition cryptonote_core.cpp:1893
uint32_t get_blockchain_pruning_seed() const
get the blockchain pruning seed
Definition cryptonote_core.cpp:1900
network_type m_nettype
which network are we on?
Definition cryptonote_core.h:1098
difficulty_type get_block_cumulative_difficulty(uint64_t height) const
Definition cryptonote_core.cpp:1488
bool get_pool_transaction_hashes(std::vector< crypto::hash > &txs, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition cryptonote_core.cpp:1519
bool is_update_available() const
check whether an update is known to be available or not
Definition cryptonote_core.h:833
bool get_short_chain_history(std::list< crypto::hash > &ids, uint64_t &current_height) const
gets the hashes for a subset of the blockchain
Definition cryptonote_core.cpp:1556
miner m_miner
miner instance
Definition cryptonote_core.h:1080
Blockchain m_blockchain_storage
Blockchain instance.
Definition cryptonote_core.h:1073
bool have_block(const crypto::hash &id, int *where=NULL) const
Definition cryptonote_core.cpp:1503
bool get_pool_transactions(std::vector< transaction > &txs, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition cryptonote_core.cpp:1513
std::string m_config_folder
folder to look in for configs and other files
Definition cryptonote_core.h:1082
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
Definition cryptonote_core.cpp:1362
bool check_block_rate()
checks block rate, and warns if it's too slow
Definition cryptonote_core.cpp:1812
uint64_t m_target_blockchain_height
blockchain height target
Definition cryptonote_core.h:1096
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition cryptonote_core.cpp:740
size_t get_blockchain_total_transactions() const
gets the total number of transactions on the main chain
Definition cryptonote_core.cpp:1074
bool have_block_unlocked(const crypto::hash &id, int *where=NULL) const
Definition cryptonote_core.cpp:1498
bool add_new_block(const block &b, block_verification_context &bvc, pool_supplement &extra_block_txs)
adds a block to the blockchain
Definition cryptonote_core.cpp:1356
@ UPDATES_NOTIFY
Definition cryptonote_core.h:1115
@ UPDATES_UPDATE
Definition cryptonote_core.h:1117
@ UPDATES_DOWNLOAD
Definition cryptonote_core.h:1116
@ UPDATES_DISABLED
Definition cryptonote_core.h:1114
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition cryptonote_core.cpp:1619
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition cryptonote_core.cpp:1483
bool get_test_drop_download() const
gets whether or not to drop blocks (for testing)
Definition cryptonote_core.cpp:769
bool m_disable_dns_checkpoints
Definition cryptonote_core.h:1107
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition cryptonote_core.cpp:1378
virtual uint64_t get_current_blockchain_height() const final
get the current height of the blockchain
Definition cryptonote_core.cpp:402
std::atomic_flag m_checkpoints_updating
set if checkpoints are currently updating to avoid multiple threads attempting to update at once
Definition cryptonote_core.h:1106
virtual bool is_synchronized() const final
gets the core synchronization status
Definition cryptonote_core.cpp:1341
std::string m_checkpoints_path
path to json checkpoints file
Definition cryptonote_core.h:1102
bool load_state_data()
load any core state stored on disk
Definition cryptonote_core.cpp:745
epee::math_helper::once_a_time_seconds< 60 *60 *12, false > m_store_blockchain_interval
interval for manual storing of Blockchain, if enabled
Definition cryptonote_core.h:1086
bool get_txpool_complement(std::vector< crypto::hash > hashes, std::vector< cryptonote::blobdata > &txes)
returns the set of transactions in the txpool which are not in the argument
Definition cryptonote_core.cpp:1863
void set_checkpoints_file_path(const std::string &path)
set the file path to read from when loading checkpoints
Definition cryptonote_core.cpp:260
bool check_blockchain_pruning()
checks the blockchain pruning if enabled
Definition cryptonote_core.cpp:1873
size_t get_block_sync_size(uint64_t height) const
get the number of blocks to sync in one go
Definition cryptonote_core.cpp:948
bool offline() const
get whether the core is running offline
Definition cryptonote_core.h:854
bool notify_txpool_event(const epee::span< const cryptonote::blobdata > tx_blobs, epee::span< const crypto::hash > tx_hashes, epee::span< const cryptonote::transaction > txs, const std::vector< bool > &just_broadcasted) const
sends notification of txpool events to subscribers
Definition cryptonote_core.cpp:1155
bool deinit()
performs safe shutdown steps for core and core components
Definition cryptonote_core.cpp:751
network_type get_nettype() const
get the network type we're on
Definition cryptonote_core.h:823
core(i_cryptonote_protocol *pprotocol)
constructor
Definition cryptonote_core.cpp:224
virtual bool get_block_template(block &b, const account_public_address &adr, difficulty_type &diffic, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) override
creates a new block to mine against
Definition cryptonote_core.cpp:1214
const miner & get_miner() const
gets the miner instance (const)
Definition cryptonote_core.h:267
std::time_t get_start_time() const
gets start_time
Definition cryptonote_core.cpp:1920
uint64_t m_test_drop_download_height
height under which to drop incoming blocks, if doing so
Definition cryptonote_core.h:1070
bool handle_single_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, pool_supplement &extra_block_txs, bool update_miner_blocktemplate=true)
handles a single incoming block
Definition cryptonote_core.cpp:1434
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition cryptonote_core.cpp:255
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
Definition cryptonote_core.cpp:1576
size_t get_pool_transactions_count(bool include_sensitive_txes=false) const
get the total number of transactions in the pool
Definition cryptonote_core.cpp:1493
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block as part of a batch
Definition cryptonote_core.cpp:1390
std::atomic< bool > m_starter_message_showed
has the "daemon will sync now" message been shown?
Definition cryptonote_core.h:1094
static bool check_tx_inputs_ring_members_diff(const transaction &tx, const uint8_t hf_version)
verify that each ring uses distinct members
Definition cryptonote_core.cpp:1036
void set_target_blockchain_height(uint64_t target_blockchain_height)
sets the target blockchain height
Definition cryptonote_core.cpp:1878
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
Definition cryptonote_core.cpp:1239
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition cryptonote_core.cpp:1566
bool get_pool_transaction(const crypto::hash &id, cryptonote::blobdata &tx, relay_category tx_category) const
get a specific transaction from the pool
Definition cryptonote_core.cpp:1536
bool update_checkpoints(const bool skip_dns=false)
tells the Blockchain to update its checkpoints
Definition cryptonote_core.cpp:270
i_cryptonote_protocol * get_protocol()
get the cryptonote protocol instance
Definition cryptonote_core.h:215
uint64_t get_target_blockchain_height() const
gets the target blockchain height
Definition cryptonote_core.cpp:1883
void on_synchronized()
Definition cryptonote_core.cpp:1346
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Definition cryptonote_core.cpp:453
bool recalculate_difficulties()
recalculate difficulties after the last difficulty checklpoint to circumvent the annoying 'difficulty...
Definition cryptonote_core.cpp:1852
tools::download_async_handle m_update_download
Definition cryptonote_core.h:1120
void set_enforce_dns_checkpoints(bool enforce_dns)
set whether or not we enforce DNS checkpoints
Definition cryptonote_core.cpp:265
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
Definition cryptonote_core.cpp:437
bool m_test_drop_download
whether or not to drop incoming blocks (for testing)
Definition cryptonote_core.h:1068
bool check_incoming_block_size(const blobdata &block_blob) const
check the size of a block against the current maximum
Definition cryptonote_core.cpp:1469
void disable_dns_checkpoints(bool disable=true)
set whether or not to enable or disable DNS checkpoints
Definition cryptonote_core.h:484
epee::critical_section m_incoming_tx_lock
incoming transaction lock
Definition cryptonote_core.h:1077
std::atomic< bool > m_update_available
Definition cryptonote_core.h:1100
epee::math_helper::once_a_time_seconds< 60 *60 *24 *7, false > m_diff_recalc_interval
interval for recalculating difficulties
Definition cryptonote_core.h:1092
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 cryptonote_core.cpp:1551
bool get_pool_transaction_stats(struct txpool_stats &stats, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition cryptonote_core.cpp:1530
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp) const
Definition cryptonote_core.cpp:1229
void test_drop_download()
sets to drop blocks downloaded (for testing)
Definition cryptonote_core.cpp:759
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block > > &blocks, std::vector< cryptonote::blobdata > &txs) const
Definition cryptonote_core.cpp:412
size_t m_last_update_length
Definition cryptonote_core.h:1121
bool get_pool_transactions_and_spent_keys_info(std::vector< tx_info > &tx_infos, std::vector< spent_key_image_info > &key_image_infos, bool include_sensitive_txes=false) const
Definition cryptonote_core.cpp:1546
bool prune_blockchain(uint32_t pruning_seed=0)
prune the blockchain
Definition cryptonote_core.cpp:1905
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
return the earliest block a given version may activate
Definition cryptonote_core.cpp:1634
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan=NULL) const
gets the block with a given hash
Definition cryptonote_core.cpp:1571
i_cryptonote_protocol * m_pprotocol
cryptonote protocol instance
Definition cryptonote_core.h:1075
cryptonote_protocol_stub m_protocol_stub
cryptonote protocol stub instance
Definition cryptonote_core.h:1084
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
Definition cryptonote_core.cpp:938
static bool check_tx_inputs_keyimages_domain(const transaction &tx)
verify that each input key image in a transaction is in the valid domain
Definition cryptonote_core.cpp:1051
epee::math_helper::once_a_time_seconds< 60 *10, true > m_check_disk_space_interval
interval for checking for disk space
Definition cryptonote_core.h:1089
boost::mutex m_update_mutex
Definition cryptonote_core.h:1122
enum cryptonote::core::@176231357257140137215223266231333145057172114107 check_updates_level
bool get_txpool_backlog(std::vector< tx_backlog_entry > &backlog, bool include_sensitive_txes=false) const
Definition cryptonote_core.cpp:442
Blockchain & get_blockchain_storage()
gets the Blockchain instance
Definition cryptonote_core.h:663
time_t start_time
Definition cryptonote_core.h:1111
virtual bool handle_block_found(block &b, block_verification_context &bvc) override
stores and relays a block found by a miner
Definition cryptonote_core.cpp:1283
time_t m_last_dns_checkpoints_update
time when dns checkpoints were last updated
Definition cryptonote_core.h:1103
const checkpoints & get_checkpoints() const
get a set of blockchain checkpoint hashes
Definition cryptonote_core.cpp:251
bool handle_incoming_tx(const blobdata &tx_blob, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
handles an incoming transaction
Definition cryptonote_core.cpp:785
bool add_new_tx(transaction &tx, const crypto::hash &tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
Definition cryptonote_core.cpp:1079
bool relay_txpool_transactions()
attempts to relay any transactions in the mempool which need it
Definition cryptonote_core.cpp:1110
miner & get_miner()
gets the miner instance
Definition cryptonote_core.h:260
std::pair< boost::multiprecision::uint128_t, boost::multiprecision::uint128_t > get_coinbase_tx_sum(const uint64_t start_offset, const size_t count)
get the sum of coinbase tx amounts between blocks
Definition cryptonote_core.cpp:996
bool get_miner_data(uint8_t &major_version, uint64_t &height, crypto::hash &prev_id, crypto::hash &seed_hash, difficulty_type &difficulty, uint64_t &median_weight, uint64_t &already_generated_coins, std::vector< tx_block_template_backlog_entry > &tx_backlog)
gets data required to create a block template and start mining on it
Definition cryptonote_core.cpp:1224
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
Definition cryptonote_core.cpp:1249
Definition miner.h:61
Definition cryptonote_basic.h:205
Transaction pool, handles transactions which are not part of a block.
Definition tx_pool.h:99
Definition syncobj.h:82
Definition math_helper.h:297
Non-owning sequence of data. Does not deep copy.
Definition span.h:55
@ HAVE_BLOCK_MAIN_CHAIN
Definition cryptonote_core.h:57
@ HAVE_BLOCK_INVALID
Definition cryptonote_core.h:57
@ HAVE_BLOCK_ALT_CHAIN
Definition cryptonote_core.h:57
#define false
const char * res
Definition hmac_keccak.cpp:42
static void init()
Definition logging.cpp:42
static int version
Definition mdb_load.c:29
Definition base.py:1
Definition blocks.cpp:13
Definition portable_binary_archive.hpp:29
crypto namespace.
Definition crypto.cpp:60
POD_CLASS hash
Definition hash.h:49
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition message_data_structs.h:107
Holds cryptonote related classes and helpers.
Definition blockchain_db.cpp:45
const command_line::arg_descriptor< bool > arg_sync_pruned_blocks
Definition cryptonote_core.cpp:128
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:41
network_type
Definition cryptonote_config.h:302
const command_line::arg_descriptor< bool > arg_regtest_on
Definition cryptonote_core.cpp:85
const command_line::arg_descriptor< bool > arg_offline
Definition cryptonote_core.cpp:115
relay_category
Definition blockchain_db.h:110
relay_method
Methods tracking how a tx was received and relayed.
Definition enums.h:37
const command_line::arg_descriptor< difficulty_type > arg_fixed_difficulty
Definition cryptonote_core.cpp:95
const command_line::arg_descriptor< bool, false > arg_testnet_on
Definition cryptonote_core.cpp:75
const command_line::arg_descriptor< std::string, false, true, 3 > arg_data_dir
Definition cryptonote_core.cpp:100
std::function< const epee::span< const unsigned char >(cryptonote::network_type network)> GetCheckpointsCallback
Callback routine that returns checkpoints data for specific network type.
Definition blockchain.h:93
const command_line::arg_descriptor< bool, false > arg_stagenet_on
Definition cryptonote_core.cpp:80
std::string blobdata
Definition blobdatatype.h:39
const command_line::arg_descriptor< size_t > arg_block_download_max_size
Definition cryptonote_core.cpp:123
Definition get_output_distribution.py:1
Definition enums.h:68
std::shared_ptr< download_thread_control > download_async_handle
Definition download.h:36
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition command_line.h:53
epee::misc_utils::struct_init< request_t > request
Definition core_rpc_server_commands_defs.h:539
epee::misc_utils::struct_init< response_t > response
Definition core_rpc_server_commands_defs.h:567
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:227
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:316
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:246
Definition cryptonote_basic.h:512
Definition verification_context.h:66
Definition cryptonote_basic.h:475
Definition connection_context.h:44
Definition cryptonote_protocol_handler_common.h:53
Definition i_core_events.h:38
Definition cryptonote_protocol_handler_common.h:42
Definition miner.h:48
Used to provide transaction info that skips the mempool to block handling code.
Definition tx_verification_utils.h:101
Definition cryptonote_core.h:61
const size_t long_term_block_weight_window
Definition cryptonote_core.h:63
const std::pair< uint8_t, uint64_t > * hard_forks
Definition cryptonote_core.h:62
Definition verification_context.h:41
Definition core_rpc_server_commands_defs.h:1681
struct hash_func hashes[]
randomx_vm * vm
Definition tests.cpp:20
cryptonote::transaction tx
Definition transaction.cpp:40
#define DISABLE_VS_WARNINGS(w)
Definition warnings.h:18
#define POP_WARNINGS
Definition warnings.h:17
#define PUSH_WARNINGS
Definition warnings.h:16