Monero
db_lmdb.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2020, The Monero Project
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without modification, are
5 // permitted provided that the following conditions are met:
6 //
7 // 1. Redistributions of source code must retain the above copyright notice, this list of
8 // conditions and the following disclaimer.
9 //
10 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 // of conditions and the following disclaimer in the documentation and/or other
12 // materials provided with the distribution.
13 //
14 // 3. Neither the name of the copyright holder nor the names of its contributors may be
15 // used to endorse or promote products derived from this software without specific
16 // prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
19 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #pragma once
28 
29 #include <atomic>
30 
32 #include "cryptonote_basic/blobdatatype.h" // for type blobdata
33 #include "ringct/rctTypes.h"
34 #include <boost/thread/tss.hpp>
35 
36 #include <lmdb.h>
37 
38 #define ENABLE_AUTO_RESIZE
39 
40 namespace cryptonote
41 {
42 
43 typedef struct txindex {
47 
48 typedef struct mdb_txn_cursors
49 {
50  MDB_cursor *m_txc_blocks;
51  MDB_cursor *m_txc_block_heights;
52  MDB_cursor *m_txc_block_info;
53 
54  MDB_cursor *m_txc_output_txs;
55  MDB_cursor *m_txc_output_amounts;
56 
57  MDB_cursor *m_txc_txs;
58  MDB_cursor *m_txc_txs_pruned;
59  MDB_cursor *m_txc_txs_prunable;
62  MDB_cursor *m_txc_tx_indices;
63  MDB_cursor *m_txc_tx_outputs;
64 
65  MDB_cursor *m_txc_spent_keys;
66 
67  MDB_cursor *m_txc_txpool_meta;
68  MDB_cursor *m_txc_txpool_blob;
69 
70  MDB_cursor *m_txc_alt_blocks;
71 
72  MDB_cursor *m_txc_hf_versions;
73 
74  MDB_cursor *m_txc_properties;
76 
77 #define m_cur_blocks m_cursors->m_txc_blocks
78 #define m_cur_block_heights m_cursors->m_txc_block_heights
79 #define m_cur_block_info m_cursors->m_txc_block_info
80 #define m_cur_output_txs m_cursors->m_txc_output_txs
81 #define m_cur_output_amounts m_cursors->m_txc_output_amounts
82 #define m_cur_txs m_cursors->m_txc_txs
83 #define m_cur_txs_pruned m_cursors->m_txc_txs_pruned
84 #define m_cur_txs_prunable m_cursors->m_txc_txs_prunable
85 #define m_cur_txs_prunable_hash m_cursors->m_txc_txs_prunable_hash
86 #define m_cur_txs_prunable_tip m_cursors->m_txc_txs_prunable_tip
87 #define m_cur_tx_indices m_cursors->m_txc_tx_indices
88 #define m_cur_tx_outputs m_cursors->m_txc_tx_outputs
89 #define m_cur_spent_keys m_cursors->m_txc_spent_keys
90 #define m_cur_txpool_meta m_cursors->m_txc_txpool_meta
91 #define m_cur_txpool_blob m_cursors->m_txc_txpool_blob
92 #define m_cur_alt_blocks m_cursors->m_txc_alt_blocks
93 #define m_cur_hf_versions m_cursors->m_txc_hf_versions
94 #define m_cur_properties m_cursors->m_txc_properties
95 
96 typedef struct mdb_rflags
97 {
98  bool m_rf_txn;
104  bool m_rf_txs;
118 
119 typedef struct mdb_threadinfo
120 {
121  MDB_txn *m_ti_rtxn; // per-thread read txn
122  mdb_txn_cursors m_ti_rcursors; // per-thread read cursors
123  mdb_rflags m_ti_rflags; // per-thread read state
124 
125  ~mdb_threadinfo();
127 
129 {
130  mdb_txn_safe(const bool check=true);
131  ~mdb_txn_safe();
132 
133  void commit(std::string message = "");
134 
135  // This should only be needed for batch transaction which must be ensured to
136  // be aborted before mdb_env_close, not after. So we can't rely on
137  // BlockchainLMDB destructor to call mdb_txn_safe destructor, as that's too late
138  // to properly abort, since mdb_env_close would have been called earlier.
139  void abort();
140  void uncheck();
141 
142  operator MDB_txn*()
143  {
144  return m_txn;
145  }
146 
147  operator MDB_txn**()
148  {
149  return &m_txn;
150  }
151 
152  uint64_t num_active_tx() const;
153 
154  static void prevent_new_txns();
155  static void wait_no_active_txns();
156  static void allow_new_txns();
157 
159  MDB_txn* m_txn;
160  bool m_batch_txn = false;
161  bool m_check;
162  static std::atomic<uint64_t> num_active_txns;
163 
164  // could use a mutex here, but this should be sufficient.
165  static std::atomic_flag creation_gate;
166 };
167 
168 
169 // If m_batch_active is set, a batch transaction exists beyond this class, such
170 // as a batch import with verification enabled, or possibly (later) a batch
171 // network sync.
172 //
173 // For some of the lookup methods, such as get_block_timestamp(), tx_exists(),
174 // and get_tx(), when m_batch_active is set, the lookup uses the batch
175 // transaction. This isn't only because the transaction is available, but it's
176 // necessary so that lookups include the database updates only present in the
177 // current batch write.
178 //
179 // A regular network sync without batch writes is expected to open a new read
180 // transaction, as those lookups are part of the validation done prior to the
181 // write for block and tx data, so no write transaction is open at the time.
183 {
184 public:
185  BlockchainLMDB(bool batch_transactions=true);
186  ~BlockchainLMDB();
187 
188  virtual void open(const std::string& filename, const int mdb_flags=0);
189 
190  virtual void close();
191 
192  virtual void sync();
193 
194  virtual void safesyncmode(const bool onoff);
195 
196  virtual void reset();
197 
198  virtual std::vector<std::string> get_filenames() const;
199 
200  virtual bool remove_data_file(const std::string& folder) const;
201 
202  virtual std::string get_db_name() const;
203 
204  virtual bool lock();
205 
206  virtual void unlock();
207 
208  virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const;
209 
210  virtual uint64_t get_block_height(const crypto::hash& h) const;
211 
212  virtual block_header get_block_header(const crypto::hash& h) const;
213 
214  virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const;
215 
216  virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const;
217 
218  virtual std::vector<uint64_t> get_block_cumulative_rct_outputs(const std::vector<uint64_t> &heights) const;
219 
220  virtual uint64_t get_block_timestamp(const uint64_t& height) const;
221 
222  virtual uint64_t get_top_block_timestamp() const;
223 
224  virtual size_t get_block_weight(const uint64_t& height) const;
225 
226  virtual std::vector<uint64_t> get_block_weights(uint64_t start_height, size_t count) const;
227 
228  virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const;
229 
230  virtual difficulty_type get_block_difficulty(const uint64_t& height) const;
231 
232  virtual void correct_block_cumulative_difficulties(const uint64_t& start_height, const std::vector<difficulty_type>& new_cumulative_difficulties);
233 
234  virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const;
235 
236  virtual uint64_t get_block_long_term_weight(const uint64_t& height) const;
237 
238  virtual std::vector<uint64_t> get_long_term_block_weights(uint64_t start_height, size_t count) const;
239 
240  virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const;
241 
242  virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) const;
243 
244  virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const;
245 
246  virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const;
247 
248  virtual block get_top_block() const;
249 
250  virtual uint64_t height() const;
251 
252  virtual bool tx_exists(const crypto::hash& h) const;
253  virtual bool tx_exists(const crypto::hash& h, uint64_t& tx_index) const;
254 
255  virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const;
256 
257  virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
258  virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
259  virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const;
260  virtual bool get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const;
261  virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
262  virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const;
263 
264  virtual uint64_t get_tx_count() const;
265 
266  virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const;
267 
268  virtual uint64_t get_tx_block_height(const crypto::hash& h) const;
269 
270  virtual uint64_t get_num_outputs(const uint64_t& amount) const;
271 
272  virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index, bool include_commitmemt) const;
273  virtual void get_output_key(const epee::span<const uint64_t> &amounts, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs, bool allow_partial = false) const;
274 
275  virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const;
276  virtual void get_output_tx_and_index_from_global(const std::vector<uint64_t> &global_indices,
277  std::vector<tx_out_index> &tx_out_indices) const;
278 
279  virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const;
280  virtual void get_output_tx_and_index(const uint64_t& amount, const std::vector<uint64_t> &offsets, std::vector<tx_out_index> &indices) const;
281 
282  virtual std::vector<std::vector<uint64_t>> get_tx_amount_output_indices(const uint64_t tx_id, size_t n_txes) const;
283 
284  virtual bool has_key_image(const crypto::key_image& img) const;
285 
286  virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t& meta);
287  virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& meta);
288  virtual uint64_t get_txpool_tx_count(relay_category category = relay_category::broadcasted) const;
289  virtual bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const;
290  virtual void remove_txpool_tx(const crypto::hash& txid);
291  virtual bool get_txpool_tx_meta(const crypto::hash& txid, txpool_tx_meta_t &meta) const;
292  virtual bool get_txpool_tx_blob(const crypto::hash& txid, cryptonote::blobdata& bd, relay_category tx_category) const;
293  virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid, relay_category tx_category) const;
294  virtual uint32_t get_blockchain_pruning_seed() const;
295  virtual bool prune_blockchain(uint32_t pruning_seed = 0);
296  virtual bool update_pruning();
297  virtual bool check_pruning();
298 
299  virtual void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob);
300  virtual bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob);
301  virtual void remove_alt_block(const crypto::hash &blkid);
302  virtual uint64_t get_alt_block_count();
303  virtual void drop_alt_blocks();
304 
305  virtual bool for_all_txpool_txes(std::function<bool(const crypto::hash&, const txpool_tx_meta_t&, const cryptonote::blobdata_ref*)> f, bool include_blob = false, relay_category category = relay_category::broadcasted) const;
306 
307  virtual bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
308  virtual bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function<bool(uint64_t, const crypto::hash&, const cryptonote::block&)>) const;
309  virtual bool for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)>, bool pruned) const;
310  virtual bool for_all_outputs(std::function<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const;
311  virtual bool for_all_outputs(uint64_t amount, const std::function<bool(uint64_t height)> &f) const;
312  virtual bool for_all_alt_blocks(std::function<bool(const crypto::hash &blkid, const alt_block_data_t &data, const cryptonote::blobdata_ref *blob)> f, bool include_blob = false) const;
313 
314  virtual uint64_t add_block( const std::pair<block, blobdata>& blk
315  , size_t block_weight
316  , uint64_t long_term_block_weight
317  , const difficulty_type& cumulative_difficulty
318  , const uint64_t& coins_generated
319  , const std::vector<std::pair<transaction, blobdata>>& txs
320  );
321 
322  virtual void set_batch_transactions(bool batch_transactions);
323  virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0);
324  virtual void batch_commit();
325  virtual void batch_stop();
326  virtual void batch_abort();
327 
328  virtual void block_wtxn_start();
329  virtual void block_wtxn_stop();
330  virtual void block_wtxn_abort();
331  virtual bool block_rtxn_start() const;
332  virtual void block_rtxn_stop() const;
333  virtual void block_rtxn_abort() const;
334 
335  bool block_rtxn_start(MDB_txn **mtxn, mdb_txn_cursors **mcur) const;
336 
337  virtual void pop_block(block& blk, std::vector<transaction>& txs);
338 
339  virtual bool can_thread_bulk_indices() const { return true; }
340 
351  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) const;
352 
353  bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, std::vector<uint64_t> &distribution, uint64_t &base) const;
354 
355  // helper functions
356  static int compare_uint64(const MDB_val *a, const MDB_val *b);
357  static int compare_hash32(const MDB_val *a, const MDB_val *b);
358  static int compare_string(const MDB_val *a, const MDB_val *b);
359 
360 private:
361  void check_mmap_support();
362  void do_resize(uint64_t size_increase=0);
363 
364  bool need_resize(uint64_t threshold_size=0) const;
365  void check_and_resize_for_batch(uint64_t batch_num_blocks, uint64_t batch_bytes);
366  uint64_t get_estimated_batch_size(uint64_t batch_num_blocks, uint64_t batch_bytes) const;
367 
368  virtual void add_block( const block& blk
369  , size_t block_weight
370  , uint64_t long_term_block_weight
371  , const difficulty_type& cumulative_difficulty
372  , const uint64_t& coins_generated
373  , uint64_t num_rct_outs
374  , const crypto::hash& block_hash
375  );
376 
377  virtual void remove_block();
378 
379  virtual uint64_t add_transaction_data(const crypto::hash& blk_hash, const std::pair<transaction, blobdata_ref>& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prunable_hash);
380 
381  virtual void remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx);
382 
383  virtual uint64_t add_output(const crypto::hash& tx_hash,
384  const tx_out& tx_output,
385  const uint64_t& local_index,
386  const uint64_t unlock_time,
387  const rct::key *commitment
388  );
389 
390  virtual void add_tx_amount_output_indices(const uint64_t tx_id,
391  const std::vector<uint64_t>& amount_output_indices
392  );
393 
394  void remove_tx_outputs(const uint64_t tx_id, const transaction& tx);
395 
396  void remove_output(const uint64_t amount, const uint64_t& out_index);
397 
398  virtual void prune_outputs(uint64_t amount);
399 
400  virtual void add_spent_key(const crypto::key_image& k_image);
401 
402  virtual void remove_spent_key(const crypto::key_image& k_image);
403 
404  uint64_t num_outputs() const;
405 
406  // Hard fork
407  virtual void set_hard_fork_version(uint64_t height, uint8_t version);
408  virtual uint8_t get_hard_fork_version(uint64_t height) const;
409  virtual void check_hard_fork_info();
410  virtual void drop_hard_fork_info();
411 
412  inline void check_open() const;
413 
414  bool prune_worker(int mode, uint32_t pruning_seed);
415 
416  virtual bool is_read_only() const;
417 
418  virtual uint64_t get_database_size() const;
419 
420  std::vector<uint64_t> get_block_info_64bit_fields(uint64_t start_height, size_t count, off_t offset) const;
421 
422  uint64_t get_max_block_size();
423  void add_max_block_size(uint64_t sz);
424 
425  // fix up anything that may be wrong due to past bugs
426  virtual void fixup();
427 
428  // migrate from older DB version to current
429  void migrate(const uint32_t oldversion);
430 
431  // migrate from DB version 0 to 1
432  void migrate_0_1();
433 
434  // migrate from DB version 1 to 2
435  void migrate_1_2();
436 
437  // migrate from DB version 2 to 3
438  void migrate_2_3();
439 
440  // migrate from DB version 3 to 4
441  void migrate_3_4();
442 
443  // migrate from DB version 4 to 5
444  void migrate_4_5();
445 
446  void cleanup_batch();
447 
448 private:
449  MDB_env* m_env;
450 
451  MDB_dbi m_blocks;
453  MDB_dbi m_block_info;
454 
455  MDB_dbi m_txs;
456  MDB_dbi m_txs_pruned;
457  MDB_dbi m_txs_prunable;
460  MDB_dbi m_tx_indices;
461  MDB_dbi m_tx_outputs;
462 
463  MDB_dbi m_output_txs;
465 
466  MDB_dbi m_spent_keys;
467 
468  MDB_dbi m_txpool_meta;
469  MDB_dbi m_txpool_blob;
470 
471  MDB_dbi m_alt_blocks;
472 
474  MDB_dbi m_hf_versions;
475 
476  MDB_dbi m_properties;
477 
478  mutable uint64_t m_cum_size; // used in batch size estimation
479  mutable unsigned int m_cum_count;
480  std::string m_folder;
481  mdb_txn_safe* m_write_txn; // may point to either a short-lived txn or a batch txn
482  mdb_txn_safe* m_write_batch_txn; // persist batch txn outside of BlockchainLMDB
483  boost::thread::id m_writer;
484 
485  bool m_batch_transactions; // support for batch transactions
486  bool m_batch_active; // whether batch transaction is in progress
487 
489  mutable boost::thread_specific_ptr<mdb_threadinfo> m_tinfo;
490 
491 #if defined(__arm__)
492  // force a value so it can compile with 32-bit ARM
493  constexpr static uint64_t DEFAULT_MAPSIZE = 1LL << 31;
494 #else
495 #if defined(ENABLE_AUTO_RESIZE)
496  constexpr static uint64_t DEFAULT_MAPSIZE = 1LL << 30;
497 #else
498  constexpr static uint64_t DEFAULT_MAPSIZE = 1LL << 33;
499 #endif
500 #endif
501 
502  constexpr static float RESIZE_PERCENT = 0.9f;
503 };
504 
505 } // namespace cryptonote
cryptonote::mdb_rflags::m_rf_blocks
bool m_rf_blocks
Definition: db_lmdb.h:99
cryptonote::BlockchainLMDB::get_output_tx_and_index_from_global
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t &index) const
gets an output's tx hash and index
Definition: db_lmdb.cpp:3444
cryptonote::BlockchainLMDB::prune_worker
bool prune_worker(int mode, uint32_t pruning_seed)
Definition: db_lmdb.cpp:2013
cryptonote::mdb_txn_cursors::m_txc_txpool_blob
MDB_cursor * m_txc_txpool_blob
Definition: db_lmdb.h:68
cryptonote::BlockchainLMDB::get_max_block_size
uint64_t get_max_block_size()
get the max block size
Definition: db_lmdb.cpp:2674
cryptonote::BlockchainLMDB::get_pruned_tx_blobs_from
virtual bool get_pruned_tx_blobs_from(const crypto::hash &h, size_t count, std::vector< cryptonote::blobdata > &bd) const
fetches a number of pruned transaction blob from the given hash, in canonical blockchain order
Definition: db_lmdb.cpp:3132
cryptonote::BlockchainLMDB::m_blocks
MDB_dbi m_blocks
Definition: db_lmdb.h:451
cryptonote::BlockchainLMDB::for_all_transactions
virtual bool for_all_transactions(std::function< bool(const crypto::hash &, const cryptonote::transaction &)>, bool pruned) const
runs a function over all transactions stored
Definition: db_lmdb.cpp:3623
cryptonote::mdb_txn_safe::num_active_tx
uint64_t num_active_tx() const
Definition: db_lmdb.cpp:450
cryptonote::mdb_rflags::m_rf_txs_pruned
bool m_rf_txs_pruned
Definition: db_lmdb.h:105
cryptonote::BlockchainLMDB::for_all_txpool_txes
virtual bool for_all_txpool_txes(std::function< bool(const crypto::hash &, const txpool_tx_meta_t &, const cryptonote::blobdata_ref *)> f, bool include_blob=false, relay_category category=relay_category::broadcasted) const
runs a function over all txpool transactions
Definition: db_lmdb.cpp:2311
cryptonote::BlockchainLMDB::remove_output
void remove_output(const uint64_t amount, const uint64_t &out_index)
Definition: db_lmdb.cpp:1135
cryptonote::BlockchainLMDB::get_output_key
virtual output_data_t get_output_key(const uint64_t &amount, const uint64_t &index, bool include_commitmemt) const
get some of an output's data
Definition: db_lmdb.cpp:3410
cryptonote::BlockchainLMDB::migrate_1_2
void migrate_1_2()
Definition: db_lmdb.cpp:5101
cryptonote::mdb_rflags::m_rf_hf_versions
bool m_rf_hf_versions
Definition: db_lmdb.h:115
cryptonote::BlockchainLMDB::get_block_cumulative_rct_outputs
virtual std::vector< uint64_t > get_block_cumulative_rct_outputs(const std::vector< uint64_t > &heights) const
fetch a block's cumulative number of rct outputs
Definition: db_lmdb.cpp:2520
cryptonote::BlockchainLMDB::reset
virtual void reset()
Remove everything from the BlockchainDB.
Definition: db_lmdb.cpp:1604
cryptonote::BlockchainLMDB::get_tx_count
virtual uint64_t get_tx_count() const
fetches the total number of transactions ever
Definition: db_lmdb.cpp:3332
cryptonote::BlockchainLMDB::migrate
void migrate(const uint32_t oldversion)
Definition: db_lmdb.cpp:5665
cryptonote::mdb_txn_safe::prevent_new_txns
static void prevent_new_txns()
Definition: db_lmdb.cpp:455
cryptonote::mdb_txn_safe::mdb_txn_safe
mdb_txn_safe(const bool check=true)
Definition: db_lmdb.cpp:375
cryptonote::BlockchainLMDB::remove_alt_block
virtual void remove_alt_block(const crypto::hash &blkid)
remove an alternative block
Definition: db_lmdb.cpp:4452
cryptonote::BlockchainLMDB::batch_abort
virtual void batch_abort()
aborts a batch transaction
Definition: db_lmdb.cpp:3871
cryptonote::BlockchainLMDB::close
virtual void close()
close the BlockchainDB
Definition: db_lmdb.cpp:1566
base
Definition: base.py:1
cryptonote::BlockchainLMDB::block_wtxn_start
virtual void block_wtxn_start()
Definition: db_lmdb.cpp:3957
cryptonote::BlockchainLMDB::compare_string
static int compare_string(const MDB_val *a, const MDB_val *b)
Definition: db_lmdb.cpp:169
cryptonote::mdb_txn_cursors::m_txc_tx_indices
MDB_cursor * m_txc_tx_indices
Definition: db_lmdb.h:62
cryptonote::BlockchainLMDB::remove_spent_key
virtual void remove_spent_key(const crypto::key_image &k_image)
remove a spent key
Definition: db_lmdb.cpp:1244
cryptonote::BlockchainLMDB::~BlockchainLMDB
~BlockchainLMDB()
Definition: db_lmdb.cpp:1264
rct::key
Definition: rctTypes.h:79
cryptonote::mdb_rflags::m_rf_output_txs
bool m_rf_output_txs
Definition: db_lmdb.h:102
cryptonote::BlockchainLMDB::get_txpool_tx_meta
virtual bool get_txpool_tx_meta(const crypto::hash &txid, txpool_tx_meta_t &meta) const
get a txpool transaction's metadata
Definition: db_lmdb.cpp:1912
cryptonote::BlockchainLMDB::get_database_size
virtual uint64_t get_database_size() const
get disk space requirements
Definition: db_lmdb.cpp:4518
cryptonote::mdb_rflags::m_rf_txs_prunable
bool m_rf_txs_prunable
Definition: db_lmdb.h:106
cryptonote::BlockchainLMDB::get_block_blob
virtual cryptonote::blobdata get_block_blob(const crypto::hash &h) const
fetches the block with the given hash
Definition: db_lmdb.cpp:2433
cryptonote::tx_out
Definition: cryptonote_basic.h:143
cryptonote::BlockchainLMDB::drop_hard_fork_info
virtual void drop_hard_fork_info()
delete hard fork info from database
Definition: db_lmdb.cpp:4346
cryptonote::BlockchainLMDB::remove_data_file
virtual bool remove_data_file(const std::string &folder) const
remove file(s) storing the database
Definition: db_lmdb.cpp:1670
cryptonote::BlockchainLMDB::get_estimated_batch_size
uint64_t get_estimated_batch_size(uint64_t batch_num_blocks, uint64_t batch_bytes) const
Definition: db_lmdb.cpp:669
cryptonote::mdb_txn_safe::allow_new_txns
static void allow_new_txns()
Definition: db_lmdb.cpp:465
cryptonote::BlockchainLMDB::open
virtual void open(const std::string &filename, const int mdb_flags=0)
open a db, or create it if necessary.
Definition: db_lmdb.cpp:1317
cryptonote::mdb_rflags::m_rf_txs_prunable_hash
bool m_rf_txs_prunable_hash
Definition: db_lmdb.h:107
cryptonote::BlockchainLMDB::cleanup_batch
void cleanup_batch()
Definition: db_lmdb.cpp:3832
cryptonote::BlockchainLMDB::get_prunable_tx_blob
virtual bool get_prunable_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const
fetches the prunable transaction blob with the given hash
Definition: db_lmdb.cpp:3272
cryptonote::BlockchainLMDB::m_block_heights
MDB_dbi m_block_heights
Definition: db_lmdb.h:452
cryptonote::BlockchainLMDB::add_alt_block
virtual void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob)
add a new alternative block
Definition: db_lmdb.cpp:4401
cryptonote::BlockchainLMDB::has_key_image
virtual bool has_key_image(const crypto::key_image &img) const
check if a key image is stored as spent
Definition: db_lmdb.cpp:3523
cryptonote::mdb_txn_cursors::m_txc_spent_keys
MDB_cursor * m_txc_spent_keys
Definition: db_lmdb.h:65
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::mdb_txn_safe::creation_gate
static std::atomic_flag creation_gate
Definition: db_lmdb.h:165
cryptonote::BlockchainLMDB::block_exists
virtual bool block_exists(const crypto::hash &h, uint64_t *height=NULL) const
checks if a block exists
Definition: db_lmdb.cpp:2402
cryptonote::BlockchainLMDB::remove_tx_outputs
void remove_tx_outputs(const uint64_t tx_id, const transaction &tx)
Definition: db_lmdb.cpp:1112
cryptonote::BlockchainLMDB::sync
virtual void sync()
sync the BlockchainDB with disk
Definition: db_lmdb.cpp:1582
cryptonote::BlockchainLMDB::add_tx_amount_output_indices
virtual void add_tx_amount_output_indices(const uint64_t tx_id, const std::vector< uint64_t > &amount_output_indices)
store amount output indices for a tx's outputs
Definition: db_lmdb.cpp:1089
cryptonote::BlockchainLMDB::remove_block
virtual void remove_block()
remove data about the top block
Definition: db_lmdb.cpp:822
cryptonote::BlockchainLMDB::migrate_4_5
void migrate_4_5()
Definition: db_lmdb.cpp:5538
cryptonote::BlockchainLMDB::add_output
virtual uint64_t add_output(const crypto::hash &tx_hash, const tx_out &tx_output, const uint64_t &local_index, const uint64_t unlock_time, const rct::key *commitment)
store an output
Definition: db_lmdb.cpp:1023
cryptonote::mdb_rflags::m_rf_txs_prunable_tip
bool m_rf_txs_prunable_tip
Definition: db_lmdb.h:108
cryptonote::BlockchainLMDB::migrate_0_1
void migrate_0_1()
Definition: db_lmdb.cpp:4559
cryptonote::mdb_rflags::m_rf_block_heights
bool m_rf_block_heights
Definition: db_lmdb.h:100
cryptonote::BlockchainLMDB::get_prunable_tx_hash
virtual bool get_prunable_tx_hash(const crypto::hash &tx_hash, crypto::hash &prunable_hash) const
fetches the prunable transaction hash
Definition: db_lmdb.cpp:3302
cryptonote::BlockchainLMDB::get_block_already_generated_coins
virtual uint64_t get_block_already_generated_coins(const uint64_t &height) const
fetch a block's already generated coins
Definition: db_lmdb.cpp:2816
cryptonote::blobdata_ref
boost::string_ref blobdata_ref
Definition: blobdatatype.h:40
cryptonote::mdb_txn_cursors::m_txc_txs_prunable_hash
MDB_cursor * m_txc_txs_prunable_hash
Definition: db_lmdb.h:60
cryptonote::BlockchainLMDB::compare_uint64
static int compare_uint64(const MDB_val *a, const MDB_val *b)
Definition: db_lmdb.cpp:147
cryptonote::BlockchainLMDB::m_cum_count
unsigned int m_cum_count
Definition: db_lmdb.h:479
rctTypes.h
cryptonote::relay_category
relay_category
Definition: blockchain_db.h:110
cryptonote::mdb_txn_cursors::m_txc_txs_prunable
MDB_cursor * m_txc_txs_prunable
Definition: db_lmdb.h:59
cryptonote::BlockchainLMDB::check_and_resize_for_batch
void check_and_resize_for_batch(uint64_t batch_num_blocks, uint64_t batch_bytes)
Definition: db_lmdb.cpp:637
cryptonote::BlockchainLMDB::get_block_long_term_weight
virtual uint64_t get_block_long_term_weight(const uint64_t &height) const
fetch a block's long term weight
Definition: db_lmdb.cpp:2839
cryptonote::BlockchainLMDB::block_wtxn_abort
virtual void block_wtxn_abort()
Definition: db_lmdb.cpp:4012
cryptonote::BlockchainLMDB::batch_start
virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0)
tells the BlockchainDB to start a new "batch" of blocks
Definition: db_lmdb.cpp:3762
cryptonote::BlockchainLMDB::top_block_hash
virtual crypto::hash top_block_hash(uint64_t *block_height=NULL) const
fetch the top block's hash
Definition: db_lmdb.cpp:2913
cryptonote::mdb_txn_safe::wait_no_active_txns
static void wait_no_active_txns()
Definition: db_lmdb.cpp:460
cryptonote::mdb_txn_cursors::m_txc_tx_outputs
MDB_cursor * m_txc_tx_outputs
Definition: db_lmdb.h:63
cryptonote::mdb_txn_cursors::m_txc_block_info
MDB_cursor * m_txc_block_info
Definition: db_lmdb.h:52
cryptonote::mdb_threadinfo
Definition: db_lmdb.h:120
cryptonote::BlockchainLMDB::unlock
virtual void unlock()
This function releases the BlockchainDB lock.
Definition: db_lmdb.cpp:1701
cryptonote::BlockchainLMDB::batch_stop
virtual void batch_stop()
ends a batch transaction
Definition: db_lmdb.cpp:3842
cryptonote::BlockchainLMDB::m_hf_versions
MDB_dbi m_hf_versions
Definition: db_lmdb.h:474
cryptonote::BlockchainLMDB::lock
virtual bool lock()
acquires the BlockchainDB lock
Definition: db_lmdb.cpp:1693
cryptonote::BlockchainLMDB::get_block_info_64bit_fields
std::vector< uint64_t > get_block_info_64bit_fields(uint64_t start_height, size_t count, off_t offset) const
Definition: db_lmdb.cpp:2620
cryptonote::BlockchainLMDB::correct_block_cumulative_difficulties
virtual void correct_block_cumulative_difficulties(const uint64_t &start_height, const std::vector< difficulty_type > &new_cumulative_difficulties)
correct blocks cumulative difficulties that were incorrectly calculated due to the 'difficulty drift'...
Definition: db_lmdb.cpp:2778
cryptonote::BlockchainLMDB::update_pruning
virtual bool update_pruning()
prunes recent blockchain changes as needed, iff pruning is enabled
Definition: db_lmdb.cpp:2301
cryptonote::BlockchainLMDB::add_block
virtual uint64_t add_block(const std::pair< block, blobdata > &blk, size_t block_weight, uint64_t long_term_block_weight, const difficulty_type &cumulative_difficulty, const uint64_t &coins_generated, const std::vector< std::pair< transaction, blobdata >> &txs)
handles the addition of a new block to BlockchainDB
Definition: db_lmdb.cpp:4035
cryptonote::mdb_txn_safe::~mdb_txn_safe
~mdb_txn_safe()
Definition: db_lmdb.cpp:385
cryptonote::BlockchainLMDB::for_all_outputs
virtual bool for_all_outputs(std::function< bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const
runs a function over all outputs stored
Definition: db_lmdb.cpp:3686
cryptonote::mdb_txn_safe::m_check
bool m_check
Definition: db_lmdb.h:161
cryptonote::BlockchainLMDB::check_mmap_support
void check_mmap_support()
Definition: db_lmdb.cpp:1297
cryptonote::BlockchainLMDB::get_block_timestamp
virtual uint64_t get_block_timestamp(const uint64_t &height) const
fetch a block's timestamp
Definition: db_lmdb.cpp:2497
cryptonote::BlockchainLMDB::get_block_cumulative_difficulty
virtual difficulty_type get_block_cumulative_difficulty(const uint64_t &height) const
fetch a block's cumulative difficulty
Definition: db_lmdb.cpp:2736
cryptonote::BlockchainLMDB::m_properties
MDB_dbi m_properties
Definition: db_lmdb.h:476
cryptonote::BlockchainLMDB::m_txpool_blob
MDB_dbi m_txpool_blob
Definition: db_lmdb.h:469
cryptonote::BlockchainLMDB::add_spent_key
virtual void add_spent_key(const crypto::key_image &k_image)
store a spent key
Definition: db_lmdb.cpp:1227
cryptonote::BlockchainLMDB::get_tx_blob
virtual bool get_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const
fetches the transaction blob with the given hash
Definition: db_lmdb.cpp:3066
base.b
int b
Definition: base.py:1
cryptonote::BlockchainLMDB::get_tx_unlock_time
virtual uint64_t get_tx_unlock_time(const crypto::hash &h) const
fetch a transaction's unlock time/height
Definition: db_lmdb.cpp:3045
cryptonote::BlockchainLMDB::m_hf_starting_heights
MDB_dbi m_hf_starting_heights
Definition: db_lmdb.h:473
lmdb::stream::count
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
cryptonote::BlockchainLMDB::for_blocks_range
virtual bool for_blocks_range(const uint64_t &h1, const uint64_t &h2, std::function< bool(uint64_t, const crypto::hash &, const cryptonote::block &)>) const
runs a function over a range of blocks
Definition: db_lmdb.cpp:3573
cryptonote::BlockchainLMDB::m_tx_outputs
MDB_dbi m_tx_outputs
Definition: db_lmdb.h:461
cryptonote::mdb_txn_safe::m_batch_txn
bool m_batch_txn
Definition: db_lmdb.h:160
cryptonote::BlockchainLMDB::DEFAULT_MAPSIZE
constexpr static uint64_t DEFAULT_MAPSIZE
Definition: db_lmdb.h:496
cryptonote::mdb_txn_cursors::m_txc_properties
MDB_cursor * m_txc_properties
Definition: db_lmdb.h:74
cryptonote::BlockchainLMDB::get_blocks_range
virtual std::vector< block > get_blocks_range(const uint64_t &h1, const uint64_t &h2) const
fetch a list of blocks
Definition: db_lmdb.cpp:2885
cryptonote::txindex::key
crypto::hash key
Definition: db_lmdb.h:44
cryptonote::BlockchainLMDB::m_alt_blocks
MDB_dbi m_alt_blocks
Definition: db_lmdb.h:471
cryptonote::BlockchainLMDB::batch_commit
virtual void batch_commit()
Definition: db_lmdb.cpp:3805
cryptonote::BlockchainLMDB::get_block_blob_from_height
virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t &height) const
fetch a block blob by height
Definition: db_lmdb.cpp:2471
cryptonote::BlockchainLMDB
Definition: db_lmdb.h:183
cryptonote::BlockchainLMDB::get_block_hash_from_height
virtual crypto::hash get_block_hash_from_height(const uint64_t &height) const
fetch a block's hash
Definition: db_lmdb.cpp:2862
cryptonote::BlockchainLMDB::get_top_block_timestamp
virtual uint64_t get_top_block_timestamp() const
fetch the top block's timestamp
Definition: db_lmdb.cpp:2582
cryptonote::BlockchainLMDB::get_block_difficulty
virtual difficulty_type get_block_difficulty(const uint64_t &height) const
fetch a block's difficulty
Definition: db_lmdb.cpp:2761
cryptonote::txindex::data
tx_data_t data
Definition: db_lmdb.h:45
cryptonote::mdb_txn_cursors::m_txc_output_txs
MDB_cursor * m_txc_output_txs
Definition: db_lmdb.h:54
cryptonote::mdb_txn_cursors::m_txc_hf_versions
MDB_cursor * m_txc_hf_versions
Definition: db_lmdb.h:72
cryptonote::BlockchainLMDB::m_env
MDB_env * m_env
Definition: db_lmdb.h:449
blocks
Definition: blocks.cpp:13
cryptonote::BlockchainLMDB::get_pruned_tx_blob
virtual bool get_pruned_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const
fetches the pruned transaction blob with the given hash
Definition: db_lmdb.cpp:3102
cryptonote::mdb_txn_cursors::m_txc_output_amounts
MDB_cursor * m_txc_output_amounts
Definition: db_lmdb.h:55
cryptonote::BlockchainLMDB::can_thread_bulk_indices
virtual bool can_thread_bulk_indices() const
Definition: db_lmdb.h:339
cryptonote::block
Definition: cryptonote_basic.h:464
cryptonote::tx_out_index
std::pair< crypto::hash, uint64_t > tx_out_index
Definition: blockchain_db.h:104
cryptonote::mdb_rflags::m_rf_txs
bool m_rf_txs
Definition: db_lmdb.h:104
net::socks::version
version
Supported socks variants.
Definition: socks.h:58
cryptonote::BlockchainLMDB::prune_blockchain
virtual bool prune_blockchain(uint32_t pruning_seed=0)
prunes the blockchain
Definition: db_lmdb.cpp:2296
cryptonote::BlockchainLMDB::fixup
virtual void fixup()
fix up anything that may be wrong due to past bugs
Definition: db_lmdb.cpp:4528
cryptonote::mdb_threadinfo::m_ti_rtxn
MDB_txn * m_ti_rtxn
Definition: db_lmdb.h:121
cryptonote::BlockchainLMDB::get_output_tx_and_index
virtual tx_out_index get_output_tx_and_index(const uint64_t &amount, const uint64_t &index) const
gets an output's tx hash and index
Definition: db_lmdb.cpp:3467
cryptonote::txindex
Definition: db_lmdb.h:43
cryptonote::mdb_txn_safe::abort
void abort()
Definition: db_lmdb.cpp:436
cryptonote
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
cryptonote::BlockchainLMDB::add_max_block_size
void add_max_block_size(uint64_t sz)
add a new max block size
Definition: db_lmdb.cpp:2696
cryptonote::alt_block_data_t
Definition: blockchain_db.h:143
cryptonote::BlockchainLMDB::m_tinfo
boost::thread_specific_ptr< mdb_threadinfo > m_tinfo
Definition: db_lmdb.h:489
cryptonote::mdb_txn_cursors
struct cryptonote::mdb_txn_cursors mdb_txn_cursors
cryptonote::BlockchainLMDB::get_block_weights
virtual std::vector< uint64_t > get_block_weights(uint64_t start_height, size_t count) const
fetch the last N blocks' weights
Definition: db_lmdb.cpp:2726
cryptonote::BlockchainLMDB::m_txpool_meta
MDB_dbi m_txpool_meta
Definition: db_lmdb.h:468
cryptonote::BlockchainLMDB::get_tx_block_height
virtual uint64_t get_tx_block_height(const crypto::hash &h) const
fetches the height of a transaction's block
Definition: db_lmdb.cpp:3363
cryptonote::mdb_rflags::m_rf_alt_blocks
bool m_rf_alt_blocks
Definition: db_lmdb.h:114
cryptonote::BlockchainLMDB::drop_alt_blocks
virtual void drop_alt_blocks()
drop all alternative blocks
Definition: db_lmdb.cpp:4491
cryptonote::BlockchainLMDB::do_resize
void do_resize(uint64_t size_increase=0)
Definition: db_lmdb.cpp:521
cryptonote::mdb_txn_cursors::m_txc_txs_prunable_tip
MDB_cursor * m_txc_txs_prunable_tip
Definition: db_lmdb.h:61
cryptonote::mdb_rflags
Definition: db_lmdb.h:97
cryptonote::BlockchainLMDB::migrate_2_3
void migrate_2_3()
Definition: db_lmdb.cpp:5242
blobdatatype.h
cryptonote::BlockchainLMDB::get_hard_fork_version
virtual uint8_t get_hard_fork_version(uint64_t height) const
checks which hardfork version a height is on
Definition: db_lmdb.cpp:4382
cryptonote::mdb_rflags
struct cryptonote::mdb_rflags mdb_rflags
cryptonote::BlockchainLMDB::RESIZE_PERCENT
constexpr static float RESIZE_PERCENT
Definition: db_lmdb.h:502
cryptonote::mdb_txn_safe
Definition: db_lmdb.h:129
cryptonote::mdb_txn_safe::commit
void commit(std::string message="")
Definition: db_lmdb.cpp:421
cryptonote::BlockchainLMDB::safesyncmode
virtual void safesyncmode(const bool onoff)
toggle safe syncs for the DB
Definition: db_lmdb.cpp:1598
cryptonote::mdb_rflags::m_rf_txpool_blob
bool m_rf_txpool_blob
Definition: db_lmdb.h:113
cryptonote::BlockchainLMDB::get_top_block
virtual block get_top_block() const
fetch the top block
Definition: db_lmdb.cpp:2928
cryptonote::BlockchainLMDB::is_read_only
virtual bool is_read_only() const
is BlockchainDB in read-only mode?
Definition: db_lmdb.cpp:4505
cryptonote::BlockchainLMDB::get_num_outputs
virtual uint64_t get_num_outputs(const uint64_t &amount) const
fetches the number of outputs of a given amount
Definition: db_lmdb.cpp:3386
cryptonote::BlockchainLMDB::get_block_height
virtual uint64_t get_block_height(const crypto::hash &h) const
gets the height of the block with a given hash
Definition: db_lmdb.cpp:2441
cryptonote::mdb_rflags::m_rf_txpool_meta
bool m_rf_txpool_meta
Definition: db_lmdb.h:112
cryptonote::mdb_txn_cursors::m_txc_txpool_meta
MDB_cursor * m_txc_txpool_meta
Definition: db_lmdb.h:67
cryptonote::BlockchainLMDB::get_txpool_tx_count
virtual uint64_t get_txpool_tx_count(relay_category category=relay_category::broadcasted) const
get the number of transactions in the txpool
Definition: db_lmdb.cpp:1811
cryptonote::txpool_tx_meta_t
a struct containing txpool per transaction metadata
Definition: blockchain_db.h:155
cryptonote::BlockchainLMDB::for_all_key_images
virtual bool for_all_key_images(std::function< bool(const crypto::key_image &)>) const
runs a function over all key images stored
Definition: db_lmdb.cpp:3540
cryptonote::BlockchainLMDB::get_output_distribution
bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, std::vector< uint64_t > &distribution, uint64_t &base) const
Definition: db_lmdb.cpp:4295
cryptonote::BlockchainLMDB::check_pruning
virtual bool check_pruning()
checks pruning was done correctly, iff enabled
Definition: db_lmdb.cpp:2306
cryptonote::BlockchainLMDB::m_txs_pruned
MDB_dbi m_txs_pruned
Definition: db_lmdb.h:456
cryptonote::BlockchainLMDB::m_txs
MDB_dbi m_txs
Definition: db_lmdb.h:455
cryptonote::BlockchainLMDB::m_batch_transactions
bool m_batch_transactions
Definition: db_lmdb.h:485
cryptonote::BlockchainLMDB::get_blocks_from
virtual bool get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector< std::pair< std::pair< cryptonote::blobdata, crypto::hash >, std::vector< std::pair< crypto::hash, cryptonote::blobdata >>>> &blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const
fetches a variable number of blocks and transactions from the given height, in canonical blockchain o...
Definition: db_lmdb.cpp:3174
cryptonote::blobdata
std::string blobdata
Definition: blobdatatype.h:39
cryptonote::BlockchainLMDB::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) const
return a histogram of outputs on the blockchain
Definition: db_lmdb.cpp:4202
cryptonote::BlockchainLMDB::BlockchainLMDB
BlockchainLMDB(bool batch_transactions=true)
Definition: db_lmdb.cpp:1278
cryptonote::BlockchainLMDB::set_batch_transactions
virtual void set_batch_transactions(bool batch_transactions)
sets whether or not to batch transactions
Definition: db_lmdb.cpp:3894
cryptonote::BlockchainLMDB::need_resize
bool need_resize(uint64_t threshold_size=0) const
Definition: db_lmdb.cpp:590
cryptonote::BlockchainLMDB::get_hashes_range
virtual std::vector< crypto::hash > get_hashes_range(const uint64_t &h1, const uint64_t &h2) const
fetch a list of block hashes
Definition: db_lmdb.cpp:2899
cryptonote::mdb_threadinfo::~mdb_threadinfo
~mdb_threadinfo()
Definition: db_lmdb.cpp:364
cryptonote::BlockchainLMDB::m_wcursors
mdb_txn_cursors m_wcursors
Definition: db_lmdb.h:488
cryptonote::mdb_txn_cursors::m_txc_alt_blocks
MDB_cursor * m_txc_alt_blocks
Definition: db_lmdb.h:70
cryptonote::mdb_txn_safe::uncheck
void uncheck()
Definition: db_lmdb.cpp:415
cryptonote::mdb_txn_cursors
Definition: db_lmdb.h:49
cryptonote::mdb_threadinfo
struct cryptonote::mdb_threadinfo mdb_threadinfo
cryptonote::BlockchainLMDB::block_wtxn_stop
virtual void block_wtxn_stop()
Definition: db_lmdb.cpp:3990
cryptonote::BlockchainLMDB::num_outputs
uint64_t num_outputs() const
Definition: db_lmdb.cpp:2957
cryptonote::mdb_txn_safe::num_active_txns
static std::atomic< uint64_t > num_active_txns
Definition: db_lmdb.h:162
cryptonote::BlockchainLMDB::block_rtxn_start
virtual bool block_rtxn_start() const
Definition: db_lmdb.cpp:3950
cryptonote::BlockchainLMDB::for_all_alt_blocks
virtual bool for_all_alt_blocks(std::function< bool(const crypto::hash &blkid, const alt_block_data_t &data, const cryptonote::blobdata_ref *blob)> f, bool include_blob=false) const
runs a function over all alternative blocks stored
Definition: db_lmdb.cpp:2360
cryptonote::BlockchainLMDB::compare_hash32
static int compare_hash32(const MDB_val *a, const MDB_val *b)
Definition: db_lmdb.cpp:155
MakeCryptoOps.a
string a
Definition: MakeCryptoOps.py:15
cryptonote::BlockchainLMDB::get_filenames
virtual std::vector< std::string > get_filenames() const
get all files used by the BlockchainDB (if any)
Definition: db_lmdb.cpp:1654
cryptonote::BlockchainLMDB::get_blockchain_pruning_seed
virtual uint32_t get_blockchain_pruning_seed() const
get the blockchain pruning seed
Definition: db_lmdb.cpp:1978
cryptonote::BlockchainLMDB::get_db_name
virtual std::string get_db_name() const
gets the name of the folder the BlockchainDB's file(s) should be in
Definition: db_lmdb.cpp:1685
cryptonote::BlockchainLMDB::m_txs_prunable_hash
MDB_dbi m_txs_prunable_hash
Definition: db_lmdb.h:458
cryptonote::transaction
Definition: cryptonote_basic.h:194
cryptonote::BlockchainLMDB::txpool_has_tx
virtual bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const
check whether a txid is in the txpool and meets tx_category requirements
Definition: db_lmdb.cpp:1856
cryptonote::BlockchainLMDB::m_txs_prunable
MDB_dbi m_txs_prunable
Definition: db_lmdb.h:457
cryptonote::mdb_threadinfo::m_ti_rflags
mdb_rflags m_ti_rflags
Definition: db_lmdb.h:123
cryptonote::BlockchainLMDB::get_block_header
virtual block_header get_block_header(const crypto::hash &h) const
fetch a block header
Definition: db_lmdb.cpp:2462
cryptonote::mdb_txn_cursors::m_txc_blocks
MDB_cursor * m_txc_blocks
Definition: db_lmdb.h:50
cryptonote::mdb_txn_cursors::m_txc_txs
MDB_cursor * m_txc_txs
Definition: db_lmdb.h:57
cryptonote::BlockchainLMDB::remove_transaction_data
virtual void remove_transaction_data(const crypto::hash &tx_hash, const transaction &tx)
remove data about a transaction
Definition: db_lmdb.cpp:947
cryptonote::txindex
struct cryptonote::txindex txindex
cryptonote::BlockchainLMDB::m_batch_active
bool m_batch_active
Definition: db_lmdb.h:486
cryptonote::BlockchainLMDB::m_folder
std::string m_folder
Definition: db_lmdb.h:480
cryptonote::block_header
Definition: cryptonote_basic.h:447
cryptonote::BlockchainLMDB::get_block_weight
virtual size_t get_block_weight(const uint64_t &height) const
fetch a block's weight
Definition: db_lmdb.cpp:2597
cryptonote::BlockchainLMDB::height
virtual uint64_t height() const
fetch the current blockchain height
Definition: db_lmdb.cpp:2943
cryptonote::mdb_rflags::m_rf_block_info
bool m_rf_block_info
Definition: db_lmdb.h:101
cryptonote::BlockchainLMDB::get_txpool_tx_blob
virtual bool get_txpool_tx_blob(const crypto::hash &txid, cryptonote::blobdata &bd, relay_category tx_category) const
get a txpool transaction's blob
Definition: db_lmdb.cpp:1933
cryptonote::BlockchainLMDB::m_writer
boost::thread::id m_writer
Definition: db_lmdb.h:483
cryptonote::BlockchainLMDB::update_txpool_tx
virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta)
update a txpool transaction's metadata
Definition: db_lmdb.cpp:1785
cryptonote::BlockchainDB::pop_block
void pop_block()
private version of pop_block, for undoing if an add_block fails
Definition: blockchain_db.cpp:175
cryptonote::mdb_rflags::m_rf_output_amounts
bool m_rf_output_amounts
Definition: db_lmdb.h:103
cryptonote::mdb_threadinfo::m_ti_rcursors
mdb_txn_cursors m_ti_rcursors
Definition: db_lmdb.h:122
cryptonote::mdb_rflags::m_rf_tx_outputs
bool m_rf_tx_outputs
Definition: db_lmdb.h:110
cryptonote::mdb_txn_safe::m_tinfo
mdb_threadinfo * m_tinfo
Definition: db_lmdb.h:158
cryptonote::BlockchainLMDB::get_alt_block_count
virtual uint64_t get_alt_block_count()
get the number of alternative blocks stored
Definition: db_lmdb.cpp:4470
cryptonote::mdb_rflags::m_rf_properties
bool m_rf_properties
Definition: db_lmdb.h:116
cryptonote::mdb_rflags::m_rf_tx_indices
bool m_rf_tx_indices
Definition: db_lmdb.h:109
cryptonote::BlockchainLMDB::m_tx_indices
MDB_dbi m_tx_indices
Definition: db_lmdb.h:460
cryptonote::BlockchainLMDB::check_hard_fork_info
virtual void check_hard_fork_info()
verify hard fork info in database
Definition: db_lmdb.cpp:4342
cryptonote::BlockchainLMDB::block_rtxn_abort
virtual void block_rtxn_abort() const
Definition: db_lmdb.cpp:4028
crypto::key_image
POD_CLASS key_image
Definition: crypto.h:87
cryptonote::BlockchainLMDB::set_hard_fork_version
virtual void set_hard_fork_version(uint64_t height, uint8_t version)
sets which hardfork version a height is on
Definition: db_lmdb.cpp:4363
cryptonote::mdb_rflags::m_rf_spent_keys
bool m_rf_spent_keys
Definition: db_lmdb.h:111
cryptonote::mdb_rflags::m_rf_txn
bool m_rf_txn
Definition: db_lmdb.h:98
cryptonote::BlockchainLMDB::m_spent_keys
MDB_dbi m_spent_keys
Definition: db_lmdb.h:466
cryptonote::BlockchainLMDB::check_open
void check_open() const
Definition: db_lmdb.cpp:515
cryptonote::BlockchainLMDB::get_tx_list
virtual std::vector< transaction > get_tx_list(const std::vector< crypto::hash > &hlist) const
fetches a list of transactions based on their hashes
Definition: db_lmdb.cpp:3349
cryptonote::BlockchainLMDB::m_block_info
MDB_dbi m_block_info
Definition: db_lmdb.h:453
cryptonote::BlockchainLMDB::m_write_batch_txn
mdb_txn_safe * m_write_batch_txn
Definition: db_lmdb.h:482
cryptonote::BlockchainLMDB::migrate_3_4
void migrate_3_4()
Definition: db_lmdb.cpp:5378
cryptonote::BlockchainLMDB::add_txpool_tx
virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t &meta)
add a txpool transaction
Definition: db_lmdb.cpp:1759
cryptonote::BlockchainLMDB::m_cum_size
uint64_t m_cum_size
Definition: db_lmdb.h:478
cryptonote::BlockchainLMDB::m_output_txs
MDB_dbi m_output_txs
Definition: db_lmdb.h:463
blockchain_db.h
cryptonote::tx_data_t
Definition: blockchain_db.h:135
cryptonote::mdb_txn_cursors::m_txc_block_heights
MDB_cursor * m_txc_block_heights
Definition: db_lmdb.h:51
cryptonote::BlockchainLMDB::add_transaction_data
virtual uint64_t add_transaction_data(const crypto::hash &blk_hash, const std::pair< transaction, blobdata_ref > &tx, const crypto::hash &tx_hash, const crypto::hash &tx_prunable_hash)
store the transaction and its metadata
Definition: db_lmdb.cpp:859
cryptonote::BlockchainLMDB::block_rtxn_stop
virtual void block_rtxn_stop() const
Definition: db_lmdb.cpp:3943
cryptonote::BlockchainLMDB::m_output_amounts
MDB_dbi m_output_amounts
Definition: db_lmdb.h:464
cryptonote::BlockchainLMDB::remove_txpool_tx
virtual void remove_txpool_tx(const crypto::hash &txid)
remove a txpool transaction
Definition: db_lmdb.cpp:1882
cryptonote::BlockchainLMDB::m_txs_prunable_tip
MDB_dbi m_txs_prunable_tip
Definition: db_lmdb.h:459
cryptonote::output_data_t
a struct containing output metadata
Definition: blockchain_db.h:125
cryptonote::BlockchainLMDB::tx_exists
virtual bool tx_exists(const crypto::hash &h) const
check if a transaction with a given hash exists
Definition: db_lmdb.cpp:2979
cryptonote::mdb_txn_cursors::m_txc_txs_pruned
MDB_cursor * m_txc_txs_pruned
Definition: db_lmdb.h:58
cryptonote::mdb_txn_safe::m_txn
MDB_txn * m_txn
Definition: db_lmdb.h:159
cryptonote::BlockchainLMDB::prune_outputs
virtual void prune_outputs(uint64_t amount)
prune output data for the given amount
Definition: db_lmdb.cpp:1173
cryptonote::BlockchainLMDB::get_long_term_block_weights
virtual std::vector< uint64_t > get_long_term_block_weights(uint64_t start_height, size_t count) const
fetch the last N blocks' long term weights
Definition: db_lmdb.cpp:2731
cryptonote::BlockchainLMDB::get_tx_amount_output_indices
virtual std::vector< std::vector< uint64_t > > get_tx_amount_output_indices(const uint64_t tx_id, size_t n_txes) const
gets output indices (amount-specific) for a transaction's outputs
Definition: db_lmdb.cpp:3480
cryptonote::BlockchainLMDB::get_alt_block
virtual bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob)
get an alternative block by hash
Definition: db_lmdb.cpp:4423
crypto::hash
POD_CLASS hash
Definition: hash.h:48
cryptonote::BlockchainLMDB::m_write_txn
mdb_txn_safe * m_write_txn
Definition: db_lmdb.h:481