Monero
blockchain_db.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 #ifndef BLOCKCHAIN_DB_H
29 #define BLOCKCHAIN_DB_H
30 
31 #pragma once
32 
33 #include <string>
34 #include <exception>
35 #include <boost/program_options.hpp>
36 #include "common/command_line.h"
37 #include "crypto/hash.h"
43 
100 namespace cryptonote
101 {
102 
104 typedef std::pair<crypto::hash, uint64_t> tx_out_index;
105 
108 
109 enum class relay_category : uint8_t
110 {
111  broadcasted = 0,
112  relayable,
113  legacy,
114  all
115 };
116 
117 bool matches_category(relay_method method, relay_category category) noexcept;
118 
119 #pragma pack(push, 1)
120 
125 {
127  uint64_t unlock_time;
128  uint64_t height;
130 };
131 #pragma pack(pop)
132 
133 #pragma pack(push, 1)
134 struct tx_data_t
135 {
136  uint64_t tx_id;
137  uint64_t unlock_time;
138  uint64_t block_id;
139 };
140 #pragma pack(pop)
141 
143 {
144  uint64_t height;
149 };
150 
155 {
158  uint64_t weight;
159  uint64_t fee;
162  uint64_t receive_time;
163  uint64_t last_relayed_time;
164  // 112 bytes
165  uint8_t kept_by_block;
166  uint8_t relayed;
167  uint8_t do_not_relay;
168  uint8_t double_spend_seen: 1;
169  uint8_t pruned: 1;
170  uint8_t is_local: 1;
171  uint8_t dandelionpp_stem : 1;
172  uint8_t is_forwarding: 1;
173  uint8_t bf_padding: 3;
174 
175  uint8_t padding[76]; // till 192 bytes
176 
177  void set_relay_method(relay_method method) noexcept;
179 
181  bool upgrade_relay_method(relay_method method) noexcept;
182 
184  bool matches(const relay_category category) const noexcept
185  {
186  return matches_category(get_relay_method(), category);
187  }
188 };
189 
190 
191 #define DBF_SAFE 1
192 #define DBF_FAST 2
193 #define DBF_FASTEST 4
194 #define DBF_RDONLY 8
195 #define DBF_SALVAGE 0x10
196 
197 /***********************************
198  * Exception Definitions
199  ***********************************/
200 
204 class DB_EXCEPTION : public std::exception
205 {
206  private:
207  std::string m;
208 
209  protected:
210  DB_EXCEPTION(const char *s) : m(s) { }
211 
212  public:
213  virtual ~DB_EXCEPTION() { }
214 
215  const char* what() const throw()
216  {
217  return m.c_str();
218  }
219 };
220 
224 class DB_ERROR : public DB_EXCEPTION
225 {
226  public:
227  DB_ERROR() : DB_EXCEPTION("Generic DB Error") { }
228  DB_ERROR(const char* s) : DB_EXCEPTION(s) { }
229 };
230 
235 {
236  public:
237  DB_ERROR_TXN_START() : DB_EXCEPTION("DB Error in starting txn") { }
238  DB_ERROR_TXN_START(const char* s) : DB_EXCEPTION(s) { }
239 };
240 
245 {
246  public:
247  DB_OPEN_FAILURE() : DB_EXCEPTION("Failed to open the db") { }
248  DB_OPEN_FAILURE(const char* s) : DB_EXCEPTION(s) { }
249 };
250 
255 {
256  public:
257  DB_CREATE_FAILURE() : DB_EXCEPTION("Failed to create the db") { }
258  DB_CREATE_FAILURE(const char* s) : DB_EXCEPTION(s) { }
259 };
260 
265 {
266  public:
267  DB_SYNC_FAILURE() : DB_EXCEPTION("Failed to sync the db") { }
268  DB_SYNC_FAILURE(const char* s) : DB_EXCEPTION(s) { }
269 };
270 
274 class BLOCK_DNE : public DB_EXCEPTION
275 {
276  public:
277  BLOCK_DNE() : DB_EXCEPTION("The block requested does not exist") { }
278  BLOCK_DNE(const char* s) : DB_EXCEPTION(s) { }
279 };
280 
285 {
286  public:
287  BLOCK_PARENT_DNE() : DB_EXCEPTION("The parent of the block does not exist") { }
288  BLOCK_PARENT_DNE(const char* s) : DB_EXCEPTION(s) { }
289 };
290 
295 {
296  public:
297  BLOCK_EXISTS() : DB_EXCEPTION("The block to be added already exists!") { }
298  BLOCK_EXISTS(const char* s) : DB_EXCEPTION(s) { }
299 };
300 
305 {
306  public:
307  BLOCK_INVALID() : DB_EXCEPTION("The block to be added did not pass validation!") { }
308  BLOCK_INVALID(const char* s) : DB_EXCEPTION(s) { }
309 };
310 
314 class TX_DNE : public DB_EXCEPTION
315 {
316  public:
317  TX_DNE() : DB_EXCEPTION("The transaction requested does not exist") { }
318  TX_DNE(const char* s) : DB_EXCEPTION(s) { }
319 };
320 
324 class TX_EXISTS : public DB_EXCEPTION
325 {
326  public:
327  TX_EXISTS() : DB_EXCEPTION("The transaction to be added already exists!") { }
328  TX_EXISTS(const char* s) : DB_EXCEPTION(s) { }
329 };
330 
334 class OUTPUT_DNE : public DB_EXCEPTION
335 {
336  public:
337  OUTPUT_DNE() : DB_EXCEPTION("The output requested does not exist!") { }
338  OUTPUT_DNE(const char* s) : DB_EXCEPTION(s) { }
339 };
340 
345 {
346  public:
347  OUTPUT_EXISTS() : DB_EXCEPTION("The output to be added already exists!") { }
348  OUTPUT_EXISTS(const char* s) : DB_EXCEPTION(s) { }
349 };
350 
355 {
356  public:
357  KEY_IMAGE_EXISTS() : DB_EXCEPTION("The spent key image to be added already exists!") { }
358  KEY_IMAGE_EXISTS(const char* s) : DB_EXCEPTION(s) { }
359 };
360 
361 /***********************************
362  * End of Exception Definitions
363  ***********************************/
364 
365 
379 {
380 private:
381  /*********************************************************************
382  * private virtual members
383  *********************************************************************/
384 
402  virtual void add_block( const block& blk
403  , size_t block_weight
404  , uint64_t long_term_block_weight
405  , const difficulty_type& cumulative_difficulty
406  , const uint64_t& coins_generated
407  , uint64_t num_rct_outs
408  , const crypto::hash& blk_hash
409  ) = 0;
410 
421  virtual void remove_block() = 0;
422 
443  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) = 0;
444 
461  virtual void remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx) = 0;
462 
489  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) = 0;
490 
504  virtual void add_tx_amount_output_indices(const uint64_t tx_id, const std::vector<uint64_t>& amount_output_indices) = 0;
505 
516  virtual void add_spent_key(const crypto::key_image& k_image) = 0;
517 
528  virtual void remove_spent_key(const crypto::key_image& k_image) = 0;
529 
530 
531  /*********************************************************************
532  * private concrete members
533  *********************************************************************/
540  void pop_block();
541 
542  // helper function to remove transaction from blockchain
550  void remove_transaction(const crypto::hash& tx_hash);
551 
552  uint64_t num_calls = 0;
553  uint64_t time_blk_hash = 0;
554  uint64_t time_add_block1 = 0;
555  uint64_t time_add_transaction = 0;
556 
557 
558 protected:
559 
571  void add_transaction(const crypto::hash& blk_hash, const std::pair<transaction, blobdata_ref>& tx, const crypto::hash* tx_hash_ptr = NULL, const crypto::hash* tx_prunable_hash_ptr = NULL);
572 
573  mutable uint64_t time_tx_exists = 0;
574  uint64_t time_commit1 = 0;
575  bool m_auto_remove_logs = true;
576 
578 
579 public:
580 
585 
589  virtual ~BlockchainDB() { };
590 
594  static void init_options(boost::program_options::options_description& desc);
595 
599  void reset_stats();
600 
607  void show_stats();
608 
632  virtual void open(const std::string& filename, const int db_flags = 0) = 0;
633 
639  bool is_open() const;
640 
651  virtual void close() = 0;
652 
664  virtual void sync() = 0;
665 
671  virtual void safesyncmode(const bool onoff) = 0;
672 
683  virtual void reset() = 0;
684 
694  virtual std::vector<std::string> get_filenames() const = 0;
695 
708  virtual bool remove_data_file(const std::string& folder) const = 0;
709 
710  // return the name of the folder the db's file(s) should reside in
719  virtual std::string get_db_name() const = 0;
720 
721 
722  // FIXME: these are just for functionality mocking, need to implement
723  // RAII-friendly and multi-read one-write friendly locking mechanism
724  //
725  // acquire db lock
741  virtual bool lock() = 0;
742 
743  // release db lock
754  virtual void unlock() = 0;
755 
775  virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0) = 0;
776 
790  virtual void batch_stop() = 0;
791 
805  virtual void batch_abort() = 0;
806 
822  virtual void set_batch_transactions(bool) = 0;
823 
824  virtual void block_wtxn_start() = 0;
825  virtual void block_wtxn_stop() = 0;
826  virtual void block_wtxn_abort() = 0;
827  virtual bool block_rtxn_start() const = 0;
828  virtual void block_rtxn_stop() const = 0;
829  virtual void block_rtxn_abort() const = 0;
830 
831  virtual void set_hard_fork(HardFork* hf);
832 
833  // adds a block with the given metadata to the top of the blockchain, returns the new height
855  virtual uint64_t add_block( const std::pair<block, blobdata>& blk
856  , size_t block_weight
857  , uint64_t long_term_block_weight
858  , const difficulty_type& cumulative_difficulty
859  , const uint64_t& coins_generated
860  , const std::vector<std::pair<transaction, blobdata>>& txs
861  );
862 
871  virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const = 0;
872 
884  virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const = 0;
885 
897  virtual block get_block(const crypto::hash& h) const;
898 
910  virtual uint64_t get_block_height(const crypto::hash& h) const = 0;
911 
924  virtual block_header get_block_header(const crypto::hash& h) const = 0;
925 
938  virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const = 0;
939 
950  virtual block get_block_from_height(const uint64_t& height) const;
951 
964  virtual uint64_t get_block_timestamp(const uint64_t& height) const = 0;
965 
978  virtual std::vector<uint64_t> get_block_cumulative_rct_outputs(const std::vector<uint64_t> &heights) const = 0;
979 
987  virtual uint64_t get_top_block_timestamp() const = 0;
988 
1001  virtual size_t get_block_weight(const uint64_t& height) const = 0;
1002 
1012  virtual std::vector<uint64_t> get_block_weights(uint64_t start_height, size_t count) const = 0;
1013 
1026  virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const = 0;
1027 
1040  virtual difficulty_type get_block_difficulty(const uint64_t& height) const = 0;
1041 
1050  virtual void correct_block_cumulative_difficulties(const uint64_t& start_height, const std::vector<difficulty_type>& new_cumulative_difficulties) = 0;
1051 
1064  virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const = 0;
1065 
1075  virtual uint64_t get_block_long_term_weight(const uint64_t& height) const = 0;
1076 
1086  virtual std::vector<uint64_t> get_long_term_block_weights(uint64_t start_height, size_t count) const = 0;
1087 
1100  virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const = 0;
1101 
1117  virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) const = 0;
1118 
1134  virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const = 0;
1135 
1145  virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const = 0;
1146 
1154  virtual block get_top_block() const = 0;
1155 
1163  virtual uint64_t height() const = 0;
1164 
1165 
1186  virtual void pop_block(block& blk, std::vector<transaction>& txs);
1187 
1188 
1200  virtual bool tx_exists(const crypto::hash& h) const = 0;
1201  virtual bool tx_exists(const crypto::hash& h, uint64_t& tx_id) const = 0;
1202 
1203  // return unlock time of tx with hash <h>
1216  virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const = 0;
1217 
1218  // return tx with hash <h>
1219  // throw if no such tx exists
1229  virtual transaction get_tx(const crypto::hash& h) const;
1230 
1240  virtual transaction get_pruned_tx(const crypto::hash& h) const;
1241 
1251  virtual bool get_tx(const crypto::hash& h, transaction &tx) const;
1252 
1262  virtual bool get_pruned_tx(const crypto::hash& h, transaction &tx) const;
1263 
1276  virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const = 0;
1277 
1290  virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const = 0;
1291 
1306  virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const = 0;
1307 
1325  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 = 0;
1326 
1340  virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const = 0;
1341 
1353  virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const = 0;
1354 
1363  virtual uint64_t get_tx_count() const = 0;
1364 
1380  virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const = 0;
1381 
1382  // returns height of block that contains transaction with hash <h>
1395  virtual uint64_t get_tx_block_height(const crypto::hash& h) const = 0;
1396 
1397  // returns the total number of outputs of amount <amount>
1411  virtual uint64_t get_num_outputs(const uint64_t& amount) const = 0;
1412 
1418  virtual uint64_t get_indexing_base() const { return 0; }
1419 
1436  virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index, bool include_commitmemt = true) const = 0;
1437 
1448  virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const = 0;
1449 
1462  virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const = 0;
1463 
1475  virtual void get_output_tx_and_index(const uint64_t& amount, const std::vector<uint64_t> &offsets, std::vector<tx_out_index> &indices) const = 0;
1476 
1488  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 = 0;
1489 
1490  /*
1491  * FIXME: Need to check with git blame and ask what this does to
1492  * document it
1493  */
1494  virtual bool can_thread_bulk_indices() const = 0;
1495 
1511  virtual std::vector<std::vector<uint64_t>> get_tx_amount_output_indices(const uint64_t tx_id, size_t n_txes = 1) const = 0;
1512 
1520  virtual bool has_key_image(const crypto::key_image& img) const = 0;
1521 
1527  virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t& details) = 0;
1528 
1535  virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& details) = 0;
1536 
1540  virtual uint64_t get_txpool_tx_count(relay_category tx_category = relay_category::broadcasted) const = 0;
1541 
1545  virtual bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const = 0;
1546 
1552  virtual void remove_txpool_tx(const crypto::hash& txid) = 0;
1553 
1562  virtual bool get_txpool_tx_meta(const crypto::hash& txid, txpool_tx_meta_t &meta) const = 0;
1563 
1573  virtual bool get_txpool_tx_blob(const crypto::hash& txid, cryptonote::blobdata &bd, relay_category tx_category) const = 0;
1574 
1582  virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid, relay_category tx_category) const = 0;
1583 
1592  bool txpool_tx_matches_category(const crypto::hash& tx_hash, relay_category category);
1593 
1599  virtual void prune_outputs(uint64_t amount) = 0;
1600 
1605  virtual uint32_t get_blockchain_pruning_seed() const = 0;
1606 
1612  virtual bool prune_blockchain(uint32_t pruning_seed = 0) = 0;
1613 
1618  virtual bool update_pruning() = 0;
1619 
1624  virtual bool check_pruning() = 0;
1625 
1629  virtual uint64_t get_max_block_size() = 0;
1630 
1638  virtual void add_max_block_size(uint64_t sz) = 0;
1639 
1647  virtual void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob) = 0;
1648 
1658  virtual bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob) = 0;
1659 
1665  virtual void remove_alt_block(const crypto::hash &blkid) = 0;
1666 
1670  virtual uint64_t get_alt_block_count() = 0;
1671 
1675  virtual void drop_alt_blocks() = 0;
1676 
1690  virtual 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 category = relay_category::broadcasted) const = 0;
1691 
1705  virtual bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const = 0;
1706 
1725  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 = 0;
1726 
1744  virtual bool for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)>, bool pruned) const = 0;
1745 
1763  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 = 0;
1764  virtual bool for_all_outputs(uint64_t amount, const std::function<bool(uint64_t height)> &f) const = 0;
1765 
1782  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 = 0;
1783 
1784 
1785  //
1786  // Hard fork related storage
1787  //
1788 
1795  virtual void set_hard_fork_version(uint64_t height, uint8_t version) = 0;
1796 
1804  virtual uint8_t get_hard_fork_version(uint64_t height) const = 0;
1805 
1809  virtual void check_hard_fork_info() = 0;
1810 
1814  virtual void drop_hard_fork_info() = 0;
1815 
1826  virtual 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 = 0;
1827 
1828  virtual bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, std::vector<uint64_t> &distribution, uint64_t &base) const = 0;
1829 
1835  virtual bool is_read_only() const = 0;
1836 
1842  virtual uint64_t get_database_size() const = 0;
1843 
1844  // TODO: this should perhaps be (or call) a series of functions which
1845  // progressively update through version updates
1849  virtual void fixup();
1850 
1859  void set_auto_remove_logs(bool auto_remove) { m_auto_remove_logs = auto_remove; }
1860 
1861  bool m_open;
1862  mutable epee::critical_section m_synchronization_lock;
1863 
1864 }; // class BlockchainDB
1865 
1867 {
1868 public:
1870  {
1871  if (readonly)
1872  {
1873  active = db->block_rtxn_start();
1874  }
1875  else
1876  {
1877  db->block_wtxn_start();
1878  active = true;
1879  }
1880  }
1881  virtual ~db_txn_guard()
1882  {
1883  if (active)
1884  stop();
1885  }
1886  void stop()
1887  {
1888  if (readonly)
1889  db->block_rtxn_stop();
1890  else
1891  db->block_wtxn_stop();
1892  active = false;
1893  }
1894  void abort()
1895  {
1896  if (readonly)
1897  db->block_rtxn_abort();
1898  else
1899  db->block_wtxn_abort();
1900  active = false;
1901  }
1902 
1903 private:
1905  bool readonly;
1906  bool active;
1907 };
1908 
1909 class db_rtxn_guard: public db_txn_guard { public: db_rtxn_guard(BlockchainDB *db): db_txn_guard(db, true) {} };
1910 class db_wtxn_guard: public db_txn_guard { public: db_wtxn_guard(BlockchainDB *db): db_txn_guard(db, false) {} };
1911 
1912 BlockchainDB *new_db();
1913 
1914 } // namespace cryptonote
1915 
1916 #endif // BLOCKCHAIN_DB_H
cryptonote::BlockchainDB::get_output_tx_and_index
virtual void get_output_tx_and_index(const uint64_t &amount, const std::vector< uint64_t > &offsets, std::vector< tx_out_index > &indices) const =0
gets some outputs' tx hashes and indices
cryptonote::OUTPUT_DNE::OUTPUT_DNE
OUTPUT_DNE(const char *s)
Definition: blockchain_db.h:338
cryptonote::BlockchainDB::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 =0
runs a function over all alternative blocks stored
cryptonote::db_txn_guard::active
bool active
Definition: blockchain_db.h:1906
cryptonote::BlockchainDB::for_all_transactions
virtual bool for_all_transactions(std::function< bool(const crypto::hash &, const cryptonote::transaction &)>, bool pruned) const =0
runs a function over all transactions stored
cryptonote::BlockchainDB::for_all_outputs
virtual bool for_all_outputs(uint64_t amount, const std::function< bool(uint64_t height)> &f) const =0
cryptonote::BlockchainDB::get_block_blob_from_height
virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t &height) const =0
fetch a block blob by height
cryptonote::BlockchainDB::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)=0
store amount output indices for a tx's outputs
cryptonote::BlockchainDB::get_txpool_tx_meta
virtual bool get_txpool_tx_meta(const crypto::hash &txid, txpool_tx_meta_t &meta) const =0
get a txpool transaction's metadata
cryptonote::output_data_t::commitment
rct::key commitment
the output's amount commitment (for spend verification)
Definition: blockchain_db.h:129
cryptonote::BlockchainDB::get_block_long_term_weight
virtual uint64_t get_block_long_term_weight(const uint64_t &height) const =0
fetch a block's long term weight
cryptonote::BlockchainDB::get_long_term_block_weights
virtual std::vector< uint64_t > get_long_term_block_weights(uint64_t start_height, size_t count) const =0
fetch the last N blocks' long term weights
cryptonote::txpool_tx_meta_t::max_used_block_id
crypto::hash max_used_block_id
Definition: blockchain_db.h:156
cryptonote::tx_data_t::unlock_time
uint64_t unlock_time
Definition: blockchain_db.h:137
cryptonote::BlockchainDB::get_filenames
virtual std::vector< std::string > get_filenames() const =0
get all files used by the BlockchainDB (if any)
cryptonote::DB_EXCEPTION::what
const char * what() const
Definition: blockchain_db.h:215
cryptonote::DB_ERROR_TXN_START::DB_ERROR_TXN_START
DB_ERROR_TXN_START()
Definition: blockchain_db.h:237
cryptonote::BLOCK_EXISTS
thrown when a block exists, but shouldn't, namely when adding a block
Definition: blockchain_db.h:295
cryptonote::DB_ERROR_TXN_START
thrown when there is an error starting a DB transaction
Definition: blockchain_db.h:235
cryptonote::DB_SYNC_FAILURE::DB_SYNC_FAILURE
DB_SYNC_FAILURE()
Definition: blockchain_db.h:267
cryptonote::BlockchainDB::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 =0
fetches a variable number of blocks and transactions from the given height, in canonical blockchain o...
cryptonote::BlockchainDB::get_hard_fork_version
virtual uint8_t get_hard_fork_version(uint64_t height) const =0
checks which hardfork version a height is on
cryptonote_basic.h
cryptonote::db_wtxn_guard
Definition: blockchain_db.h:1910
cryptonote::txpool_tx_meta_t::kept_by_block
uint8_t kept_by_block
Definition: blockchain_db.h:165
cryptonote::tx_data_t::tx_id
uint64_t tx_id
Definition: blockchain_db.h:136
cryptonote::db_wtxn_guard::db_wtxn_guard
db_wtxn_guard(BlockchainDB *db)
Definition: blockchain_db.h:1910
cryptonote::BlockchainDB::reset
virtual void reset()=0
Remove everything from the BlockchainDB.
cryptonote::txpool_tx_meta_t::padding
uint8_t padding[76]
Definition: blockchain_db.h:175
cryptonote::BlockchainDB::get_output_tx_and_index_from_global
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t &index) const =0
gets an output's tx hash and index
cryptonote::txpool_tx_meta_t::do_not_relay
uint8_t do_not_relay
Definition: blockchain_db.h:167
cryptonote::txpool_tx_meta_t::receive_time
uint64_t receive_time
Definition: blockchain_db.h:162
cryptonote::BlockchainDB::for_all_key_images
virtual bool for_all_key_images(std::function< bool(const crypto::key_image &)>) const =0
runs a function over all key images stored
cryptonote::BlockchainDB::m_hardfork
HardFork * m_hardfork
Definition: blockchain_db.h:577
cryptonote::BlockchainDB::get_block_already_generated_coins
virtual uint64_t get_block_already_generated_coins(const uint64_t &height) const =0
fetch a block's already generated coins
cryptonote::db_txn_guard::db
BlockchainDB * db
Definition: blockchain_db.h:1904
cryptonote::BlockchainDB::block_wtxn_abort
virtual void block_wtxn_abort()=0
cryptonote::BlockchainDB::is_read_only
virtual bool is_read_only() const =0
is BlockchainDB in read-only mode?
cryptonote::BlockchainDB::remove_data_file
virtual bool remove_data_file(const std::string &folder) const =0
remove file(s) storing the database
cryptonote::BlockchainDB::get_blocks_range
virtual std::vector< block > get_blocks_range(const uint64_t &h1, const uint64_t &h2) const =0
fetch a list of blocks
cryptonote::txpool_tx_meta_t::dandelionpp_stem
uint8_t dandelionpp_stem
Definition: blockchain_db.h:171
cryptonote::TX_EXISTS
thrown when a transaction exists, but shouldn't, namely when adding a block
Definition: blockchain_db.h:325
cryptonote::OUTPUT_EXISTS::OUTPUT_EXISTS
OUTPUT_EXISTS()
Definition: blockchain_db.h:347
cryptonote::arg_db_salvage
const command_line::arg_descriptor< bool > arg_db_salvage
Definition: blockchain_db.cpp:158
cryptonote::DB_ERROR::DB_ERROR
DB_ERROR()
Definition: blockchain_db.h:227
base
Definition: base.py:1
cryptonote::relay_method
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:37
cryptonote::DB_EXCEPTION
A base class for BlockchainDB exceptions.
Definition: blockchain_db.h:205
cryptonote::KEY_IMAGE_EXISTS::KEY_IMAGE_EXISTS
KEY_IMAGE_EXISTS(const char *s)
Definition: blockchain_db.h:358
rct::key
Definition: rctTypes.h:79
cryptonote::BlockchainDB::drop_hard_fork_info
virtual void drop_hard_fork_info()=0
delete hard fork info from database
cryptonote::txpool_tx_meta_t::is_local
uint8_t is_local
Definition: blockchain_db.h:170
cryptonote::BlockchainDB::close
virtual void close()=0
close the BlockchainDB
cryptonote::tx_out
Definition: cryptonote_basic.h:143
cryptonote::BLOCK_DNE
thrown when a requested block does not exist
Definition: blockchain_db.h:275
cryptonote::DB_ERROR::DB_ERROR
DB_ERROR(const char *s)
Definition: blockchain_db.h:228
cryptonote::BlockchainDB::add_spent_key
virtual void add_spent_key(const crypto::key_image &k_image)=0
store a spent key
cryptonote::BlockchainDB::add_max_block_size
virtual void add_max_block_size(uint64_t sz)=0
add a new max block size
cryptonote::BlockchainDB::num_calls
uint64_t num_calls
a performance metric
Definition: blockchain_db.h:552
cryptonote::new_db
BlockchainDB * new_db()
Definition: blockchain_db.cpp:164
cryptonote::TX_EXISTS::TX_EXISTS
TX_EXISTS()
Definition: blockchain_db.h:327
cryptonote::BLOCK_PARENT_DNE
thrown when a block's parent does not exist (and it needed to)
Definition: blockchain_db.h:285
cryptonote::BlockchainDB::get_indexing_base
virtual uint64_t get_indexing_base() const
return index of the first element (should be hidden, but isn't)
Definition: blockchain_db.h:1418
cryptonote::tx_data_t::block_id
uint64_t block_id
Definition: blockchain_db.h:138
cryptonote::db_rtxn_guard
Definition: blockchain_db.h:1909
cryptonote::BlockchainDB::add_transaction
void add_transaction(const crypto::hash &blk_hash, const std::pair< transaction, blobdata_ref > &tx, const crypto::hash *tx_hash_ptr=NULL, const crypto::hash *tx_prunable_hash_ptr=NULL)
helper function for add_transactions, to add each individual transaction
Definition: blockchain_db.cpp:182
cryptonote::BlockchainDB::get_pruned_tx_blob
virtual bool get_pruned_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const =0
fetches the pruned transaction blob with the given hash
cryptonote::BlockchainDB::block_wtxn_start
virtual void block_wtxn_start()=0
cryptonote::txpool_tx_meta_t::pruned
uint8_t pruned
Definition: blockchain_db.h:169
cryptonote::BlockchainDB
The BlockchainDB backing store interface declaration/contract.
Definition: blockchain_db.h:379
command_line.h
cryptonote::difficulty_type
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:41
cryptonote::BlockchainDB::block_rtxn_stop
virtual void block_rtxn_stop() const =0
cryptonote::BlockchainDB::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=1) const =0
gets output indices (amount-specific) for a transaction's outputs
cryptonote::txpool_tx_meta_t::weight
uint64_t weight
Definition: blockchain_db.h:158
cryptonote::BlockchainDB::get_block_from_height
virtual block get_block_from_height(const uint64_t &height) const
fetch a block by height
Definition: blockchain_db.cpp:360
hardfork.h
cryptonote::BLOCK_PARENT_DNE::BLOCK_PARENT_DNE
BLOCK_PARENT_DNE()
Definition: blockchain_db.h:287
cryptonote::BlockchainDB::time_commit1
uint64_t time_commit1
a performance metric
Definition: blockchain_db.h:574
cryptonote::TX_DNE::TX_DNE
TX_DNE(const char *s)
Definition: blockchain_db.h:318
cryptonote::BlockchainDB::safesyncmode
virtual void safesyncmode(const bool onoff)=0
toggle safe syncs for the DB
cryptonote::BLOCK_DNE::BLOCK_DNE
BLOCK_DNE(const char *s)
Definition: blockchain_db.h:278
cryptonote::BlockchainDB::get_block_blob
virtual cryptonote::blobdata get_block_blob(const crypto::hash &h) const =0
fetches the block with the given hash
cryptonote::BlockchainDB::get_txpool_tx_count
virtual uint64_t get_txpool_tx_count(relay_category tx_category=relay_category::broadcasted) const =0
get the number of transactions in the txpool
cryptonote::BlockchainDB::fixup
virtual void fixup()
fix up anything that may be wrong due to past bugs
Definition: blockchain_db.cpp:450
cryptonote::blobdata_ref
boost::string_ref blobdata_ref
Definition: blobdatatype.h:40
cryptonote::DB_ERROR_TXN_START::DB_ERROR_TXN_START
DB_ERROR_TXN_START(const char *s)
Definition: blockchain_db.h:238
cryptonote::BlockchainDB::set_auto_remove_logs
void set_auto_remove_logs(bool auto_remove)
set whether or not to automatically remove logs
Definition: blockchain_db.h:1859
cryptonote::BlockchainDB::batch_stop
virtual void batch_stop()=0
ends a batch transaction
cryptonote::relay_category
relay_category
Definition: blockchain_db.h:110
cryptonote::BlockchainDB::block_wtxn_stop
virtual void block_wtxn_stop()=0
cryptonote::db_rtxn_guard::db_rtxn_guard
db_rtxn_guard(BlockchainDB *db)
Definition: blockchain_db.h:1909
cryptonote::BlockchainDB::block_rtxn_start
virtual bool block_rtxn_start() const =0
build_protob.const
const
Definition: build_protob.py:9
s
#define s(x, c)
Definition: aesb.c:47
cryptonote::output_data_t::unlock_time
uint64_t unlock_time
the output's unlock time (or height)
Definition: blockchain_db.h:127
cryptonote::BlockchainDB::has_key_image
virtual bool has_key_image(const crypto::key_image &img) const =0
check if a key image is stored as spent
cryptonote::BlockchainDB::check_pruning
virtual bool check_pruning()=0
checks pruning was done correctly, iff enabled
cryptonote::txpool_tx_meta_t::last_failed_height
uint64_t last_failed_height
Definition: blockchain_db.h:161
cryptonote::BlockchainDB::get_block_height
virtual uint64_t get_block_height(const crypto::hash &h) const =0
gets the height of the block with a given hash
cryptonote::BLOCK_EXISTS::BLOCK_EXISTS
BLOCK_EXISTS()
Definition: blockchain_db.h:297
cryptonote::BlockchainDB::open
virtual void open(const std::string &filename, const int db_flags=0)=0
open a db, or create it if necessary.
cryptonote::BlockchainDB::get_block_cumulative_difficulty
virtual difficulty_type get_block_cumulative_difficulty(const uint64_t &height) const =0
fetch a block's cumulative difficulty
cryptonote::matches_category
bool matches_category(relay_method method, relay_category category) noexcept
Definition: blockchain_db.cpp:47
cryptonote::txpool_tx_meta_t::set_relay_method
void set_relay_method(relay_method method) noexcept
Definition: blockchain_db.cpp:78
cryptonote::BlockchainDB::sync
virtual void sync()=0
sync the BlockchainDB with disk
cryptonote::BlockchainDB::get_block_timestamp
virtual uint64_t get_block_timestamp(const uint64_t &height) const =0
fetch a block's timestamp
cryptonote::txpool_tx_meta_t::fee
uint64_t fee
Definition: blockchain_db.h:159
cryptonote::BlockchainDB::get_tx_unlock_time
virtual uint64_t get_tx_unlock_time(const crypto::hash &h) const =0
fetch a transaction's unlock time/height
cryptonote::db_txn_guard
Definition: blockchain_db.h:1867
cryptonote::BlockchainDB::add_block
virtual void add_block(const block &blk, size_t block_weight, uint64_t long_term_block_weight, const difficulty_type &cumulative_difficulty, const uint64_t &coins_generated, uint64_t num_rct_outs, const crypto::hash &blk_hash)=0
add the block and metadata to the db
cryptonote::BlockchainDB::show_stats
void show_stats()
show profiling stats
Definition: blockchain_db.cpp:428
cryptonote::BlockchainDB::unlock
virtual void unlock()=0
This function releases the BlockchainDB lock.
cryptonote::relay_category::all
@ all
Everything in the db.
cryptonote::db_txn_guard::abort
void abort()
Definition: blockchain_db.h:1894
lmdb::stream::count
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
cryptonote::db_txn_guard::db_txn_guard
db_txn_guard(BlockchainDB *db, bool readonly)
Definition: blockchain_db.h:1869
cryptonote::alt_block_data_t::already_generated_coins
uint64_t already_generated_coins
Definition: blockchain_db.h:148
cryptonote::BlockchainDB::get_block_weights
virtual std::vector< uint64_t > get_block_weights(uint64_t start_height, size_t count) const =0
fetch the last N blocks' weights
cryptonote::BlockchainDB::txpool_has_tx
virtual bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const =0
check whether a txid is in the txpool and meets tx_category requirements
cryptonote::BlockchainDB::set_hard_fork_version
virtual void set_hard_fork_version(uint64_t height, uint8_t version)=0
sets which hardfork version a height is on
cryptonote::OUTPUT_DNE
thrown when a requested output does not exist
Definition: blockchain_db.h:335
cryptonote::BlockchainDB::get_num_outputs
virtual uint64_t get_num_outputs(const uint64_t &amount) const =0
fetches the number of outputs of a given amount
cryptonote::db_txn_guard::~db_txn_guard
virtual ~db_txn_guard()
Definition: blockchain_db.h:1881
cryptonote::BlockchainDB::prune_outputs
virtual void prune_outputs(uint64_t amount)=0
prune output data for the given amount
cryptonote::txpool_tx_meta_t::bf_padding
uint8_t bf_padding
Definition: blockchain_db.h:173
cryptonote::BlockchainDB::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 =0
runs a function over a range of blocks
cryptonote::alt_block_data_t::cumulative_difficulty_low
uint64_t cumulative_difficulty_low
Definition: blockchain_db.h:146
cryptonote::BlockchainDB::get_prunable_tx_hash
virtual bool get_prunable_tx_hash(const crypto::hash &tx_hash, crypto::hash &prunable_hash) const =0
fetches the prunable transaction hash
cryptonote::BlockchainDB::correct_block_cumulative_difficulties
virtual void correct_block_cumulative_difficulties(const uint64_t &start_height, const std::vector< difficulty_type > &new_cumulative_difficulties)=0
correct blocks cumulative difficulties that were incorrectly calculated due to the 'difficulty drift'...
cryptonote::BlockchainDB::remove_block
virtual void remove_block()=0
remove data about the top block
cryptonote::OUTPUT_EXISTS
thrown when an output exists, but shouldn't, namely when adding a block
Definition: blockchain_db.h:345
blocks
Definition: blocks.cpp:13
cryptonote::BlockchainDB::get_output_histogram
virtual 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 =0
return a histogram of outputs on the blockchain
cryptonote::BlockchainDB::init_options
static void init_options(boost::program_options::options_description &desc)
init command line options
Definition: blockchain_db.cpp:169
cryptonote::BlockchainDB::remove_transaction_data
virtual void remove_transaction_data(const crypto::hash &tx_hash, const transaction &tx)=0
remove data about a transaction
cryptonote::BlockchainDB::tx_exists
virtual bool tx_exists(const crypto::hash &h, uint64_t &tx_id) const =0
cryptonote::DB_OPEN_FAILURE::DB_OPEN_FAILURE
DB_OPEN_FAILURE()
Definition: blockchain_db.h:247
cryptonote::BlockchainDB::txpool_tx_matches_category
bool txpool_tx_matches_category(const crypto::hash &tx_hash, relay_category category)
Check if tx_hash relay status is in category.
Definition: blockchain_db.cpp:1034
cryptonote::block
Definition: cryptonote_basic.h:464
cryptonote::BlockchainDB::get_block
virtual block get_block(const crypto::hash &h) const
fetches the block with the given hash
Definition: blockchain_db.cpp:370
cryptonote::BlockchainDB::batch_start
virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0)=0
tells the BlockchainDB to start a new "batch" of blocks
cryptonote::tx_out_index
std::pair< crypto::hash, uint64_t > tx_out_index
Definition: blockchain_db.h:104
cryptonote::BlockchainDB::time_add_block1
uint64_t time_add_block1
a performance metric
Definition: blockchain_db.h:554
net::socks::version
version
Supported socks variants.
Definition: socks.h:58
cryptonote::BlockchainDB::get_pruned_tx
virtual transaction get_pruned_tx(const crypto::hash &h) const
fetches the transaction base with the given hash
Definition: blockchain_db.cpp:410
cryptonote::BLOCK_EXISTS::BLOCK_EXISTS
BLOCK_EXISTS(const char *s)
Definition: blockchain_db.h:298
cryptonote::BlockchainDB::remove_alt_block
virtual void remove_alt_block(const crypto::hash &blkid)=0
remove an alternative block
cryptonote::BLOCK_INVALID
thrown when something is wrong with the block to be added
Definition: blockchain_db.h:305
cryptonote::BlockchainDB::get_blockchain_pruning_seed
virtual uint32_t get_blockchain_pruning_seed() const =0
get the blockchain pruning seed
cryptonote
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
cryptonote::BlockchainDB::get_max_block_size
virtual uint64_t get_max_block_size()=0
get the max block size
cryptonote::OUTPUT_EXISTS::OUTPUT_EXISTS
OUTPUT_EXISTS(const char *s)
Definition: blockchain_db.h:348
cryptonote::BlockchainDB::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 *)>, bool include_blob=false, relay_category category=relay_category::broadcasted) const =0
runs a function over all txpool transactions
cryptonote::alt_block_data_t
Definition: blockchain_db.h:143
cryptonote::txpool_tx_meta_t::last_relayed_time
uint64_t last_relayed_time
If received over i2p/tor, randomized forward time. If Dandelion++stem, randomized embargo time....
Definition: blockchain_db.h:163
cryptonote::txpool_tx_meta_t::relayed
uint8_t relayed
Definition: blockchain_db.h:166
cryptonote::BlockchainDB::BlockchainDB
BlockchainDB()
An empty constructor.
Definition: blockchain_db.h:584
cryptonote::DB_EXCEPTION::m
std::string m
Definition: blockchain_db.h:207
cryptonote::BlockchainDB::tx_exists
virtual bool tx_exists(const crypto::hash &h) const =0
check if a transaction with a given hash exists
cryptonote::txpool_tx_meta_t::get_relay_method
relay_method get_relay_method() const noexcept
Definition: blockchain_db.cpp:109
cryptonote::DB_OPEN_FAILURE::DB_OPEN_FAILURE
DB_OPEN_FAILURE(const char *s)
Definition: blockchain_db.h:248
cryptonote::BlockchainDB::block_rtxn_abort
virtual void block_rtxn_abort() const =0
cryptonote::BlockchainDB::lock
virtual bool lock()=0
acquires the BlockchainDB lock
cryptonote::BLOCK_INVALID::BLOCK_INVALID
BLOCK_INVALID()
Definition: blockchain_db.h:307
cryptonote::KEY_IMAGE_EXISTS::KEY_IMAGE_EXISTS
KEY_IMAGE_EXISTS()
Definition: blockchain_db.h:357
cryptonote::BlockchainDB::time_blk_hash
uint64_t time_blk_hash
a performance metric
Definition: blockchain_db.h:553
blobdatatype.h
cryptonote::BlockchainDB::get_block_cumulative_rct_outputs
virtual std::vector< uint64_t > get_block_cumulative_rct_outputs(const std::vector< uint64_t > &heights) const =0
fetch a block's cumulative number of rct outputs
false
#define false
Definition: stdbool.h:37
cryptonote::DB_EXCEPTION::~DB_EXCEPTION
virtual ~DB_EXCEPTION()
Definition: blockchain_db.h:213
cryptonote::BlockchainDB::set_hard_fork
virtual void set_hard_fork(HardFork *hf)
Definition: blockchain_db.cpp:317
cryptonote::BlockchainDB::add_alt_block
virtual void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob)=0
add a new alternative block
cryptonote::BlockchainDB::get_txpool_tx_blob
virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash &txid, relay_category tx_category) const =0
get a txpool transaction's blob
cryptonote::BlockchainDB::remove_spent_key
virtual void remove_spent_key(const crypto::key_image &k_image)=0
remove a spent key
cryptonote::BlockchainDB::batch_abort
virtual void batch_abort()=0
aborts a batch transaction
cryptonote::BlockchainDB::height
virtual uint64_t height() const =0
fetch the current blockchain height
cryptonote::BlockchainDB::get_output_key
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 =0
gets outputs' data
cryptonote::txpool_tx_meta_t::double_spend_seen
uint8_t double_spend_seen
Definition: blockchain_db.h:168
cryptonote::BlockchainDB::m_open
bool m_open
Whether or not the BlockchainDB is open/ready for use.
Definition: blockchain_db.h:1861
cryptonote::BlockchainDB::get_output_key
virtual output_data_t get_output_key(const uint64_t &amount, const uint64_t &index, bool include_commitmemt=true) const =0
get some of an output's data
cryptonote::db_txn_guard::readonly
bool readonly
Definition: blockchain_db.h:1905
cryptonote::BlockchainDB::~BlockchainDB
virtual ~BlockchainDB()
An empty destructor.
Definition: blockchain_db.h:589
cryptonote::BlockchainDB::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 =0
runs a function over all outputs stored
cryptonote::DB_SYNC_FAILURE
thrown when synchronizing the BlockchainDB to disk fails
Definition: blockchain_db.h:265
cryptonote::BlockchainDB::block_exists
virtual bool block_exists(const crypto::hash &h, uint64_t *height=NULL) const =0
checks if a block exists
cryptonote::BlockchainDB::get_hashes_range
virtual std::vector< crypto::hash > get_hashes_range(const uint64_t &h1, const uint64_t &h2) const =0
fetch a list of block hashes
difficulty.h
cryptonote::BlockchainDB::update_txpool_tx
virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &details)=0
update a txpool transaction's metadata
cryptonote::BlockchainDB::get_alt_block_count
virtual uint64_t get_alt_block_count()=0
get the number of alternative blocks stored
cryptonote::txpool_tx_meta_t
a struct containing txpool per transaction metadata
Definition: blockchain_db.h:155
crypto::public_key
POD_CLASS public_key
Definition: crypto.h:61
cryptonote::alt_block_data_t::height
uint64_t height
Definition: blockchain_db.h:144
cryptonote::txpool_tx_meta_t::upgrade_relay_method
bool upgrade_relay_method(relay_method method) noexcept
Definition: blockchain_db.cpp:137
cryptonote::alt_block_data_t::cumulative_weight
uint64_t cumulative_weight
Definition: blockchain_db.h:145
cryptonote::blobdata
std::string blobdata
Definition: blobdatatype.h:39
cryptonote::BlockchainDB::m_synchronization_lock
epee::critical_section m_synchronization_lock
A lock, currently for when BlockchainLMDB needs to resize the backing db file.
Definition: blockchain_db.h:1862
cryptonote::txpool_tx_meta_t::max_used_block_height
uint64_t max_used_block_height
Definition: blockchain_db.h:160
cryptonote::BlockchainDB::time_add_transaction
uint64_t time_add_transaction
a performance metric
Definition: blockchain_db.h:555
cryptonote::txpool_tx_meta_t::is_forwarding
uint8_t is_forwarding
Definition: blockchain_db.h:172
cryptonote::TX_DNE
thrown when a requested transaction does not exist
Definition: blockchain_db.h:315
cryptonote::BlockchainDB::get_block_weight
virtual size_t get_block_weight(const uint64_t &height) const =0
fetch a block's weight
cryptonote::BlockchainDB::is_open
bool is_open() const
Gets the current open/ready state of the BlockchainDB.
Definition: blockchain_db.cpp:339
cryptonote::BlockchainDB::get_top_block
virtual block get_top_block() const =0
fetch the top block
cryptonote::BlockchainDB::prune_blockchain
virtual bool prune_blockchain(uint32_t pruning_seed=0)=0
prunes the blockchain
cryptonote::BlockchainDB::get_prunable_tx_blob
virtual bool get_prunable_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const =0
fetches the prunable transaction blob with the given hash
enums.h
cryptonote::DB_CREATE_FAILURE
thrown when creating the BlockchainDB fails
Definition: blockchain_db.h:255
cryptonote::HardFork
Definition: hardfork.h:40
cryptonote::BlockchainDB::top_block_hash
virtual crypto::hash top_block_hash(uint64_t *block_height=NULL) const =0
fetch the top block's hash
cryptonote::BlockchainDB::get_top_block_timestamp
virtual uint64_t get_top_block_timestamp() const =0
fetch the top block's timestamp
cryptonote::arg_db_sync_mode
const command_line::arg_descriptor< std::string > arg_db_sync_mode
Definition: blockchain_db.cpp:153
cryptonote::BlockchainDB::get_block_hash_from_height
virtual crypto::hash get_block_hash_from_height(const uint64_t &height) const =0
fetch a block's hash
cryptonote::txpool_tx_meta_t::matches
bool matches(const relay_category category) const noexcept
See relay_category description.
Definition: blockchain_db.h:184
cryptonote::TX_EXISTS::TX_EXISTS
TX_EXISTS(const char *s)
Definition: blockchain_db.h:328
cryptonote::BlockchainDB::remove_transaction
void remove_transaction(const crypto::hash &tx_hash)
helper function to remove transaction from the blockchain
Definition: blockchain_db.cpp:344
cryptonote::BlockchainDB::get_alt_block
virtual bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob)=0
get an alternative block by hash
cryptonote::BlockchainDB::remove_txpool_tx
virtual void remove_txpool_tx(const crypto::hash &txid)=0
remove a txpool transaction
cryptonote::BlockchainDB::get_db_name
virtual std::string get_db_name() const =0
gets the name of the folder the BlockchainDB's file(s) should be in
hash.h
cryptonote::BlockchainDB::get_tx_blob
virtual bool get_tx_blob(const crypto::hash &h, cryptonote::blobdata &tx) const =0
fetches the transaction blob with the given hash
cryptonote::BlockchainDB::reset_stats
void reset_stats()
reset profiling stats
Definition: blockchain_db.cpp:418
cryptonote::BlockchainDB::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)=0
store the transaction and its metadata
cryptonote::BLOCK_PARENT_DNE::BLOCK_PARENT_DNE
BLOCK_PARENT_DNE(const char *s)
Definition: blockchain_db.h:288
cryptonote::KEY_IMAGE_EXISTS
thrown when a spent key image exists, but shouldn't, namely when adding a block
Definition: blockchain_db.h:355
cryptonote::transaction
Definition: cryptonote_basic.h:194
cryptonote::BLOCK_DNE::BLOCK_DNE
BLOCK_DNE()
Definition: blockchain_db.h:277
db_flags
static uint64_t db_flags
Definition: blockchain_blackball.cpp:54
cryptonote::BlockchainDB::set_batch_transactions
virtual void set_batch_transactions(bool)=0
sets whether or not to batch transactions
cryptonote::DB_ERROR
A generic BlockchainDB exception.
Definition: blockchain_db.h:225
cryptonote::alt_block_data_t::cumulative_difficulty_high
uint64_t cumulative_difficulty_high
Definition: blockchain_db.h:147
cryptonote::block_header
Definition: cryptonote_basic.h:447
cryptonote::BlockchainDB::can_thread_bulk_indices
virtual bool can_thread_bulk_indices() const =0
cryptonote::BLOCK_INVALID::BLOCK_INVALID
BLOCK_INVALID(const char *s)
Definition: blockchain_db.h:308
cryptonote::BlockchainDB::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)=0
store an output
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::DB_SYNC_FAILURE::DB_SYNC_FAILURE
DB_SYNC_FAILURE(const char *s)
Definition: blockchain_db.h:268
cryptonote::BlockchainDB::get_output_tx_and_index
virtual tx_out_index get_output_tx_and_index(const uint64_t &amount, const uint64_t &index) const =0
gets an output's tx hash and index
cryptonote::BlockchainDB::get_tx_list
virtual std::vector< transaction > get_tx_list(const std::vector< crypto::hash > &hlist) const =0
fetches a list of transactions based on their hashes
crypto::key_image
POD_CLASS key_image
Definition: crypto.h:87
cryptonote::BlockchainDB::get_output_distribution
virtual bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, std::vector< uint64_t > &distribution, uint64_t &base) const =0
cryptonote::BlockchainDB::get_txpool_tx_blob
virtual bool get_txpool_tx_blob(const crypto::hash &txid, cryptonote::blobdata &bd, relay_category tx_category) const =0
get a txpool transaction's blob
cryptonote::BlockchainDB::drop_alt_blocks
virtual void drop_alt_blocks()=0
drop all alternative blocks
cryptonote::txpool_tx_meta_t::last_failed_id
crypto::hash last_failed_id
Definition: blockchain_db.h:157
cryptonote::OUTPUT_DNE::OUTPUT_DNE
OUTPUT_DNE()
Definition: blockchain_db.h:337
cryptonote::BlockchainDB::get_tx_count
virtual uint64_t get_tx_count() const =0
fetches the total number of transactions ever
cryptonote::BlockchainDB::get_tx_block_height
virtual uint64_t get_tx_block_height(const crypto::hash &h) const =0
fetches the height of a transaction's block
cryptonote::DB_CREATE_FAILURE::DB_CREATE_FAILURE
DB_CREATE_FAILURE()
Definition: blockchain_db.h:257
cryptonote::output_data_t::pubkey
crypto::public_key pubkey
the output's public key (for spend verification)
Definition: blockchain_db.h:126
cryptonote::DB_CREATE_FAILURE::DB_CREATE_FAILURE
DB_CREATE_FAILURE(const char *s)
Definition: blockchain_db.h:258
cryptonote::db_txn_guard::stop
void stop()
Definition: blockchain_db.h:1886
cryptonote::DB_EXCEPTION::DB_EXCEPTION
DB_EXCEPTION(const char *s)
Definition: blockchain_db.h:210
cryptonote::BlockchainDB::update_pruning
virtual bool update_pruning()=0
prunes recent blockchain changes as needed, iff pruning is enabled
cryptonote::tx_data_t
Definition: blockchain_db.h:135
cryptonote::BlockchainDB::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 =0
fetches a number of pruned transaction blob from the given hash, in canonical blockchain order
command_line::arg_descriptor< std::string >
cryptonote::BlockchainDB::get_block_header
virtual block_header get_block_header(const crypto::hash &h) const =0
fetch a block header
cryptonote::BlockchainDB::get_database_size
virtual uint64_t get_database_size() const =0
get disk space requirements
cryptonote::output_data_t::height
uint64_t height
the height of the block which created the output
Definition: blockchain_db.h:128
cryptonote::BlockchainDB::m_auto_remove_logs
bool m_auto_remove_logs
whether or not to automatically remove old logs
Definition: blockchain_db.h:575
cryptonote::output_data_t
a struct containing output metadata
Definition: blockchain_db.h:125
cryptonote::BlockchainDB::get_tx
virtual transaction get_tx(const crypto::hash &h) const
fetches the transaction with the given hash
Definition: blockchain_db.cpp:402
cryptonote::BlockchainDB::time_tx_exists
uint64_t time_tx_exists
a performance metric
Definition: blockchain_db.h:573
cryptonote::TX_DNE::TX_DNE
TX_DNE()
Definition: blockchain_db.h:317
cryptonote::BlockchainDB::get_block_difficulty
virtual difficulty_type get_block_difficulty(const uint64_t &height) const =0
fetch a block's difficulty
cryptonote::BlockchainDB::add_txpool_tx
virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t &details)=0
add a txpool transaction
crypto::hash
POD_CLASS hash
Definition: hash.h:48
cryptonote::BlockchainDB::check_hard_fork_info
virtual void check_hard_fork_info()=0
verify hard fork info in database
cryptonote::DB_OPEN_FAILURE
thrown when opening the BlockchainDB fails
Definition: blockchain_db.h:245