Monero
blockchain.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2020, 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 #include <boost/asio/io_service.hpp>
33 #include <boost/function/function_fwd.hpp>
34 #if BOOST_VERSION >= 107400
35 #include <boost/serialization/library_version_type.hpp>
36 #endif
37 #include <boost/serialization/serialization.hpp>
38 #include <boost/serialization/version.hpp>
39 #include <boost/serialization/list.hpp>
40 #include <boost/multi_index_container.hpp>
41 #include <boost/multi_index/global_fun.hpp>
42 #include <boost/multi_index/hashed_index.hpp>
43 #include <boost/multi_index/member.hpp>
44 #include <atomic>
45 #include <functional>
46 #include <unordered_map>
47 #include <unordered_set>
48 
49 #include "span.h"
50 #include "syncobj.h"
51 #include "string_tools.h"
52 #include "rolling_median.h"
54 #include "common/util.h"
58 #include "cryptonote_tx_utils.h"
60 #include "crypto/hash.h"
64 
65 namespace tools { class Notify; }
66 
67 namespace cryptonote
68 {
69  class tx_memory_pool;
70  struct test_options;
71 
76  {
80  db_nosync
81  };
82 
90  typedef std::function<const epee::span<const unsigned char>(cryptonote::network_type network)> GetCheckpointsCallback;
91 
92  /************************************************************************/
93  /* */
94  /************************************************************************/
95  class Blockchain
96  {
97  public:
102  {
104  uint64_t height;
108  };
109 
115  Blockchain(tx_memory_pool& tx_pool);
116 
120  ~Blockchain();
121 
134  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);
135 
146  bool init(BlockchainDB* db, HardFork*& hf, const network_type nettype = MAINNET, bool offline = false);
147 
155  bool deinit();
156 
162  void set_checkpoints(checkpoints&& chk_pts) { m_checkpoints = chk_pts; }
163 
174  bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks, std::vector<cryptonote::blobdata>& txs) const;
175 
185  bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks) const;
186 
194  bool get_alternative_blocks(std::vector<block>& blocks) const;
195 
201  size_t get_alternative_blocks_count() const;
202 
210  crypto::hash get_block_id_by_height(uint64_t height) const;
211 
222  crypto::hash get_pending_block_id_by_height(uint64_t height) const;
223 
233  bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
234 
243  bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
244 
252  bool cleanup_handle_incoming_blocks(bool force_sync = false);
253 
261  bool have_tx(const crypto::hash &id) const;
262 
270  bool have_tx_keyimges_as_spent(const transaction &tx) const;
271 
284  bool have_tx_keyimg_as_spent(const crypto::key_image &key_im) const;
285 
291  uint64_t get_current_blockchain_height() const;
292 
298  crypto::hash get_tail_id() const;
299 
307  crypto::hash get_tail_id(uint64_t& height) const;
308 
315 
321  std::pair<bool, uint64_t> check_difficulty_checkpoints() const;
322 
330  size_t recalculate_difficulties(boost::optional<uint64_t> start_height = boost::none);
331 
345  bool add_new_block(const block& bl_, block_verification_context& bvc);
346 
354  bool reset_and_set_genesis_block(const block& b);
355 
369  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, uint64_t &seed_height, crypto::hash &seed_hash);
370  bool create_block_template(block& b, const crypto::hash *from_block, const account_public_address& miner_address, difficulty_type& di, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash);
371 
382  bool have_block(const crypto::hash& id) const;
383 
389  size_t get_total_transactions() const;
390 
405  bool get_short_chain_history(std::list<crypto::hash>& ids) const;
406 
423  bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, std::vector<crypto::hash>& hashes, std::vector<uint64_t>* weights, uint64_t& start_height, uint64_t& current_height, bool clip_pruned) const;
424 
438  bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
439 
452  bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, uint64_t& starter_offset) const;
453 
471  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;
472 
486 
494  uint64_t get_num_mature_outputs(uint64_t amount) const;
495 
504  crypto::public_key get_output_key(uint64_t amount, uint64_t global_index) const;
505 
520 
530  void get_output_key_mask_unlocked(const uint64_t& amount, const uint64_t& index, crypto::public_key& key, rct::key& mask, bool& unlocked) const;
531 
542  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;
543 
556  bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs) const;
557  bool get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes, std::vector<std::vector<uint64_t>>& indexs) const;
558 
567  bool store_blockchain();
568 
585  bool check_tx_inputs(transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id, tx_verification_context &tvc, bool kept_by_block = false) const;
586 
594  static uint64_t get_fee_quantization_mask();
595 
609  static uint64_t get_dynamic_base_fee(uint64_t block_reward, size_t median_block_weight, uint8_t version);
610 
624  uint64_t get_dynamic_base_fee_estimate(uint64_t grace_blocks) const;
625 
638  bool check_fee(size_t tx_weight, uint64_t fee) const;
639 
652  bool check_tx_outputs(const transaction& tx, tx_verification_context &tvc) const;
653 
660 
666  uint64_t get_next_long_term_block_weight(uint64_t block_weight) const;
667 
674 
682  difficulty_type block_difficulty(uint64_t i) const;
683 
696  template<class t_ids_container, class t_blocks_container, class t_missed_container>
697  bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) const;
698 
712  bool get_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
713  bool get_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<tx_blob_entry>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
714  template<class t_ids_container, class t_tx_container, class t_missed_container>
715  bool get_split_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
716  template<class t_ids_container, class t_tx_container, class t_missed_container>
717  bool get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
718 
719  //debug functions
720 
732  void check_against_checkpoints(const checkpoints& points, bool enforce);
733 
739  void set_enforce_dns_checkpoints(bool enforce);
740 
749  bool update_checkpoints(const std::string& file_path, bool check_dns);
750 
751 
752  // user options, must be called before calling init()
753 
763  void set_user_options(uint64_t maxthreads, bool sync_on_blocks, uint64_t sync_threshold,
764  blockchain_db_sync_mode sync_mode, bool fast_sync);
765 
771  void add_block_notify(boost::function<void(std::uint64_t, epee::span<const block>)> &&notify);
772 
778  void set_reorg_notify(const std::shared_ptr<tools::Notify> &notify) { m_reorg_notify = notify; }
779 
783  void safesyncmode(const bool onoff);
784 
790  void set_show_time_stats(bool stats) { m_show_time_stats = stats; }
791 
798 
805 
812 
819 
828  uint8_t get_ideal_hard_fork_version(uint64_t height) const { return m_hardfork->get_ideal_version(height); }
829 
837  uint8_t get_hard_fork_version(uint64_t height) const { return m_hardfork->get(height); }
838 
845 
858  bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const;
859 
865  uint64_t get_difficulty_target() const;
866 
874  bool flush_txes_from_pool(const std::vector<crypto::hash> &txids);
875 
886  std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked, uint64_t recent_cutoff, uint64_t min_count = 0) const;
887 
895  bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
896 
906  bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function<bool(uint64_t, const crypto::hash&, const block&)>) const;
907 
916  bool for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)>, bool pruned) const;
917 
925  bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)>) const;
926 
935  bool for_all_outputs(uint64_t amount, std::function<bool(uint64_t height)>) const;
936 
942  const BlockchainDB& get_db() const
943  {
944  return *m_db;
945  }
946 
953  {
954  return *m_db;
955  }
956 
964  void output_scan_worker(const uint64_t amount,const std::vector<uint64_t> &offsets,
965  std::vector<output_data_t> &outputs) const;
966 
974  void block_longhash_worker(uint64_t height, const epee::span<const block> &blocks,
975  std::unordered_map<crypto::hash, crypto::hash> &map) const;
976 
982  std::vector<std::pair<block_extended_info,std::vector<crypto::hash>>> get_alternative_chains() const;
983 
984  void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t &meta);
985  void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta);
986  void remove_txpool_tx(const crypto::hash &txid);
987  uint64_t get_txpool_tx_count(bool include_sensitive = false) const;
988  bool get_txpool_tx_meta(const crypto::hash& txid, txpool_tx_meta_t &meta) const;
989  bool get_txpool_tx_blob(const crypto::hash& txid, cryptonote::blobdata &bd, relay_category tx_category) const;
990  cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid, relay_category tx_category) const;
991  bool for_all_txpool_txes(std::function<bool(const crypto::hash&, const txpool_tx_meta_t&, const cryptonote::blobdata_ref*)>, bool include_blob = false, relay_category tx_category = relay_category::broadcasted) const;
992  bool txpool_tx_matches_category(const crypto::hash& tx_hash, relay_category category);
993 
995  uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights);
997  bool prune_blockchain(uint32_t pruning_seed = 0);
1000 
1001  void lock();
1002  void unlock();
1003 
1004  void cancel();
1005 
1012 
1016  std::vector<time_t> get_last_block_timestamps(unsigned int blocks) const;
1017 
1023  void pop_blocks(uint64_t nblocks);
1024 
1030  bool is_within_compiled_block_hash_area(uint64_t height) const;
1031 
1038  bool has_block_weights(uint64_t height, uint64_t nblocks) const;
1039 
1043  void flush_invalid_blocks();
1044 
1058  uint64_t get_adjusted_time(uint64_t height) const;
1059 
1060 #ifndef IN_UNIT_TESTS
1061  private:
1062 #endif
1063 
1064  // TODO: evaluate whether or not each of these typedefs are left over from blockchain_storage
1065  typedef std::unordered_set<crypto::key_image> key_images_container;
1066 
1067  typedef std::vector<block_extended_info> blocks_container;
1068 
1069  typedef std::unordered_map<crypto::hash, block_extended_info> blocks_ext_by_hash;
1070 
1071 
1073 
1075 
1076  mutable epee::critical_section m_blockchain_lock; // TODO: add here reader/writer lock
1077 
1078  // main chain
1081 
1082  // metadata containers
1083  std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, std::vector<output_data_t>>> m_scan_table;
1084  std::unordered_map<crypto::hash, crypto::hash> m_blocks_longhash_table;
1085 
1086  // Keccak hashes for each block and for fast pow checking
1087  std::vector<std::pair<crypto::hash, crypto::hash>> m_blocks_hash_of_hashes;
1088  std::vector<std::pair<crypto::hash, uint64_t>> m_blocks_hash_check;
1089  std::vector<crypto::hash> m_blocks_txs_check;
1090 
1100  uint64_t m_sync_counter;
1102  std::vector<uint64_t> m_timestamps;
1103  std::vector<difficulty_type> m_difficulties;
1109  mutable epee::misc_utils::rolling_median_t<uint64_t> m_long_term_block_weights_cache_rolling_median;
1110 
1111  epee::critical_section m_difficulty_lock;
1114 
1115  boost::asio::io_service m_async_service;
1116  boost::thread_group m_async_pool;
1117  std::unique_ptr<boost::asio::io_service::work> m_async_work_idle;
1118 
1119  // some invalid blocks
1120  blocks_ext_by_hash m_invalid_blocks; // crypto::hash -> block_extended_info
1121 
1122 
1125 
1127 
1131 
1132  std::atomic<bool> m_cancel;
1133 
1134  // block template cache
1139  uint64_t m_btc_height;
1145 
1146 
1148 
1149  /* `boost::function` is used because the implementation never allocates if
1150  the callable object has a single `std::shared_ptr` or `std::weap_ptr`
1151  internally. Whereas, the libstdc++ `std::function` will allocate. */
1152 
1153  std::vector<boost::function<void(std::uint64_t, epee::span<const block>)>> m_block_notifiers;
1154  std::shared_ptr<tools::Notify> m_reorg_notify;
1155 
1156  // for prepare_handle_incoming_blocks
1159  std::vector<block> *m_prepare_blocks;
1160 
1180  template<class visitor_t>
1181  inline bool scan_outputkeys_for_indexes(size_t tx_version, const txin_to_key& tx_in_to_key, visitor_t &vis, const crypto::hash &tx_prefix_hash, uint64_t* pmax_related_block_height = NULL) const;
1182 
1204  bool check_tx_input(size_t tx_version,const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const rct::rctSig &rct_signatures, std::vector<rct::ctkey> &output_keys, uint64_t* pmax_related_block_height, uint8_t hf_version) const;
1205 
1226  bool check_tx_inputs(transaction& tx, tx_verification_context &tvc, uint64_t* pmax_used_block_height = NULL) const;
1227 
1240  bool switch_to_alternative_blockchain(std::list<block_extended_info>& alt_chain, bool discard_disconnected_chain);
1241 
1248 
1262  bool handle_block_to_main_chain(const block& bl, block_verification_context& bvc, bool notify = true);
1263 
1278  bool handle_block_to_main_chain(const block& bl, const crypto::hash& id, block_verification_context& bvc, bool notify = true);
1279 
1294 
1305  bool build_alt_chain(const crypto::hash &prev_id, std::list<block_extended_info>& alt_chain, std::vector<uint64_t> &timestamps, block_verification_context& bvc) const;
1306 
1315  difficulty_type get_next_difficulty_for_alternative_chain(const std::list<block_extended_info>& alt_chain, block_extended_info& bei) const;
1316 
1329  bool prevalidate_miner_transaction(const block& b, uint64_t height, uint8_t hf_version);
1330 
1347  bool validate_miner_transaction(const block& b, size_t cumulative_block_weight, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, bool &partial_block_reward, uint8_t version);
1348 
1361  bool rollback_blockchain_switching(std::list<block>& original_chain, uint64_t rollback_height);
1362 
1371  void get_last_n_blocks_weights(std::vector<uint64_t>& weights, size_t count) const;
1372 
1383  uint64_t get_long_term_block_weight_median(uint64_t start_height, size_t count) const;
1384 
1396  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint8_t hf_version) const;
1397 
1409  bool add_block_as_invalid(const block& bl, const crypto::hash& h);
1410 
1422  bool add_block_as_invalid(const block_extended_info& bei, const crypto::hash& h);
1423 
1440  bool check_block_timestamp(const block& b, uint64_t& median_ts) const;
1441  bool check_block_timestamp(const block& b) const { uint64_t median_ts; return check_block_timestamp(b, median_ts); }
1442 
1454  bool check_block_timestamp(std::vector<uint64_t>& timestamps, const block& b, uint64_t& median_ts) const;
1455  bool check_block_timestamp(std::vector<uint64_t>& timestamps, const block& b) const { uint64_t median_ts; return check_block_timestamp(timestamps, b, median_ts); }
1456 
1468  bool complete_timestamps_vector(uint64_t start_height, std::vector<uint64_t>& timestamps) const;
1469 
1477  bool update_next_cumulative_weight_limit(uint64_t *long_term_effective_median_block_weight = NULL);
1478  void return_tx_to_pool(std::vector<std::pair<transaction, blobdata>> &txs);
1479 
1488  bool check_for_double_spend(const transaction& tx, key_images_container& keys_this_block) const;
1489 
1499  void check_ring_signature(const crypto::hash &tx_prefix_hash, const crypto::key_image &key_image,
1500  const std::vector<rct::ctkey> &pubkeys, const std::vector<crypto::signature> &sig, uint64_t &result) const;
1501 
1512 
1520  bool expand_transaction_2(transaction &tx, const crypto::hash &tx_prefix_hash, const std::vector<std::vector<rct::ctkey>> &pubkeys) const;
1521 
1526 
1532  void cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t height, uint64_t expected_reward, uint64_t seed_height, const crypto::hash &seed_hash, uint64_t pool_cookie);
1533  };
1534 } // namespace cryptonote
cryptonote::Blockchain::get_txpool_tx_meta
bool get_txpool_tx_meta(const crypto::hash &txid, txpool_tx_meta_t &meta) const
Definition: blockchain.cpp:5236
cryptonote::Blockchain::cancel
void cancel()
Definition: blockchain.cpp:5373
cryptonote::Blockchain::m_hardfork
HardFork * m_hardfork
Definition: blockchain.h:1126
cryptonote::MAINNET
@ MAINNET
Definition: cryptonote_config.h:269
cryptonote::Blockchain::check_difficulty_checkpoints
std::pair< bool, uint64_t > check_difficulty_checkpoints() const
check currently stored difficulties against difficulty checkpoints
Definition: blockchain.cpp:973
cryptonote::Blockchain::m_fast_sync
bool m_fast_sync
Definition: blockchain.h:1092
cryptonote::Blockchain::get_hard_fork_voting_info
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint64_t &earliest_height, uint8_t &voting) const
get information about hardfork voting for a version
Definition: blockchain.cpp:5301
cryptonote::Blockchain::get_alternative_blocks_count
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Definition: blockchain.cpp:2211
cryptonote::Blockchain::m_long_term_block_weights_cache_rolling_median
epee::misc_utils::rolling_median_t< uint64_t > m_long_term_block_weights_cache_rolling_median
Definition: blockchain.h:1109
cryptonote::Blockchain
Definition: blockchain.h:96
cryptonote::Blockchain::m_checkpoints
checkpoints m_checkpoints
Definition: blockchain.h:1123
cryptonote::Blockchain::prepare_handle_incoming_blocks
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: blockchain.cpp:4870
cryptonote::Blockchain::create_block_template
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, uint64_t &seed_height, crypto::hash &seed_hash)
creates a new block to mine against
Definition: blockchain.cpp:1778
cryptonote::Blockchain::for_all_txpool_txes
bool for_all_txpool_txes(std::function< bool(const crypto::hash &, const txpool_tx_meta_t &, const cryptonote::blobdata_ref *)>, bool include_blob=false, relay_category tx_category=relay_category::broadcasted) const
Definition: blockchain.cpp:5251
cryptonote::Blockchain::recalculate_difficulties
size_t recalculate_difficulties(boost::optional< uint64_t > start_height=boost::none)
recalculate difficulties for blocks after the last difficulty checkpoints to circumvent the annoying ...
Definition: blockchain.cpp:987
cryptonote::Blockchain::get_block_id_by_height
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition: blockchain.cpp:744
cryptonote_basic.h
cryptonote::Blockchain::update_next_cumulative_weight_limit
bool update_next_cumulative_weight_limit(uint64_t *long_term_effective_median_block_weight=NULL)
calculate the block weight limit for the next block to be added
Definition: blockchain.cpp:4423
cryptonote::Blockchain::output_scan_worker
void output_scan_worker(const uint64_t amount, const std::vector< uint64_t > &offsets, std::vector< output_data_t > &outputs) const
get a number of outputs of a specific amount
Definition: blockchain.cpp:4717
cryptonote::Blockchain::set_checkpoints
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition: blockchain.h:162
cryptonote::Blockchain::m_enforce_dns_checkpoints
bool m_enforce_dns_checkpoints
Definition: blockchain.h:1124
cryptonote::Blockchain::handle_get_objects
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
Definition: blockchain.cpp:2140
cryptonote::Blockchain::safesyncmode
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Definition: blockchain.cpp:5284
cryptonote::Blockchain::get_earliest_ideal_height_for_version
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
returns the earliest block a given version may activate
Definition: blockchain.h:844
cryptonote::Blockchain::pop_block_from_blockchain
block pop_block_from_blockchain()
removes the most recent block from the blockchain
Definition: blockchain.cpp:575
cryptonote::Blockchain::m_prepare_height
uint64_t m_prepare_height
Definition: blockchain.h:1157
cryptonote::Blockchain::deinit
bool deinit()
Uninitializes the blockchain state.
Definition: blockchain.cpp:501
cryptonote::db_async
@ db_async
handle syncing calls instead of the backing db, asynchronously
Definition: blockchain.h:79
cryptonote::Blockchain::complete_timestamps_vector
bool complete_timestamps_vector(uint64_t start_height, std::vector< uint64_t > &timestamps) const
finish an alternate chain's timestamp window from the main chain
Definition: blockchain.cpp:1785
cryptonote::Blockchain::get_current_cumulative_block_weight_limit
uint64_t get_current_cumulative_block_weight_limit() const
gets the block weight limit based on recent blocks
Definition: blockchain.cpp:1486
cryptonote::Blockchain::key_images_container
std::unordered_set< crypto::key_image > key_images_container
Definition: blockchain.h:1065
base
Definition: base.py:1
cryptonote::Blockchain::blocks_container
std::vector< block_extended_info > blocks_container
Definition: blockchain.h:1067
cryptonote::Blockchain::have_tx_keyimg_as_spent
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:121
cryptonote::Blockchain::check_block_timestamp
bool check_block_timestamp(std::vector< uint64_t > &timestamps, const block &b) const
Definition: blockchain.h:1455
cryptonote::checkpoints
A container for blockchain checkpoints.
Definition: checkpoints.h:53
cryptonote::Blockchain::on_new_tx_from_block
void on_new_tx_from_block(const cryptonote::transaction &tx)
called when we see a tx originating from a block
Definition: blockchain.cpp:2902
rct::key
Definition: rctTypes.h:79
cryptonote::Blockchain::Blockchain
Blockchain(tx_memory_pool &tx_pool)
Blockchain constructor.
Definition: blockchain.cpp:89
cryptonote::Blockchain::m_tx_pool
tx_memory_pool & m_tx_pool
Definition: blockchain.h:1074
cryptonote::Blockchain::m_btc_seed_height
uint64_t m_btc_seed_height
Definition: blockchain.h:1143
cryptonote::Blockchain::validate_miner_transaction
bool validate_miner_transaction(const block &b, size_t cumulative_block_weight, uint64_t fee, uint64_t &base_reward, uint64_t already_generated_coins, bool &partial_block_reward, uint8_t version)
validates a miner (coinbase) transaction
Definition: blockchain.cpp:1361
verification_context.h
cryptonote::Blockchain::check_against_checkpoints
void check_against_checkpoints(const checkpoints &points, bool enforce)
check the blockchain against a set of checkpoints
Definition: blockchain.cpp:4541
cryptonote::Blockchain::add_block_as_invalid
bool add_block_as_invalid(const block &bl, const crypto::hash &h)
stores an invalid block in a separate container
Definition: blockchain.cpp:2736
cryptonote::NOTIFY_REQUEST_GET_OBJECTS::request
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:227
cryptonote::Blockchain::get_block_by_hash
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:778
cryptonote::Blockchain::reset_and_set_genesis_block
bool reset_and_set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition: blockchain.cpp:654
cryptonote::Blockchain::get_transactions_blobs
bool get_transactions_blobs(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs, bool pruned=false) const
gets transactions based on a list of transaction hashes
Definition: blockchain.cpp:2517
cryptonote::blockchain_db_sync_mode
blockchain_db_sync_mode
Definition: blockchain.h:76
cryptonote::Blockchain::rollback_blockchain_switching
bool rollback_blockchain_switching(std::list< block > &original_chain, uint64_t rollback_height)
reverts the blockchain to its previous state following a failed switch
Definition: blockchain.cpp:1093
cryptonote::Blockchain::block_extended_info::bl
block bl
the block
Definition: blockchain.h:103
cryptonote::db_sync
@ db_sync
handle syncing calls instead of the backing db, synchronously
Definition: blockchain.h:78
cryptonote::Blockchain::prune_blockchain
bool prune_blockchain(uint32_t pruning_seed=0)
Definition: blockchain.cpp:4376
cryptonote::Blockchain::block_difficulty
difficulty_type block_difficulty(uint64_t i) const
gets the difficulty of the block with a given height
Definition: blockchain.cpp:2408
cryptonote::Blockchain::get_difficulty_target
uint64_t get_difficulty_target() const
get difficulty target based on chain and hardfork version
Definition: blockchain.cpp:5306
cryptonote::Blockchain::get_split_transactions_blobs
bool get_split_transactions_blobs(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Definition: blockchain.cpp:2577
cryptonote::network_type
network_type
Definition: cryptonote_config.h:268
cryptonote::Blockchain::get_db
BlockchainDB & get_db()
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:952
cryptonote::BlockchainDB
The BlockchainDB backing store interface declaration/contract.
Definition: blockchain_db.h:379
cryptonote::difficulty_type
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:41
cryptonote::Blockchain::get_total_transactions
size_t get_total_transactions() const
gets the total number of transactions on the main chain
Definition: blockchain.cpp:2794
cryptonote::block_verification_context
Definition: verification_context.h:59
cryptonote::Blockchain::m_reorg_notify
std::shared_ptr< tools::Notify > m_reorg_notify
Definition: blockchain.h:1154
cryptonote::Blockchain::get_fee_quantization_mask
static uint64_t get_fee_quantization_mask()
get fee quantization mask
Definition: blockchain.cpp:3632
cryptonote::Blockchain::check_block_timestamp
bool check_block_timestamp(const block &b, uint64_t &median_ts) const
checks a block's timestamp
Definition: blockchain.cpp:3914
cryptonote::Blockchain::m_long_term_block_weights_cache_tip_hash
crypto::hash m_long_term_block_weights_cache_tip_hash
Definition: blockchain.h:1108
cryptonote::Blockchain::m_nettype
network_type m_nettype
Definition: blockchain.h:1128
cryptonote::Blockchain::get_output_key
crypto::public_key get_output_key(uint64_t amount, uint64_t global_index) const
get the public key for an output
Definition: blockchain.cpp:2238
hardfork.h
cryptonote::Blockchain::have_tx
bool have_tx(const crypto::hash &id) const
search the blockchain for a transaction by hash
Definition: blockchain.cpp:111
cryptonote::Blockchain::is_within_compiled_block_hash_area
bool is_within_compiled_block_hash_area() const
Definition: blockchain.h:994
cryptonote::Blockchain::m_current_block_cumul_weight_limit
size_t m_current_block_cumul_weight_limit
Definition: blockchain.h:1079
cryptonote::Blockchain::get_hard_fork_version
uint8_t get_hard_fork_version(uint64_t height) const
returns the actual hardfork version for a given block height
Definition: blockchain.h:837
cryptonote::Blockchain::m_offline
bool m_offline
Definition: blockchain.h:1129
cryptonote::blobdata_ref
boost::string_ref blobdata_ref
Definition: blobdatatype.h:40
cryptonote::Blockchain::get_current_cumulative_block_weight_median
uint64_t get_current_cumulative_block_weight_median() const
gets the block weight median based on recent blocks (same window as for the limit)
Definition: blockchain.cpp:1492
cryptonote::Blockchain::get_output_key_mask_unlocked
void get_output_key_mask_unlocked(const uint64_t &amount, const uint64_t &index, crypto::public_key &key, rct::key &mask, bool &unlocked) const
gets an output's key and unlocked state
Definition: blockchain.cpp:2290
cryptonote::Blockchain::flush_txes_from_pool
bool flush_txes_from_pool(const std::vector< crypto::hash > &txids)
remove transactions from the transaction pool (if present)
Definition: blockchain.cpp:3964
cryptonote::GetCheckpointsCallback
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:90
cryptonote::relay_category
relay_category
Definition: blockchain_db.h:110
cryptonote::Blockchain::m_blocks_txs_check
std::vector< crypto::hash > m_blocks_txs_check
Definition: blockchain.h:1089
cryptonote::Blockchain::m_btc
block m_btc
Definition: blockchain.h:1135
cryptonote::Blockchain::check_blockchain_pruning
bool check_blockchain_pruning()
Definition: blockchain.cpp:4394
cryptonote::Blockchain::cleanup_handle_incoming_blocks
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition: blockchain.cpp:4639
cryptonote::Blockchain::load_compiled_in_block_hashes
void load_compiled_in_block_hashes(const GetCheckpointsCallback &get_checkpoints)
loads block hashes from compiled-in data set
cryptonote::Blockchain::cache_block_template
void cache_block_template(const block &b, const cryptonote::account_public_address &address, const blobdata &nonce, const difficulty_type &diff, uint64_t height, uint64_t expected_reward, uint64_t seed_height, const crypto::hash &seed_hash, uint64_t pool_cookie)
stores a new cached block template
Definition: blockchain.cpp:5521
cryptonote::db_defaultsync
@ db_defaultsync
user didn't specify, use db_async
Definition: blockchain.h:77
cryptonote::Blockchain::lock
void lock()
Definition: blockchain.cpp:5480
cryptonote::Blockchain::get_short_chain_history
bool get_short_chain_history(std::list< crypto::hash > &ids) const
gets the hashes for a subset of the blockchain
Definition: blockchain.cpp:702
cryptonote::Blockchain::m_btc_valid
bool m_btc_valid
Definition: blockchain.h:1144
cryptonote::Blockchain::m_long_term_effective_median_block_weight
uint64_t m_long_term_effective_median_block_weight
Definition: blockchain.h:1107
cryptonote::Blockchain::have_block
bool have_block(const crypto::hash &id) const
checks if a block is known about with a given hash
Definition: blockchain.cpp:2761
cryptonote::Blockchain::init
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)
Initialize the Blockchain state.
Definition: blockchain.cpp:278
cryptonote::HardFork::get_ideal_version
uint8_t get_ideal_version() const
returns the latest "ideal" version
Definition: hardfork.cpp:366
cryptonote::HardFork::State
State
Definition: hardfork.h:42
cryptonote::Blockchain::have_tx_keyimges_as_spent
bool have_tx_keyimges_as_spent(const transaction &tx) const
check if any key image in a transaction has already been spent
Definition: blockchain.cpp:3093
cryptonote::Blockchain::scan_outputkeys_for_indexes
bool scan_outputkeys_for_indexes(size_t tx_version, const txin_to_key &tx_in_to_key, visitor_t &vis, const crypto::hash &tx_prefix_hash, uint64_t *pmax_related_block_height=NULL) const
collects the keys for all outputs being "spent" as an input
Definition: blockchain.cpp:135
cryptonote::Blockchain::m_btc_address
account_public_address m_btc_address
Definition: blockchain.h:1136
cryptonote::Blockchain::m_db_sync_on_blocks
bool m_db_sync_on_blocks
Definition: blockchain.h:1095
cryptonote::Blockchain::for_blocks_range
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
Definition: blockchain.cpp:5495
base.b
int b
Definition: base.py:1
cryptonote_protocol_defs.h
cryptonote::db_nosync
@ db_nosync
Leave syncing up to the backing db (safest, but slowest because of disk I/O)
Definition: blockchain.h:80
lmdb::stream::count
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
cryptonote::Blockchain::get_adjusted_time
uint64_t get_adjusted_time(uint64_t height) const
get the "adjusted time"
Definition: blockchain.cpp:3859
cryptonote::Blockchain::get_tail_id
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition: blockchain.cpp:680
cryptonote::Blockchain::get_difficulty_for_next_block
difficulty_type get_difficulty_for_next_block()
returns the difficulty target the next block to be added must meet
Definition: blockchain.cpp:826
cryptonote::Blockchain::get_transactions
bool get_transactions(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Definition: blockchain.cpp:2611
cryptonote::Blockchain::expand_transaction_2
bool expand_transaction_2(transaction &tx, const crypto::hash &tx_prefix_hash, const std::vector< std::vector< rct::ctkey >> &pubkeys) const
expands v2 transaction data from blockchain
Definition: blockchain.cpp:3104
cryptonote::Blockchain::m_max_prepare_blocks_threads
uint64_t m_max_prepare_blocks_threads
Definition: blockchain.h:1097
cryptonote::Blockchain::check_tx_inputs
bool check_tx_inputs(transaction &tx, uint64_t &pmax_used_block_height, crypto::hash &max_used_block_id, tx_verification_context &tvc, bool kept_by_block=false) const
validates a transaction's inputs
Definition: blockchain.cpp:2928
cryptonote::Blockchain::handle_block_to_main_chain
bool handle_block_to_main_chain(const block &bl, block_verification_context &bvc, bool notify=true)
validate and add a new block to the end of the blockchain
Definition: blockchain.cpp:2787
cryptonote::Blockchain::get_hard_fork_state
HardFork::State get_hard_fork_state() const
gets the hardfork voting state object
Definition: blockchain.cpp:5296
cryptonote::COMMAND_RPC_GET_OUTPUTS_BIN::request
epee::misc_utils::struct_init< request_t > request
Definition: core_rpc_server_commands_defs.h:487
cryptonote::Blockchain::m_sync_counter
uint64_t m_sync_counter
Definition: blockchain.h:1100
cryptonote::Blockchain::get_txpool_tx_count
uint64_t get_txpool_tx_count(bool include_sensitive=false) const
Definition: blockchain.cpp:5231
cryptonote::Blockchain::return_tx_to_pool
void return_tx_to_pool(std::vector< std::pair< transaction, blobdata >> &txs)
Definition: blockchain.cpp:3944
cryptonote::Blockchain::m_difficulty_for_next_block_top_hash
crypto::hash m_difficulty_for_next_block_top_hash
Definition: blockchain.h:1112
blocks
Definition: blocks.cpp:13
cryptonote::Blockchain::flush_invalid_blocks
void flush_invalid_blocks()
flush the invalid blocks set
Definition: blockchain.cpp:2754
cryptonote_tx_utils.h
cryptonote::Blockchain::get_alternative_blocks
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Definition: blockchain.cpp:2189
cryptonote::Blockchain::block_longhash_worker
void block_longhash_worker(uint64_t height, const epee::span< const block > &blocks, std::unordered_map< crypto::hash, crypto::hash > &map) const
computes the "short" and "long" hashes for a set of blocks
Definition: blockchain.cpp:4620
cryptonote::Blockchain::m_fake_pow_calc_time
uint64_t m_fake_pow_calc_time
Definition: blockchain.h:1098
cryptonote::tx_verification_context
Definition: verification_context.h:41
cryptonote::Blockchain::get_ideal_hard_fork_version
uint8_t get_ideal_hard_fork_version(uint64_t height) const
returns the newest hardfork version voted to be enabled as of a certain height
Definition: blockchain.h:828
cryptonote::Blockchain::update_checkpoints
bool update_checkpoints(const std::string &file_path, bool check_dns)
loads new checkpoints from a file and optionally from DNS
Definition: blockchain.cpp:4579
cryptonote::Blockchain::m_scan_table
std::unordered_map< crypto::hash, std::unordered_map< crypto::key_image, std::vector< output_data_t > > > m_scan_table
Definition: blockchain.h:1083
cryptonote::block
Definition: cryptonote_basic.h:464
cryptonote::Blockchain::m_blocks_hash_check
std::vector< std::pair< crypto::hash, uint64_t > > m_blocks_hash_check
Definition: blockchain.h:1088
cryptonote::Blockchain::~Blockchain
~Blockchain()
Blockchain destructor.
Definition: blockchain.cpp:105
cryptonote::HardFork::get
uint8_t get(uint64_t height) const
returns the hard fork version for the given block height
Definition: hardfork.cpp:347
cryptonote::Blockchain::get_blockchain_pruning_seed
uint32_t get_blockchain_pruning_seed() const
Definition: blockchain.h:996
net::socks::version
version
Supported socks variants.
Definition: socks.h:58
cryptonote::Blockchain::find_blockchain_supplement
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, std::vector< crypto::hash > &hashes, std::vector< uint64_t > *weights, uint64_t &start_height, uint64_t &current_height, bool clip_pruned) const
get recent block hashes for a foreign chain
Definition: blockchain.cpp:2645
cryptonote::Blockchain::block_extended_info::cumulative_difficulty
difficulty_type cumulative_difficulty
the accumulated difficulty after that block
Definition: blockchain.h:106
cryptonote::Blockchain::set_user_options
void set_user_options(uint64_t maxthreads, bool sync_on_blocks, uint64_t sync_threshold, blockchain_db_sync_mode sync_mode, bool fast_sync)
sets various performance options
Definition: blockchain.cpp:5261
cryptonote::Blockchain::get_next_difficulty_for_alternative_chain
difficulty_type get_next_difficulty_for_alternative_chain(const std::list< block_extended_info > &alt_chain, block_extended_info &bei) const
gets the difficulty requirement for a new block on an alternate chain
Definition: blockchain.cpp:1253
cryptonote::txin_to_key
Definition: cryptonote_basic.h:124
cryptonote::HardFork::get_current_version
uint8_t get_current_version() const
returns the current version
Definition: hardfork.cpp:360
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:314
cryptonote::Blockchain::m_db_default_sync
bool m_db_default_sync
Definition: blockchain.h:1094
cryptonote::Blockchain::get_db
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition: blockchain.h:942
cryptonote::Blockchain::blocks_ext_by_hash
std::unordered_map< crypto::hash, block_extended_info > blocks_ext_by_hash
Definition: blockchain.h:1069
cryptonote::Blockchain::m_btc_pool_cookie
uint64_t m_btc_pool_cookie
Definition: blockchain.h:1140
cryptonote::BlockchainDB::get_blockchain_pruning_seed
virtual uint32_t get_blockchain_pruning_seed() const =0
get the blockchain pruning seed
cryptonote::Blockchain::m_db_sync_threshold
uint64_t m_db_sync_threshold
Definition: blockchain.h:1096
cryptonote
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
cryptonote::Blockchain::for_all_transactions
bool for_all_transactions(std::function< bool(const crypto::hash &, const cryptonote::transaction &)>, bool pruned) const
perform a check on all transactions in the blockchain
Definition: blockchain.cpp:5500
cryptonote::Blockchain::check_ring_signature
void check_ring_signature(const crypto::hash &tx_prefix_hash, const crypto::key_image &key_image, const std::vector< rct::ctkey > &pubkeys, const std::vector< crypto::signature > &sig, uint64_t &result) const
validates a transaction input's ring signature
Definition: blockchain.cpp:3618
cryptonote::Blockchain::add_block_notify
void add_block_notify(boost::function< void(std::uint64_t, epee::span< const block >)> &&notify)
sets a block notify object to call for every new block
Definition: blockchain.cpp:5275
cryptonote::Blockchain::get_last_n_blocks_weights
void get_last_n_blocks_weights(std::vector< uint64_t > &weights, size_t count) const
gets recent block weights for median calculation
Definition: blockchain.cpp:1423
cryptonote::Blockchain::get_dynamic_base_fee_estimate
uint64_t get_dynamic_base_fee_estimate(uint64_t grace_blocks) const
get dynamic per kB or byte fee estimate for the next few blocks
Definition: blockchain.cpp:3732
cryptonote::Blockchain::m_invalid_blocks
blocks_ext_by_hash m_invalid_blocks
Definition: blockchain.h:1120
checkpoints.h
cryptonote::Blockchain::check_block_timestamp
bool check_block_timestamp(const block &b) const
Definition: blockchain.h:1441
cryptonote::Blockchain::m_async_work_idle
std::unique_ptr< boost::asio::io_service::work > m_async_work_idle
Definition: blockchain.h:1117
cryptonote::Blockchain::get_output_histogram
std::map< uint64_t, std::tuple< uint64_t, uint64_t, uint64_t > > get_output_histogram(const std::vector< uint64_t > &amounts, bool unlocked, uint64_t recent_cutoff, uint64_t min_count=0) const
return a histogram of outputs on the blockchain
Definition: blockchain.cpp:5311
cryptonote::Blockchain::m_difficulty_for_next_block
difficulty_type m_difficulty_for_next_block
Definition: blockchain.h:1113
cryptonote::Blockchain::m_reset_timestamps_and_difficulties_height
bool m_reset_timestamps_and_difficulties_height
Definition: blockchain.h:1105
cryptonote::Blockchain::m_prepare_blocks
std::vector< block > * m_prepare_blocks
Definition: blockchain.h:1159
cryptonote::Blockchain::is_tx_spendtime_unlocked
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint8_t hf_version) const
checks if a transaction is unlocked (its outputs spendable)
Definition: blockchain.cpp:3773
cryptonote::Blockchain::set_show_time_stats
void set_show_time_stats(bool stats)
set whether or not to show/print time statistics
Definition: blockchain.h:790
cryptonote::BlockchainDB::height
virtual uint64_t height() const =0
fetch the current blockchain height
cryptonote::Blockchain::m_btc_seed_hash
crypto::hash m_btc_seed_hash
Definition: blockchain.h:1142
cryptonote::Blockchain::m_db_sync_mode
blockchain_db_sync_mode m_db_sync_mode
Definition: blockchain.h:1091
cryptonote::Blockchain::get_ideal_hard_fork_version
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition: blockchain.h:811
cryptonote::Blockchain::m_btc_height
uint64_t m_btc_height
Definition: blockchain.h:1139
cryptonote::Blockchain::get_next_long_term_block_weight
uint64_t get_next_long_term_block_weight(uint64_t block_weight) const
gets the long term block weight for a new block
Definition: blockchain.cpp:4403
cryptonote::Blockchain::prevalidate_block_hashes
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector< crypto::hash > &hashes, const std::vector< uint64_t > &weights)
Definition: blockchain.cpp:4733
tools
Various Tools.
Definition: apply_permutation.h:40
core_rpc_server_commands_defs.h
cryptonote::Blockchain::switch_to_alternative_blockchain
bool switch_to_alternative_blockchain(std::list< block_extended_info > &alt_chain, bool discard_disconnected_chain)
performs a blockchain reorganization according to the longest chain rule
Definition: blockchain.cpp:1136
rct::rctSig
Definition: rctTypes.h:536
difficulty.h
cryptonote::Blockchain::block_extended_info::height
uint64_t height
the height of the block in the blockchain
Definition: blockchain.h:104
cryptonote::txpool_tx_meta_t
a struct containing txpool per transaction metadata
Definition: blockchain_db.h:155
cryptonote::Blockchain::get_next_hard_fork_version
uint8_t get_next_hard_fork_version() const
returns the next hardfork version
Definition: blockchain.h:818
cryptonote::Blockchain::get_output_distribution
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
Definition: blockchain.cpp:2300
crypto::public_key
POD_CLASS public_key
Definition: crypto.h:61
cryptonote::Blockchain::get_pending_block_id_by_height
crypto::hash get_pending_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition: blockchain.cpp:771
cryptonote::Blockchain::m_long_term_block_weights_window
uint64_t m_long_term_block_weights_window
Definition: blockchain.h:1106
cryptonote::Blockchain::for_all_outputs
bool for_all_outputs(std::function< bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)>) const
perform a check on all outputs in the blockchain
Definition: blockchain.cpp:5505
cryptonote::blobdata
std::string blobdata
Definition: blobdatatype.h:39
cryptonote::Blockchain::get_outs
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: blockchain.cpp:2245
cryptonote::Blockchain::m_btc_nonce
blobdata m_btc_nonce
Definition: blockchain.h:1137
cryptonote::Blockchain::block_extended_info::block_cumulative_weight
uint64_t block_cumulative_weight
the weight of the block
Definition: blockchain.h:105
cryptonote::Blockchain::pop_blocks
void pop_blocks(uint64_t nblocks)
removes blocks from the top of the blockchain
Definition: blockchain.cpp:541
cryptonote::Blockchain::has_block_weights
bool has_block_weights(uint64_t height, uint64_t nblocks) const
checks whether we have known weights for the given block heights
Definition: blockchain.cpp:4851
cryptonote::Blockchain::check_tx_input
bool check_tx_input(size_t tx_version, const txin_to_key &txin, const crypto::hash &tx_prefix_hash, const std::vector< crypto::signature > &sig, const rct::rctSig &rct_signatures, std::vector< rct::ctkey > &output_keys, uint64_t *pmax_related_block_height, uint8_t hf_version) const
collect output public keys of a transaction input set
Definition: blockchain.cpp:3800
cryptonote::Blockchain::m_show_time_stats
bool m_show_time_stats
Definition: blockchain.h:1093
cryptonote::Blockchain::store_blockchain
bool store_blockchain()
stores the blockchain
Definition: blockchain.cpp:471
cryptonote::Blockchain::get_current_hard_fork_version
uint8_t get_current_hard_fork_version() const
gets the current hardfork version in use/voted for
Definition: blockchain.h:804
cryptonote::Blockchain::m_btc_expected_reward
uint64_t m_btc_expected_reward
Definition: blockchain.h:1141
cryptonote::Blockchain::get_tx_outputs_gindexs
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: blockchain.cpp:2886
cryptonote::Blockchain::update_blockchain_pruning
bool update_blockchain_pruning()
Definition: blockchain.cpp:4385
cryptonote::Blockchain::add_new_block
bool add_new_block(const block &bl_, block_verification_context &bvc)
adds a block to the blockchain
Definition: blockchain.cpp:4497
cryptonote::Blockchain::set_enforce_dns_checkpoints
void set_enforce_dns_checkpoints(bool enforce)
configure whether or not to enforce DNS-based checkpoints
Definition: blockchain.cpp:4614
cryptonote::Blockchain::get_last_block_timestamps
std::vector< time_t > get_last_block_timestamps(unsigned int blocks) const
returns the timestamps of the last N blocks
Definition: blockchain.cpp:1078
cryptonote::Blockchain::invalidate_block_template_cache
void invalidate_block_template_cache()
invalidates any cached block template
Definition: blockchain.cpp:5515
cryptonote::Blockchain::m_fixed_difficulty
difficulty_type m_fixed_difficulty
Definition: blockchain.h:1130
cryptonote::account_public_address
Definition: cryptonote_basic.h:501
cryptonote::Blockchain::block_extended_info
container for passing a block and metadata about it on the blockchain
Definition: blockchain.h:102
cryptonote::HardFork
Definition: hardfork.h:40
cryptonote::Blockchain::remove_txpool_tx
void remove_txpool_tx(const crypto::hash &txid)
Definition: blockchain.cpp:5226
cryptonote::Blockchain::m_async_pool
boost::thread_group m_async_pool
Definition: blockchain.h:1116
cryptonote::Blockchain::m_current_block_cumul_weight_median
size_t m_current_block_cumul_weight_median
Definition: blockchain.h:1080
cryptonote::tx_memory_pool
Transaction pool, handles transactions which are not part of a block.
Definition: tx_pool.h:97
hash.h
cryptonote::Blockchain::check_fee
bool check_fee(size_t tx_weight, uint64_t fee) const
validate a transaction's fee
Definition: blockchain.cpp:3678
cryptonote::HardFork::get_earliest_ideal_height_for_version
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
returns the earliest block a given version may activate
Definition: hardfork.cpp:383
cryptonote::Blockchain::get_num_mature_outputs
uint64_t get_num_mature_outputs(uint64_t amount) const
get number of outputs of an amount past the minimum spendable age
Definition: blockchain.cpp:2220
cryptonote::Blockchain::m_db
BlockchainDB * m_db
Definition: blockchain.h:1072
cryptonote::Blockchain::handle_alternative_block
bool handle_alternative_block(const block &b, const crypto::hash &id, block_verification_context &bvc)
validate and add a new block to an alternate blockchain
Definition: blockchain.cpp:1866
cryptonote::Blockchain::m_fake_scan_time
uint64_t m_fake_scan_time
Definition: blockchain.h:1099
cryptonote::Blockchain::add_txpool_tx
void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t &meta)
Definition: blockchain.cpp:5216
cryptonote::transaction
Definition: cryptonote_basic.h:194
cryptonote::Blockchain::m_difficulties
std::vector< difficulty_type > m_difficulties
Definition: blockchain.h:1103
cryptonote::Blockchain::get_long_term_block_weight_median
uint64_t get_long_term_block_weight_median(uint64_t start_height, size_t count) const
gets block long term weight median
Definition: blockchain.cpp:1438
cryptonote::Blockchain::m_cancel
std::atomic< bool > m_cancel
Definition: blockchain.h:1132
cryptonote::Blockchain::for_all_key_images
bool for_all_key_images(std::function< bool(const crypto::key_image &)>) const
perform a check on all key images in the blockchain
Definition: blockchain.cpp:5490
cryptonote::Blockchain::m_batch_success
bool m_batch_success
Definition: blockchain.h:1147
cryptonote::Blockchain::update_txpool_tx
void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta)
Definition: blockchain.cpp:5221
cryptonote::Blockchain::get_current_blockchain_height
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
Definition: blockchain.cpp:266
cryptonote::NOTIFY_RESPONSE_GET_OBJECTS::request
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:246
cryptonote::Blockchain::m_timestamps_and_difficulties_height
uint64_t m_timestamps_and_difficulties_height
Definition: blockchain.h:1104
cryptonote::Blockchain::m_blocks_longhash_table
std::unordered_map< crypto::hash, crypto::hash > m_blocks_longhash_table
Definition: blockchain.h:1084
cryptonote::Blockchain::m_blocks_hash_of_hashes
std::vector< std::pair< crypto::hash, crypto::hash > > m_blocks_hash_of_hashes
Definition: blockchain.h:1087
cryptonote::Blockchain::m_bytes_to_sync
uint64_t m_bytes_to_sync
Definition: blockchain.h:1101
cryptonote::Blockchain::m_prepare_nblocks
uint64_t m_prepare_nblocks
Definition: blockchain.h:1158
cryptonote::Blockchain::m_blockchain_lock
epee::critical_section m_blockchain_lock
Definition: blockchain.h:1076
cryptonote::Blockchain::unlock
void unlock()
Definition: blockchain.cpp:5485
cryptonote::Blockchain::block_extended_info::already_generated_coins
uint64_t already_generated_coins
the total coins minted after that block
Definition: blockchain.h:107
cryptonote::Blockchain::get_txpool_tx_blob
bool get_txpool_tx_blob(const crypto::hash &txid, cryptonote::blobdata &bd, relay_category tx_category) const
Definition: blockchain.cpp:5241
crypto::key_image
POD_CLASS key_image
Definition: crypto.h:87
cryptonote::Blockchain::m_btc_difficulty
difficulty_type m_btc_difficulty
Definition: blockchain.h:1138
cryptonote::Blockchain::get_alternative_chains
std::vector< std::pair< block_extended_info, std::vector< crypto::hash > > > get_alternative_chains() const
returns a set of known alternate chains
Definition: blockchain.cpp:5316
cryptonote::Blockchain::check_tx_outputs
bool check_tx_outputs(const transaction &tx, tx_verification_context &tvc) const
check that a transaction's outputs conform to current standards
Definition: blockchain.cpp:2959
cryptonote::Blockchain::check_for_double_spend
bool check_for_double_spend(const transaction &tx, key_images_container &keys_this_block) const
make sure a transaction isn't attempting a double-spend
Definition: blockchain.cpp:2810
blockchain_db.h
util.h
cryptonote::Blockchain::prevalidate_miner_transaction
bool prevalidate_miner_transaction(const block &b, uint64_t height, uint8_t hf_version)
sanity checks a miner transaction before validating an entire block
Definition: blockchain.cpp:1326
cryptonote::Blockchain::m_async_service
boost::asio::io_service m_async_service
Definition: blockchain.h:1115
cryptonote::HardFork::get_next_version
uint8_t get_next_version() const
returns the next version
Definition: hardfork.cpp:396
cryptonote::Blockchain::build_alt_chain
bool build_alt_chain(const crypto::hash &prev_id, std::list< block_extended_info > &alt_chain, std::vector< uint64_t > &timestamps, block_verification_context &bvc) const
builds a list of blocks connecting a block to the main chain
Definition: blockchain.cpp:1805
cryptonote::Blockchain::set_reorg_notify
void set_reorg_notify(const std::shared_ptr< tools::Notify > &notify)
sets a reorg notify object to call for every reorg
Definition: blockchain.h:778
cryptonote::COMMAND_RPC_GET_OUTPUTS_BIN::response
epee::misc_utils::struct_init< response_t > response
Definition: core_rpc_server_commands_defs.h:515
cryptonote::Blockchain::m_timestamps
std::vector< uint64_t > m_timestamps
Definition: blockchain.h:1102
cryptonote::Blockchain::m_difficulty_lock
epee::critical_section m_difficulty_lock
Definition: blockchain.h:1111
cryptonote::Blockchain::m_block_notifiers
std::vector< boost::function< void(std::uint64_t, epee::span< const block >)> > m_block_notifiers
Definition: blockchain.h:1153
cryptonote::Blockchain::txpool_tx_matches_category
bool txpool_tx_matches_category(const crypto::hash &tx_hash, relay_category category)
Definition: blockchain.cpp:5256
cryptonote::Blockchain::get_blocks
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:2090
cryptonote::Blockchain::get_dynamic_base_fee
static uint64_t get_dynamic_base_fee(uint64_t block_reward, size_t median_block_weight, uint8_t version)
get dynamic per kB or byte fee for a given block weight
Definition: blockchain.cpp:3645
cryptonote::test_options
Definition: cryptonote_core.h:60
crypto::hash
POD_CLASS hash
Definition: hash.h:48