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 tx_blob_entry& tx_blob, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
130
147
161 bool handle_incoming_txs(const std::vector<tx_blob_entry>& tx_blobs, std::vector<tx_verification_context>& tvc, relay_method tx_relay, bool relayed)
162 {
163 tvc.resize(tx_blobs.size());
164 return handle_incoming_txs(epee::to_span(tx_blobs), epee::to_mut_span(tvc), tx_relay, relayed);
165 }
166
182 bool handle_incoming_block(const blobdata& block_blob, const block *b, block_verification_context& bvc, bool update_miner_blocktemplate = true);
183
189 bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
190
196 bool cleanup_handle_incoming_blocks(bool force_sync = false);
197
205 bool check_incoming_block_size(const blobdata& block_blob) const;
206
213
214 //-------------------- i_miner_handler -----------------------
215
228 virtual bool handle_block_found(block& b, block_verification_context &bvc) override;
229
235 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;
236 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);
237
243 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);
244
250
251
258
264 const miner& get_miner()const{return m_miner;}
265
274 static void init_options(boost::program_options::options_description& desc);
275
289 bool init(const boost::program_options::variables_map& vm, const test_options *test_options = NULL, const GetCheckpointsCallback& get_checkpoints = nullptr, bool allow_dns = true);
290
296 bool set_genesis_block(const block& b);
297
305 bool deinit();
306
310 void test_drop_download();
311
317 void test_drop_download_height(uint64_t height);
318
324 bool get_test_drop_download() const;
325
335
342
349 void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
350
356 bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks, std::vector<cryptonote::blobdata>& txs) const;
357
363 bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks) const;
364
370 bool get_blocks(uint64_t start_offset, size_t count, std::vector<block>& blocks) const;
371
377 template<class t_ids_container, class t_blocks_container, class t_missed_container>
378 bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) const
379 {
380 return m_blockchain_storage.get_blocks(block_ids, blocks, missed_bs);
381 }
382
388 crypto::hash get_block_id_by_height(uint64_t height) const;
389
395 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;
396
402 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;
403
409 bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
410
416 bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
417
423 bool get_alternative_blocks(std::vector<block>& blocks) const;
424
430 size_t get_alternative_blocks_count() const;
431
438
444 const checkpoints& get_checkpoints() const;
445
451 void set_checkpoints(checkpoints&& chk_pts);
452
458 void set_checkpoints_file_path(const std::string& path);
459
465 void set_enforce_dns_checkpoints(bool enforce_dns);
466
472 void set_txpool_listener(boost::function<void(std::vector<txpool_event>)> zmq_pub);
473
479 void disable_dns_checkpoints(bool disable = true) { m_disable_dns_checkpoints = disable; }
480
486 bool pool_has_tx(const crypto::hash &txid) const;
487
494 bool get_pool_transactions(std::vector<transaction>& txs, bool include_sensitive_txes = false) const;
495
502 bool get_txpool_backlog(std::vector<tx_backlog_entry>& backlog, bool include_sensitive_txes = false) const;
503
510 bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_sensitive_txes = false) const;
511
518 bool get_pool_transaction_stats(struct txpool_stats& stats, bool include_sensitive_txes = false) const;
519
525 bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx, relay_category tx_category) const;
526
533 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;
534
540 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;
541
548 size_t get_pool_transactions_count(bool include_sensitive_txes = false) const;
549
556
562 bool have_block_unlocked(const crypto::hash& id, int *where = NULL) const;
563 bool have_block(const crypto::hash& id, int *where = NULL) const;
564
570 bool get_short_chain_history(std::list<crypto::hash>& ids) const;
571
577 bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
578
584 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;
585
591 bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs) const;
592 bool get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes, std::vector<std::vector<uint64_t>>& indexs) const;
593
600
607
614
620 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;
621
627 void pause_mine();
628
634 void resume_mine();
635
642
649
655 std::string print_pool(bool short_format) const;
656
662 virtual bool is_synchronized() const final;
663
669 void on_synchronized();
670
676 void safesyncmode(const bool onoff);
677
683 void set_target_blockchain_height(uint64_t target_blockchain_height);
684
691
698
705
711 uint8_t get_hard_fork_version(uint64_t height) const;
712
719
724 std::time_t get_start_time() const;
725
736 bool update_checkpoints(const bool skip_dns = false);
737
744 void graceful_exit();
745
751 void stop();
752
758 bool is_key_image_spent(const crypto::key_image& key_im) const;
759
770 bool are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
771
780 bool are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
781
787 size_t get_block_sync_size(uint64_t height) const;
788
794 std::pair<boost::multiprecision::uint128_t, boost::multiprecision::uint128_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);
795
801 network_type get_nettype() const { return m_nettype; };
802
812
819
825 uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights);
826
832 uint64_t get_free_space() const;
833
839 bool offline() const { return m_offline; }
840
847
855 bool prune_blockchain(uint32_t pruning_seed = 0);
856
863
870
876 bool is_within_compiled_block_hash_area(uint64_t height) const;
877
881 bool has_block_weights(uint64_t height, uint64_t nblocks) const;
882
886 void flush_bad_txs_cache();
887
892
900 bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes);
901
902 private:
903
914 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);
915
931
938
946 bool load_state_data();
947
953 bool parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, const blobdata& blob) const;
954
965 bool check_tx_syntax(const transaction& tx) const;
966
983 bool check_tx_semantic(const transaction& tx, bool keeped_by_block) const;
984 void set_semantics_failed(const crypto::hash &tx_hash);
985
989 bool handle_incoming_tx_accumulated_batch(std::vector<tx_verification_batch_info> &tx_info, bool keeped_by_block);
990
999
1007 bool handle_command_line(const boost::program_options::variables_map& vm);
1008
1017
1026 bool check_tx_inputs_ring_members_diff(const transaction& tx, const uint8_t hf_version) const;
1027
1037
1044
1050 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;
1051
1057 bool check_updates();
1058
1064 bool check_disk_space();
1065
1071 bool check_block_rate();
1072
1079
1081
1083
1086
1088
1090
1091 //m_miner and m_miner_addres are probably temporary here
1093
1094 std::string m_config_folder;
1095
1097
1105
1106 std::atomic<bool> m_starter_message_showed;
1107
1109
1111
1112 std::atomic<bool> m_update_available;
1113
1117
1118 std::atomic_flag m_checkpoints_updating;
1120
1122
1124
1125 std::unordered_set<crypto::hash> bad_semantics_txes[2];
1127
1128 enum {
1134
1137 boost::mutex m_update_mutex;
1138
1141
1142 /* `boost::function` is used because the implementation never allocates if
1143 the callable object has a single `std::shared_ptr` or `std::weap_ptr`
1144 internally. Whereas, the libstdc++ `std::function` will allocate. */
1145
1146 std::shared_ptr<tools::Notify> m_block_rate_notify;
1147 boost::function<void(std::vector<txpool_event>)> m_zmq_pub;
1148 };
1149}
1150
cryptonote::block b
Definition: block.cpp:40
static uint64_t h
Definition: blockchain_stats.cpp:55
Definition: blockchain.h:100
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
Definition: blockchain.cpp:2151
A container for blockchain checkpoints.
Definition: checkpoints.h:53
handles core cryptonote functionality
Definition: cryptonote_core.h:87
epee::math_helper::once_a_time_seconds< 60 *60 *5, true > m_blockchain_pruning_interval
interval for incremental blockchain pruning
Definition: cryptonote_core.h:1103
enum cryptonote::core::@88 check_updates_level
size_t block_sync_size
Definition: cryptonote_core.h:1121
bool handle_incoming_tx_pre(const tx_blob_entry &tx_blob, tx_verification_context &tvc, cryptonote::transaction &tx, crypto::hash &tx_hash)
Definition: cryptonote_core.cpp:787
bool pool_has_tx(const crypto::hash &txid) const
checks if the pool has a transaction with the given hash
Definition: cryptonote_core.cpp:1753
bool handle_incoming_tx(const tx_blob_entry &tx_blob, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
handles an incoming transaction
Definition: cryptonote_core.cpp:1118
bool check_updates()
checks DNS versions
Definition: cryptonote_core.cpp:1851
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Definition: cryptonote_core.cpp:1609
bool update_blockchain_pruning()
incrementally prunes blockchain
Definition: cryptonote_core.cpp:2088
bool check_tx_inputs_keyimages_domain(const transaction &tx) const
verify that each input key image in a transaction is in the valid domain
Definition: cryptonote_core.cpp:1324
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:437
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:2130
bool m_offline
Definition: cryptonote_core.h:1140
tx_memory_pool m_mempool
transaction pool instance
Definition: cryptonote_core.h:1084
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:1446
bool handle_incoming_txs(epee::span< const tx_blob_entry > tx_blobs, epee::span< tx_verification_context > tvc, relay_method tx_relay, bool relayed)
handles a list of incoming transactions
Definition: cryptonote_core.cpp:1002
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:412
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:1773
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Definition: cryptonote_core.cpp:463
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:2108
void stop()
stops the daemon running
Definition: cryptonote_core.cpp:310
bool parse_tx_from_blob(transaction &tx, crypto::hash &tx_hash, const blobdata &blob) const
Definition: cryptonote_core.cpp:1720
epee::math_helper::once_a_time_seconds< 60 *60 *2, true > m_fork_moaner
interval for checking HardFork status
Definition: cryptonote_core.h:1099
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:1206
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:2135
void set_cryptonote_protocol(i_cryptonote_protocol *pprotocol)
set the pointer to the cryptonote protocol object to use
Definition: cryptonote_core.cpp:247
uint8_t get_hard_fork_version(uint64_t height) const
return the hard fork version for a given block height
Definition: cryptonote_core.cpp:1841
bool check_disk_space()
checks free disk space
Definition: cryptonote_core.cpp:1981
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition: cryptonote_core.cpp:325
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:1100
boost::function< void(std::vector< txpool_event >)> m_zmq_pub
Definition: cryptonote_core.h:1147
bool get_test_drop_download_height() const
gets whether or not to drop blocks
Definition: cryptonote_core.cpp:776
void pause_mine()
Definition: cryptonote_core.cpp:1520
std::shared_ptr< tools::Notify > m_block_rate_notify
Definition: cryptonote_core.h:1146
time_t m_last_json_checkpoints_update
time when json checkpoints were last updated
Definition: cryptonote_core.h:1116
bool handle_command_line(const boost::program_options::variables_map &vm)
act on a set of command line options given
Definition: cryptonote_core.cpp:361
bool update_miner_block_template()
Definition: cryptonote_core.cpp:1793
void flush_invalid_blocks()
flushes the invalid block cache
Definition: cryptonote_core.cpp:2078
const Blockchain & get_blockchain_storage() const
gets the Blockchain instance (const)
Definition: cryptonote_core.h:648
void graceful_exit()
tells the daemon to wind down operations and stop running
Definition: cryptonote_core.cpp:2145
void set_txpool_listener(boost::function< void(std::vector< txpool_event >)> zmq_pub)
set a listener for txes being added to the txpool
Definition: cryptonote_core.cpp:274
epee::math_helper::once_a_time_seconds< 90, false > m_block_rate_interval
interval for checking block rate
Definition: cryptonote_core.h:1102
void test_drop_download_height(uint64_t height)
sets to drop blocks downloaded below a certain height
Definition: cryptonote_core.cpp:766
bool get_short_chain_history(std::list< crypto::hash > &ids) const
gets the hashes for a subset of the blockchain
Definition: cryptonote_core.cpp:1768
void resume_mine()
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:1262
bool fluffy_blocks_enabled() const
get whether fluffy blocks are enabled
Definition: cryptonote_core.h:818
bool on_idle()
calls various idle routines
Definition: cryptonote_core.cpp:1799
uint64_t get_free_space() const
get free disk space on the blockchain partition
Definition: cryptonote_core.cpp:2113
uint32_t get_blockchain_pruning_seed() const
get the blockchain pruning seed
Definition: cryptonote_core.cpp:2120
network_type m_nettype
which network are we on?
Definition: cryptonote_core.h:1110
difficulty_type get_block_cumulative_difficulty(uint64_t height) const
Definition: cryptonote_core.cpp:1700
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:1736
bool is_update_available() const
check whether an update is known to be available or not
Definition: cryptonote_core.h:811
miner m_miner
miner instance
Definition: cryptonote_core.h:1092
Blockchain m_blockchain_storage
Blockchain instance.
Definition: cryptonote_core.h:1085
bool have_block(const crypto::hash &id, int *where=NULL) const
Definition: cryptonote_core.cpp:1715
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:1730
std::string m_config_folder
folder to look in for configs and other files
Definition: cryptonote_core.h:1094
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:1620
bool check_block_rate()
checks block rate, and warns if it's too slow
Definition: cryptonote_core.cpp:2024
uint64_t m_target_blockchain_height
blockchain height target
Definition: cryptonote_core.h:1108
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition: cryptonote_core.cpp:742
size_t get_blockchain_total_transactions() const
gets the total number of transactions on the main chain
Definition: cryptonote_core.cpp:1345
bool have_block_unlocked(const crypto::hash &id, int *where=NULL) const
Definition: cryptonote_core.cpp:1710
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition: cryptonote_core.cpp:1831
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition: cryptonote_core.cpp:1695
bool get_test_drop_download() const
gets whether or not to drop blocks (for testing)
Definition: cryptonote_core.cpp:771
bool m_disable_dns_checkpoints
Definition: cryptonote_core.h:1119
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition: cryptonote_core.cpp:1632
virtual uint64_t get_current_blockchain_height() const final
get the current height of the blockchain
Definition: cryptonote_core.cpp:407
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:1118
virtual bool is_synchronized() const final
gets the core synchronization status
Definition: cryptonote_core.cpp:1599
std::string m_checkpoints_path
path to json checkpoints file
Definition: cryptonote_core.h:1114
bool load_state_data()
load any core state stored on disk
Definition: cryptonote_core.cpp:747
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:1098
void set_checkpoints_file_path(const std::string &path)
set the file path to read from when loading checkpoints
Definition: cryptonote_core.cpp:264
bool check_tx_inputs_ring_members_diff(const transaction &tx, const uint8_t hf_version) const
verify that each ring uses distinct members
Definition: cryptonote_core.cpp:1309
bool check_blockchain_pruning()
checks the blockchain pruning if enabled
Definition: cryptonote_core.cpp:2093
void flush_bad_txs_cache()
flushes the bad txs cache
Definition: cryptonote_core.cpp:2070
size_t get_block_sync_size(uint64_t height) const
get the number of blocks to sync in one go
Definition: cryptonote_core.cpp:1221
bool offline() const
get whether the core is running offline
Definition: cryptonote_core.h:839
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:1413
bool deinit()
performs safe shutdown steps for core and core components
Definition: cryptonote_core.cpp:753
void set_semantics_failed(const crypto::hash &tx_hash)
Definition: cryptonote_core.cpp:863
network_type get_nettype() const
get the network type we're on
Definition: cryptonote_core.h:801
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:1475
const miner & get_miner() const
gets the miner instance (const)
Definition: cryptonote_core.h:264
bool check_tx_semantic(const transaction &tx, bool keeped_by_block) const
validates some simple properties of a transaction
Definition: cryptonote_core.cpp:1123
std::time_t get_start_time() const
gets start_time
Definition: cryptonote_core.cpp:2140
uint64_t m_test_drop_download_height
height under which to drop incoming blocks, if doing so
Definition: cryptonote_core.h:1082
bool handle_incoming_tx_post(const tx_blob_entry &tx_blob, tx_verification_context &tvc, cryptonote::transaction &tx, crypto::hash &tx_hash)
Definition: cryptonote_core.cpp:851
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition: cryptonote_core.cpp:259
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
Definition: cryptonote_core.cpp:1788
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:1705
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block
Definition: cryptonote_core.cpp:1644
std::atomic< bool > m_starter_message_showed
has the "daemon will sync now" message been shown?
Definition: cryptonote_core.h:1106
void set_target_blockchain_height(uint64_t target_blockchain_height)
sets the target blockchain height
Definition: cryptonote_core.cpp:2098
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:1500
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition: cryptonote_core.cpp:1778
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:1748
bool update_checkpoints(const bool skip_dns=false)
tells the Blockchain to update its checkpoints
Definition: cryptonote_core.cpp:281
i_cryptonote_protocol * get_protocol()
get the cryptonote protocol instance
Definition: cryptonote_core.h:212
uint64_t get_target_blockchain_height() const
gets the target blockchain height
Definition: cryptonote_core.cpp:2103
void on_synchronized()
Definition: cryptonote_core.cpp:1604
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Definition: cryptonote_core.cpp:458
bool recalculate_difficulties()
recalculate difficulties after the last difficulty checklpoint to circumvent the annoying 'difficulty...
Definition: cryptonote_core.cpp:2064
tools::download_async_handle m_update_download
Definition: cryptonote_core.h:1135
void set_enforce_dns_checkpoints(bool enforce_dns)
set whether or not we enforce DNS checkpoints
Definition: cryptonote_core.cpp:269
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:442
bool m_test_drop_download
whether or not to drop incoming blocks (for testing)
Definition: cryptonote_core.h:1080
bool check_incoming_block_size(const blobdata &block_blob) const
check the size of a block against the current maximum
Definition: cryptonote_core.cpp:1681
void disable_dns_checkpoints(bool disable=true)
set whether or not to enable or disable DNS checkpoints
Definition: cryptonote_core.h:479
epee::critical_section m_incoming_tx_lock
incoming transaction lock
Definition: cryptonote_core.h:1089
std::atomic< bool > m_update_available
Definition: cryptonote_core.h:1112
epee::math_helper::once_a_time_seconds< 60 *60 *24 *7, false > m_diff_recalc_interval
interval for recalculating difficulties
Definition: cryptonote_core.h:1104
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:1763
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:1742
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:1490
void test_drop_download()
sets to drop blocks downloaded (for testing)
Definition: cryptonote_core.cpp:761
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:417
bool handle_incoming_tx_accumulated_batch(std::vector< tx_verification_batch_info > &tx_info, bool keeped_by_block)
Definition: cryptonote_core.cpp:896
size_t m_last_update_length
Definition: cryptonote_core.h:1136
boost::mutex bad_semantics_txes_lock
Definition: cryptonote_core.h:1126
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:1758
bool get_txpool_complement(const std::vector< crypto::hash > &hashes, std::vector< cryptonote::blobdata > &txes)
returns the set of transactions in the txpool which are not in the argument
Definition: cryptonote_core.cpp:2083
std::unordered_set< crypto::hash > bad_semantics_txes[2]
Definition: cryptonote_core.h:1125
bool prune_blockchain(uint32_t pruning_seed=0)
prune the blockchain
Definition: cryptonote_core.cpp:2125
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:1846
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:1783
i_cryptonote_protocol * m_pprotocol
cryptonote protocol instance
Definition: cryptonote_core.h:1087
bool add_new_block(const block &b, block_verification_context &bvc)
adds a block to the blockchain
Definition: cryptonote_core.cpp:1614
cryptonote_protocol_stub m_protocol_stub
cryptonote protocol stub instance
Definition: cryptonote_core.h:1096
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:1211
bool check_tx_inputs_keyimages_diff(const transaction &tx) const
verify that each input key image in a transaction is unique
Definition: cryptonote_core.cpp:1297
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:1101
boost::mutex m_update_mutex
Definition: cryptonote_core.h:1137
bool handle_incoming_txs(const std::vector< tx_blob_entry > &tx_blobs, std::vector< tx_verification_context > &tvc, relay_method tx_relay, bool relayed)
handles a list of incoming transactions
Definition: cryptonote_core.h:161
bool get_txpool_backlog(std::vector< tx_backlog_entry > &backlog, bool include_sensitive_txes=false) const
Definition: cryptonote_core.cpp:447
Blockchain & get_blockchain_storage()
gets the Blockchain instance
Definition: cryptonote_core.h:641
time_t start_time
Definition: cryptonote_core.h:1123
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:1544
time_t m_last_dns_checkpoints_update
time when dns checkpoints were last updated
Definition: cryptonote_core.h:1115
@ UPDATES_NOTIFY
Definition: cryptonote_core.h:1130
@ UPDATES_UPDATE
Definition: cryptonote_core.h:1132
@ UPDATES_DOWNLOAD
Definition: cryptonote_core.h:1131
@ UPDATES_DISABLED
Definition: cryptonote_core.h:1129
const checkpoints & get_checkpoints() const
get a set of blockchain checkpoint hashes
Definition: cryptonote_core.cpp:255
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:1350
bool relay_txpool_transactions()
attempts to relay any transactions in the mempool which need it
Definition: cryptonote_core.cpp:1368
miner & get_miner()
gets the miner instance
Definition: cryptonote_core.h:257
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:1269
bool check_tx_syntax(const transaction &tx) const
check a transaction's syntax
Definition: cryptonote_core.cpp:1725
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:1485
bool m_fluffy_blocks_enabled
Definition: cryptonote_core.h:1139
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:1510
Definition: miner.h:61
Definition: cryptonote_basic.h:205
Transaction pool, handles transactions which are not part of a block.
Definition: tx_pool.h:98
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
int * count
Definition: gmock_stress_test.cc:176
const char * res
Definition: hmac_keccak.cpp:42
#define const
Definition: ipfrdr.c:80
relay_method tx_relay
Definition: levin_notify.cpp:545
static void init()
Definition: logging.cpp:38
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:48
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:127
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
Definition: cryptonote_core.cpp:101
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:41
network_type
Definition: cryptonote_config.h:289
const command_line::arg_descriptor< bool > arg_regtest_on
Definition: cryptonote_core.cpp:86
const command_line::arg_descriptor< bool > arg_offline
Definition: cryptonote_core.cpp:114
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:96
const command_line::arg_descriptor< bool, false > arg_testnet_on
Definition: cryptonote_core.cpp:76
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:91
const command_line::arg_descriptor< bool, false > arg_stagenet_on
Definition: cryptonote_core.cpp:81
std::string blobdata
Definition: blobdatatype.h:39
const command_line::arg_descriptor< size_t > arg_block_download_max_size
Definition: cryptonote_core.cpp:122
constexpr span< const typename T::value_type > to_span(const T &src)
Definition: span.h:122
constexpr span< typename T::value_type > to_mut_span(T &src)
Definition: span.h:130
Definition: get_output_distribution.py:1
Definition: enums.h:68
std::shared_ptr< download_thread_control > download_async_handle
Definition: download.h:36
#define false
Definition: stdbool.h:37
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
Definition: cryptonote_basic.h:512
Definition: verification_context.h:59
Definition: cryptonote_basic.h:475
Definition: cryptonote_core.h:988
const cryptonote::transaction * tx
Definition: cryptonote_core.h:988
tx_verification_context & tvc
Definition: cryptonote_core.h:988
crypto::hash tx_hash
Definition: cryptonote_core.h:988
bool & result
Definition: cryptonote_core.h:988
Definition: connection_context.h:43
Definition: cryptonote_protocol_handler_common.h:53
Definition: i_core_events.h:38
Definition: cryptonote_protocol_handler_common.h:42
Definition: miner.h:48
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: cryptonote_protocol_defs.h:122
Definition: core_rpc_server_commands_defs.h:1466
Definition: verification_context.h:41
Definition: core_rpc_server_commands_defs.h:1624
Definition: misc_language.h:104
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