32#include <boost/asio/executor_work_guard.hpp>
33#include <boost/asio/io_context.hpp>
34#include <boost/function/function_fwd.hpp>
35#if BOOST_VERSION >= 107400
36#include <boost/serialization/library_version_type.hpp>
38#include <boost/serialization/serialization.hpp>
39#include <boost/serialization/version.hpp>
40#include <boost/serialization/list.hpp>
41#include <boost/multi_index_container.hpp>
42#include <boost/multi_index/global_fun.hpp>
43#include <boost/multi_index/hashed_index.hpp>
44#include <boost/multi_index/member.hpp>
47#include <unordered_map>
48#include <unordered_set>
188 bool get_blocks(
uint64_t start_offset,
size_t count, std::vector<std::pair<cryptonote::blobdata,block>>&
blocks, std::vector<cryptonote::blobdata>& txs)
const;
199 bool get_blocks(
uint64_t start_offset,
size_t count, std::vector<std::pair<cryptonote::blobdata,block>>&
blocks)
const;
519 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;
731 std::uint8_t hf_version);
775 template<
class t_
ids_container,
class t_blocks_container,
class t_missed_container>
776 bool get_blocks(
const t_ids_container& block_ids, t_blocks_container&
blocks, t_missed_container& missed_bs)
const;
791 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;
792 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;
793 template<
class t_
ids_container,
class t_tx_container,
class t_missed_container>
795 template<
class t_
ids_container,
class t_tx_container,
class t_missed_container>
796 bool get_transactions(
const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs,
bool pruned =
false)
const;
991 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;
1070 std::vector<output_data_t> &
outputs)
const;
1080 std::unordered_map<crypto::hash, crypto::hash> &map)
const;
1158#ifndef IN_UNIT_TESTS
1181 std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, std::vector<output_data_t>>>
m_scan_table;
1214 std::unique_ptr<boost::asio::executor_work_guard<boost::asio::io_context::executor_type>>
m_async_work_idle;
1284 template<
class visitor_t>
1605 const std::vector<rct::ctkey> &pubkeys,
const std::vector<crypto::signature> &sig,
uint64_t &
result)
const;
cryptonote::block b
Definition block.cpp:40
static boost::multiprecision::uint128_t fees
Definition blockchain_stats.cpp:58
static uint64_t h
Definition blockchain_stats.cpp:55
The BlockchainDB backing store interface declaration/contract.
Definition blockchain_db.h:379
bool m_fast_sync
Definition blockchain.h:1189
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition blockchain.cpp:709
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition blockchain.cpp:773
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:3606
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:926
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:1331
bool check_fee(size_t tx_weight, uint64_t fee) const
validate a transaction's fee
Definition blockchain.cpp:3666
bool check_block_timestamp(const block &b) const
Definition blockchain.h:1547
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:5033
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:5014
uint8_t get_current_hard_fork_version() const
gets the current hardfork version in use/voted for
Definition blockchain.h:902
bool get_txpool_tx_meta(const crypto::hash &txid, txpool_tx_meta_t &meta) const
Definition blockchain.cpp:5422
std::unique_ptr< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > m_async_work_idle
Definition blockchain.h:1214
bool prune_blockchain(uint32_t pruning_seed=0)
Definition blockchain.cpp:4537
std::vector< MinerNotifyCallback > m_miner_notifiers
Definition blockchain.h:1254
size_t m_current_block_cumul_weight_limit
Definition blockchain.h:1177
uint64_t m_max_prepare_blocks_threads
Definition blockchain.h:1194
void get_dynamic_base_fee_estimate_2021_scaling(uint64_t grace_blocks, uint64_t base_reward, uint64_t Mnw, uint64_t Mlw, std::vector< uint64_t > &fees) const
Definition blockchain.cpp:3720
bool m_db_default_sync
Definition blockchain.h:1191
uint64_t m_prepare_nblocks
Definition blockchain.h:1259
uint64_t m_bytes_to_sync
Definition blockchain.h:1198
crypto::hash m_btc_seed_hash
Definition blockchain.h:1239
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:1408
epee::critical_section m_difficulty_lock
Definition blockchain.h:1208
bool get_short_chain_history(std::list< crypto::hash > &ids, uint64_t ¤t_height) const
gets the hashes for a subset of the blockchain
Definition blockchain.cpp:731
bool get_transactions(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs, bool pruned=false) const
bool get_tx_outputs_gindexs(const crypto::hash &tx_id, std::vector< uint64_t > &indexs) const
gets the global indices for outputs from a given transaction
Definition blockchain.cpp:2928
bool m_enforce_dns_checkpoints
Definition blockchain.h:1221
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:807
bool handle_block_to_main_chain(const block &bl, block_verification_context &bvc)
validate and add a new block to the end of the blockchain
Definition blockchain.cpp:2828
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:5437
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Definition blockchain.cpp:5501
uint64_t m_long_term_block_weights_window
Definition blockchain.h:1203
void flush_invalid_blocks()
flush the invalid blocks set
Definition blockchain.cpp:2783
epee::critical_section m_blockchain_lock
Definition blockchain.h:1174
void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t &meta)
Definition blockchain.cpp:5402
block pop_block_from_blockchain()
removes the most recent block from the blockchain
Definition blockchain.cpp:596
void load_compiled_in_block_hashes(const GetCheckpointsCallback &get_checkpoints)
loads block hashes from compiled-in data set
crypto::public_key get_output_key(uint64_t amount, uint64_t global_index) const
get the public key for an output
Definition blockchain.cpp:2274
boost::asio::io_context m_async_service
Definition blockchain.h:1212
uint64_t m_long_term_effective_median_block_weight
Definition blockchain.h:1204
void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta)
Definition blockchain.cpp:5407
static bool expand_transaction_2(transaction &tx, const crypto::hash &tx_prefix_hash, const std::vector< std::vector< rct::ctkey > > &pubkeys)
expands v2 transaction data from blockchain
Definition blockchain.cpp:3145
bool add_block_as_invalid(const block &bl, const crypto::hash &h)
stores an invalid block in a separate container
Definition blockchain.cpp:2765
bool get_split_transactions_blobs(const t_ids_container &txs_ids, t_tx_container &txs, t_missed_container &missed_txs) const
Definition blockchain.cpp:2604
uint64_t m_fake_scan_time
Definition blockchain.h:1196
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
void set_enforce_dns_checkpoints(bool enforce)
configure whether or not to enforce DNS-based checkpoints
Definition blockchain.cpp:4776
bool check_blockchain_pruning()
Definition blockchain.cpp:4555
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 blockchain.cpp:1753
std::vector< block_extended_info > blocks_container
Definition blockchain.h:1165
BlockchainDB * m_db
Definition blockchain.h:1170
blobdata m_btc_nonce
Definition blockchain.h:1234
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:3796
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:4878
const checkpoints & get_checkpoints() const
get a set of blockchain checkpoint hashes
Definition blockchain.h:169
void add_block_notify(BlockNotifyCallback &¬ify)
sets a block notify object to call for every new block
Definition blockchain.cpp:5467
size_t m_current_block_cumul_weight_median
Definition blockchain.h:1178
bool handle_alternative_block(const block &b, const crypto::hash &id, block_verification_context &bvc, pool_supplement &extra_block_txs)
validate and add a new block to an alternate blockchain
Definition blockchain.cpp:1860
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:4565
network_type m_nettype
Definition blockchain.h:1225
bool update_checkpoints(const std::string &file_path, bool check_dns)
loads new checkpoints from a file and optionally from DNS
Definition blockchain.cpp:4741
void add_miner_notify(MinerNotifyCallback &¬ify)
sets a miner notify object to call for every new block
Definition blockchain.cpp:5476
std::vector< std::pair< crypto::hash, uint64_t > > m_blocks_hash_check
Definition blockchain.h:1186
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector< crypto::hash > &hashes, const std::vector< uint64_t > &weights)
Definition blockchain.cpp:4894
bool check_block_timestamp(const block &b, uint64_t &median_ts) const
checks a block's timestamp
Definition blockchain.cpp:3987
bool is_within_compiled_block_hash_area() const
Definition blockchain.h:1099
uint64_t get_txpool_tx_count(bool include_sensitive=false) const
Definition blockchain.cpp:5417
~Blockchain()
Blockchain destructor.
Definition blockchain.cpp:110
void set_show_time_stats(bool stats)
set whether or not to show/print time statistics
Definition blockchain.h:888
uint64_t m_timestamps_and_difficulties_height
Definition blockchain.h:1201
std::unordered_map< crypto::hash, block_extended_info > blocks_ext_by_hash
Definition blockchain.h:1167
account_public_address m_btc_address
Definition blockchain.h:1233
bool deinit()
Uninitializes the blockchain state.
Definition blockchain.cpp:514
blockchain_db_sync_mode m_db_sync_mode
Definition blockchain.h:1188
crypto::hash m_long_term_block_weights_cache_tip_hash
Definition blockchain.h:1205
bool txpool_tx_matches_category(const crypto::hash &tx_hash, relay_category category)
Definition blockchain.cpp:5442
HardFork::State get_hard_fork_state() const
gets the hardfork voting state object
Definition blockchain.cpp:5513
uint64_t m_sync_counter
Definition blockchain.h:1197
difficulty_type m_difficulty_for_next_block
Definition blockchain.h:1210
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:1462
difficulty_type block_difficulty(uint64_t i) const
gets the difficulty of the block with a given height
Definition blockchain.cpp:2435
bool m_show_time_stats
Definition blockchain.h:1190
std::unordered_map< crypto::hash, crypto::hash > m_blocks_longhash_table
Definition blockchain.h:1182
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:140
void set_txpool_notify(TxpoolNotifyCallback &¬ify)
sets a txpool notify object to call for every new tx used to add a new block
Definition blockchain.cpp:5461
void prepare_handle_incoming_block_no_preprocess(const size_t block_byte_estimate)
prepare the blockchain for handling an incoming block, without performing preprocessing
Definition blockchain.cpp:5381
TxpoolNotifyCallback m_txpool_notifier
Definition blockchain.h:1246
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:5533
std::vector< difficulty_type > m_difficulties
Definition blockchain.h:1200
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:3844
tx_memory_pool & m_tx_pool
Definition blockchain.h:1172
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:2126
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:1297
bool check_block_timestamp(std::vector< uint64_t > ×tamps, const block &b) const
Definition blockchain.h:1561
void set_reorg_notify(const std::shared_ptr< tools::Notify > ¬ify)
sets a reorg notify object to call for every reorg
Definition blockchain.h:871
uint64_t m_btc_expected_reward
Definition blockchain.h:1238
uint64_t m_btc_height
Definition blockchain.h:1236
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Definition blockchain.cpp:2225
std::atomic< bool > m_cancel
Definition blockchain.h:1229
bool update_blockchain_pruning()
Definition blockchain.cpp:4546
void check_against_checkpoints(const checkpoints &points, bool enforce)
check the blockchain against a set of checkpoints
Definition blockchain.cpp:4703
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:5738
crypto::hash m_difficulty_for_next_block_top_hash
Definition blockchain.h:1209
Blockchain(tx_memory_pool &tx_pool)
Blockchain constructor.
Definition blockchain.cpp:93
bool complete_timestamps_vector(uint64_t start_height, std::vector< uint64_t > ×tamps) const
finish an alternate chain's timestamp window from the main chain
Definition blockchain.cpp:1779
uint64_t get_current_cumulative_block_weight_limit() const
gets the block weight limit based on recent blocks
Definition blockchain.cpp:1456
std::vector< time_t > get_last_block_timestamps(unsigned int blocks) const
returns the timestamps of the last N blocks
Definition blockchain.cpp:1040
std::vector< std::pair< crypto::hash, crypto::hash > > m_blocks_hash_of_hashes
Definition blockchain.h:1185
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:5712
uint64_t m_btc_pool_cookie
Definition blockchain.h:1237
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:1055
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:1748
bool store_blockchain()
stores the blockchain
Definition blockchain.cpp:484
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:2256
bool have_block_unlocked(const crypto::hash &id, int *where=NULL) const
checks if a block is known about with a given hash
Definition blockchain.cpp:2790
rct_ver_cache_t m_rct_ver_cache
Definition blockchain.h:1263
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:5447
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
difficulty_type get_difficulty_for_next_block()
returns the difficulty target the next block to be added must meet
Definition blockchain.cpp:855
uint8_t get_next_hard_fork_version() const
returns the next hardfork version
Definition blockchain.h:916
std::shared_ptr< tools::Notify > m_reorg_notify
Definition blockchain.h:1255
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:1393
uint64_t m_fake_pow_calc_time
Definition blockchain.h:1195
const BlockchainDB & get_db() const
get a reference to the BlockchainDB in use by Blockchain
Definition blockchain.h:1047
std::vector< uint64_t > m_timestamps
Definition blockchain.h:1199
void invalidate_block_template_cache()
invalidates any cached block template
Definition blockchain.cpp:5732
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition blockchain.cpp:4801
bool m_offline
Definition blockchain.h:1226
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:949
difficulty_type m_fixed_difficulty
Definition blockchain.h:1227
void remove_txpool_tx(const crypto::hash &txid)
Definition blockchain.cpp:5412
uint8_t get_hard_fork_version(uint64_t height) const
returns the actual hardfork version for a given block height
Definition blockchain.h:935
std::vector< block > * m_prepare_blocks
Definition blockchain.h:1260
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:5717
uint64_t get_difficulty_target() const
get difficulty target based on chain and hardfork version
Definition blockchain.cpp:5523
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:2852
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:4782
crypto::hash get_pending_block_id_by_height(uint64_t height) const
gets a block's hash given a height
Definition blockchain.cpp:800
void send_miner_notifications(uint64_t height, const crypto::hash &seed_hash, const crypto::hash &prev_id, uint64_t already_generated_coins)
sends new block notifications to ZMQ miner_data subscribers
Definition blockchain.cpp:5753
HardFork * m_hardfork
Definition blockchain.h:1223
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 ¤t_height, bool clip_pruned) const
get recent block hashes for a foreign chain
Definition blockchain.cpp:2674
boost::thread_group m_async_pool
Definition blockchain.h:1213
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:1223
BlockchainDB & get_db()
get a reference to the BlockchainDB in use by Blockchain
Definition blockchain.h:1057
blocks_ext_by_hash m_invalid_blocks
Definition blockchain.h:1217
bool m_btc_valid
Definition blockchain.h:1241
block m_btc
Definition blockchain.h:1232
std::mutex m_txpool_notifier_mutex
Definition blockchain.h:1247
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Definition blockchain.cpp:2247
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition blockchain.h:909
uint32_t get_blockchain_pruning_seed() const
Definition blockchain.h:1101
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:3620
bool have_tx(const crypto::hash &id) const
search the blockchain for a transaction by hash
Definition blockchain.cpp:116
uint64_t m_btc_seed_height
Definition blockchain.h:1240
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:5707
epee::misc_utils::rolling_median_t< uint64_t > m_long_term_block_weights_cache_rolling_median
Definition blockchain.h:1206
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:5528
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:1099
size_t get_total_transactions() const
gets the total number of transactions on the main chain
Definition blockchain.cpp:2836
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
returns the earliest block a given version may activate
Definition blockchain.h:942
bool reset_and_set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition blockchain.cpp:683
bool for_all_outputs(uint64_t amount, std::function< bool(uint64_t height)>) const
perform a check on all outputs of a given amount in the blockchain
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:3134
void lock()
Definition blockchain.cpp:5697
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:2544
bool m_reset_timestamps_and_difficulties_height
Definition blockchain.h:1202
void unlock()
Definition blockchain.cpp:5702
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:4596
bool flush_txes_from_pool(const std::vector< crypto::hash > &txids)
remove transactions from the transaction pool (if present)
Definition blockchain.cpp:4017
bool get_txpool_tx_blob(const crypto::hash &txid, cryptonote::blobdata &bd, relay_category tx_category) const
Definition blockchain.cpp:5427
bool m_db_sync_on_blocks
Definition blockchain.h:1192
uint64_t m_db_sync_threshold
Definition blockchain.h:1193
std::unordered_set< crypto::key_image > key_images_container
Definition blockchain.h:1163
bool add_new_block(const block &bl_, block_verification_context &bvc)
adds a block to the blockchain
Definition blockchain.cpp:4655
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:2281
std::unordered_map< crypto::hash, std::unordered_map< crypto::key_image, std::vector< output_data_t > > > m_scan_table
Definition blockchain.h:1181
uint64_t get_adjusted_time(uint64_t height) const
get the "adjusted time"
Definition blockchain.cpp:3932
bool build_alt_chain(const crypto::hash &prev_id, std::list< block_extended_info > &alt_chain, std::vector< uint64_t > ×tamps, block_verification_context &bvc) const
builds a list of blocks connecting a block to the main chain
Definition blockchain.cpp:1799
checkpoints m_checkpoints
Definition blockchain.h:1220
bool m_batch_success
Definition blockchain.h:1244
static bool check_tx_outputs(const transaction &tx, tx_verification_context &tvc, std::uint8_t hf_version)
check that a transaction's outputs conform to current standards
Definition blockchain.cpp:2983
void notify_txpool_event(std::vector< txpool_event > &&event) const
Notify this Blockchain's txpool notifier about a txpool event.
Definition blockchain.cpp:5485
void cancel()
Definition blockchain.cpp:5590
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:126
static uint64_t get_fee_quantization_mask()
get fee quantization mask
Definition blockchain.h:651
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:2176
const std::vector< hardfork_t > & get_hardforks() const
returns info for all known hard forks
Definition blockchain.h:949
std::vector< BlockNotifyCallback > m_block_notifiers
Definition blockchain.h:1253
difficulty_type m_btc_difficulty
Definition blockchain.h:1235
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:2326
bool have_block(const crypto::hash &id, int *where=NULL) const
Definition blockchain.cpp:2822
uint64_t get_current_blockchain_height() const
get the current height of the blockchain
Definition blockchain.cpp:271
void pop_blocks(uint64_t nblocks)
removes blocks from the top of the blockchain
Definition blockchain.cpp:554
uint64_t m_prepare_height
Definition blockchain.h:1258
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:5518
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition blockchain.h:176
std::pair< bool, uint64_t > check_difficulty_checkpoints() const
check currently stored difficulties against difficulty checkpoints
Definition blockchain.cpp:935
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:3871
State
Definition hardfork.h:42
A container for blockchain checkpoints.
Definition checkpoints.h:53
Definition cryptonote_basic.h:205
Transaction pool, handles transactions which are not part of a block.
Definition tx_pool.h:99
Non-owning sequence of data. Does not deep copy.
Definition span.h:55
std::tuple< uint64_t, uint64_t, std::vector< tools::wallet2::transfer_details > > outputs
Definition cold-outputs.cpp:53
#define PER_KB_FEE_QUANTIZATION_DECIMALS
Definition cryptonote_config.h:196
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT
Definition cryptonote_config.h:65
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition document.h:2116
const char * res
Definition hmac_keccak.cpp:42
const char * key
Definition hmac_keccak.cpp:40
static void init()
Definition logging.cpp:42
static int version
Definition mdb_load.c:29
uint32_t address
Definition getifaddr.c:269
Definition block_weight.py:1
POD_CLASS public_key
Definition crypto.h:64
POD_CLASS key_image
Definition crypto.h:95
POD_CLASS hash
Definition hash.h:49
Holds cryptonote related classes and helpers.
Definition blockchain_db.cpp:45
boost::function< void(uint64_t, epee::span< const block >)> BlockNotifyCallback
Definition blockchain.h:96
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:41
network_type
Definition cryptonote_config.h:302
@ MAINNET
Definition cryptonote_config.h:303
relay_category
Definition blockchain_db.h:110
@ broadcasted
Public txes received via block/fluff.
Definition blockchain_db.h:111
boost::function< void(std::vector< txpool_event >)> TxpoolNotifyCallback
Definition blockchain.h:95
blockchain_db_sync_mode
Definition blockchain.h:79
@ db_async
handle syncing calls instead of the backing db, asynchronously
Definition blockchain.h:82
@ db_nosync
Leave syncing up to the backing db (safest, but slowest because of disk I/O).
Definition blockchain.h:83
@ db_sync
handle syncing calls instead of the backing db, synchronously
Definition blockchain.h:81
@ db_defaultsync
user didn't specify, use db_async
Definition blockchain.h:80
std::function< const epee::span< const unsigned char >(cryptonote::network_type network)> GetCheckpointsCallback
Callback routine that returns checkpoints data for specific network type.
Definition blockchain.h:93
std::string blobdata
Definition blobdatatype.h:39
::tools::data_cache<::crypto::hash, RCT_VER_CACHE_SIZE > rct_ver_cache_t
Definition tx_verification_utils.h:49
boost::string_ref blobdata_ref
Definition blobdatatype.h:40
boost::function< void(uint8_t, uint64_t, const crypto::hash &, const crypto::hash &, difficulty_type, uint64_t, uint64_t, const std::vector< tx_block_template_backlog_entry > &)> MinerNotifyCallback
Definition blockchain.h:97
Definition get_output_distribution.py:1
tools::wallet2::message_signature_result_t result
Definition signature.cpp:62
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
container for passing a block and metadata about it on the blockchain
Definition blockchain.h:109
uint64_t already_generated_coins
the total coins minted after that block
Definition blockchain.h:114
uint64_t height
the height of the block in the blockchain
Definition blockchain.h:111
block bl
the block
Definition blockchain.h:110
difficulty_type cumulative_difficulty
the accumulated difficulty after that block
Definition blockchain.h:113
uint64_t block_cumulative_weight
the weight of the block
Definition blockchain.h:112
epee::misc_utils::struct_init< request_t > request
Definition core_rpc_server_commands_defs.h:539
epee::misc_utils::struct_init< response_t > response
Definition core_rpc_server_commands_defs.h:567
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:227
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:316
epee::misc_utils::struct_init< request_t > request
Definition cryptonote_protocol_defs.h:246
Definition cryptonote_basic.h:512
Definition verification_context.h:66
Definition cryptonote_basic.h:475
Used to provide transaction info that skips the mempool to block handling code.
Definition tx_verification_utils.h:101
Definition cryptonote_core.h:61
Definition verification_context.h:41
Definition cryptonote_basic.h:139
Definition minixmlvalid.c:15
Definition rctTypes.h:613
struct hash_func hashes[]
cryptonote::transaction tx
Definition transaction.cpp:40