|
Monero
|
#include <testdb.h>


Public Member Functions | |
| BaseTestDB () | |
| virtual void | open (const std::string &filename, const int db_flags=0) override |
| open a db, or create it if necessary. | |
| virtual void | close () override |
| close the BlockchainDB | |
| virtual void | sync () override |
| sync the BlockchainDB with disk | |
| virtual void | safesyncmode (const bool onoff) override |
| toggle safe syncs for the DB | |
| virtual void | reset () override |
| Remove everything from the BlockchainDB. | |
| virtual std::vector< std::string > | get_filenames () const override |
| get all files used by the BlockchainDB (if any) | |
| virtual bool | remove_data_file (const std::string &folder) const override |
| remove file(s) storing the database | |
| virtual std::string | get_db_name () const override |
| gets the name of the folder the BlockchainDB's file(s) should be in | |
| virtual bool | lock () override |
| acquires the BlockchainDB lock | |
| virtual void | unlock () override |
| This function releases the BlockchainDB lock. | |
| virtual bool | batch_start (uint64_t batch_num_blocks=0, uint64_t batch_bytes=0) override |
| tells the BlockchainDB to start a new "batch" of blocks | |
| virtual void | batch_stop () override |
| ends a batch transaction | |
| virtual void | batch_abort () override |
| aborts a batch transaction | |
| virtual void | set_batch_transactions (bool) override |
| sets whether or not to batch transactions | |
| virtual void | block_wtxn_start () override |
| virtual void | block_wtxn_stop () override |
| virtual void | block_wtxn_abort () override |
| virtual bool | block_rtxn_start () const override |
| virtual void | block_rtxn_stop () const override |
| virtual void | block_rtxn_abort () const override |
| virtual void | drop_hard_fork_info () override |
| delete hard fork info from database | |
| virtual bool | block_exists (const crypto::hash &h, uint64_t *height) const override |
| checks if a block exists | |
| virtual cryptonote::blobdata | get_block_blob_from_height (const uint64_t &height) const override |
| fetch a block blob by height | |
| virtual cryptonote::blobdata | get_block_blob (const crypto::hash &h) const override |
| fetches the block with the given hash | |
| virtual bool | get_tx_blob (const crypto::hash &h, cryptonote::blobdata &tx) const override |
| fetches the transaction blob with the given hash | |
| virtual bool | get_pruned_tx_blob (const crypto::hash &h, cryptonote::blobdata &tx) const override |
| fetches the pruned transaction blob with the given hash | |
| virtual bool | get_pruned_tx_blobs_from (const crypto::hash &h, size_t count, std::vector< cryptonote::blobdata > &bd) const override |
| fetches a number of pruned transaction blob from the given hash, in canonical blockchain order | |
| virtual bool | get_blocks_from (uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_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 override |
| fetches a variable number of blocks and transactions from the given height, in canonical blockchain order | |
| virtual bool | get_prunable_tx_blob (const crypto::hash &h, cryptonote::blobdata &tx) const override |
| fetches the prunable transaction blob with the given hash | |
| virtual bool | get_prunable_tx_hash (const crypto::hash &tx_hash, crypto::hash &prunable_hash) const override |
| fetches the prunable transaction hash | |
| virtual uint64_t | get_block_height (const crypto::hash &h) const override |
| gets the height of the block with a given hash | |
| virtual cryptonote::block_header | get_block_header (const crypto::hash &h) const override |
| fetch a block header | |
| virtual uint64_t | get_block_timestamp (const uint64_t &height) const override |
| fetch a block's timestamp | |
| virtual std::vector< uint64_t > | get_block_cumulative_rct_outputs (const std::vector< uint64_t > &heights) const override |
| fetch a block's cumulative number of rct outputs | |
| virtual uint64_t | get_top_block_timestamp () const override |
| fetch the top block's timestamp | |
| virtual size_t | get_block_weight (const uint64_t &height) const override |
| fetch a block's weight | |
| virtual std::vector< uint64_t > | get_block_weights (uint64_t start_height, size_t count) const override |
| fetch the last N blocks' weights | |
| virtual cryptonote::difficulty_type | get_block_cumulative_difficulty (const uint64_t &height) const override |
| fetch a block's cumulative difficulty | |
| virtual cryptonote::difficulty_type | get_block_difficulty (const uint64_t &height) const override |
| fetch a block's difficulty | |
| virtual void | correct_block_cumulative_difficulties (const uint64_t &start_height, const std::vector< difficulty_type > &new_cumulative_difficulties) override |
| correct blocks cumulative difficulties that were incorrectly calculated due to the 'difficulty drift' bug | |
| virtual uint64_t | get_block_already_generated_coins (const uint64_t &height) const override |
| fetch a block's already generated coins | |
| virtual uint64_t | get_block_long_term_weight (const uint64_t &height) const override |
| fetch a block's long term weight | |
| virtual std::vector< uint64_t > | get_long_term_block_weights (uint64_t start_height, size_t count) const override |
| fetch the last N blocks' long term weights | |
| virtual crypto::hash | get_block_hash_from_height (const uint64_t &height) const override |
| fetch a block's hash | |
| virtual std::vector< cryptonote::block > | get_blocks_range (const uint64_t &h1, const uint64_t &h2) const override |
| fetch a list of blocks | |
| virtual std::vector< crypto::hash > | get_hashes_range (const uint64_t &h1, const uint64_t &h2) const override |
| fetch a list of block hashes | |
| virtual crypto::hash | top_block_hash (uint64_t *block_height=NULL) const override |
| fetch the top block's hash | |
| virtual cryptonote::block | get_top_block () const override |
| fetch the top block | |
| virtual uint64_t | height () const override |
| fetch the current blockchain height | |
| virtual bool | tx_exists (const crypto::hash &h) const override |
| check if a transaction with a given hash exists | |
| virtual bool | tx_exists (const crypto::hash &h, uint64_t &tx_index) const override |
| virtual uint64_t | get_tx_unlock_time (const crypto::hash &h) const override |
| fetch a transaction's unlock time/height | |
| virtual cryptonote::transaction | get_tx (const crypto::hash &h) const override |
| fetches the transaction with the given hash | |
| virtual bool | get_tx (const crypto::hash &h, cryptonote::transaction &tx) const override |
| fetches the transaction with the given hash | |
| virtual uint64_t | get_tx_count () const override |
| fetches the total number of transactions ever | |
| virtual std::vector< cryptonote::transaction > | get_tx_list (const std::vector< crypto::hash > &hlist) const override |
| fetches a list of transactions based on their hashes | |
| virtual uint64_t | get_tx_block_height (const crypto::hash &h) const override |
| fetches the height of a transaction's block | |
| virtual uint64_t | get_num_outputs (const uint64_t &amount) const override |
| fetches the number of outputs of a given amount | |
| virtual uint64_t | get_indexing_base () const override |
| return index of the first element (should be hidden, but isn't) | |
| virtual cryptonote::output_data_t | get_output_key (const uint64_t &amount, const uint64_t &index, bool include_commitmemt) const override |
| get some of an output's data | |
| virtual cryptonote::tx_out_index | get_output_tx_and_index_from_global (const uint64_t &index) const override |
| gets an output's tx hash and index | |
| virtual cryptonote::tx_out_index | get_output_tx_and_index (const uint64_t &amount, const uint64_t &index) const override |
| gets an output's tx hash and index | |
| virtual void | get_output_tx_and_index (const uint64_t &amount, const std::vector< uint64_t > &offsets, std::vector< cryptonote::tx_out_index > &indices) const override |
| gets some outputs' tx hashes and indices | |
| virtual void | get_output_key (const epee::span< const uint64_t > &amounts, const std::vector< uint64_t > &offsets, std::vector< cryptonote::output_data_t > &outputs, bool allow_partial=false) const override |
| gets outputs' data | |
| virtual bool | can_thread_bulk_indices () const override |
| virtual std::vector< std::vector< uint64_t > > | get_tx_amount_output_indices (const uint64_t tx_index, size_t n_txes) const override |
| gets output indices (amount-specific) for a transaction's outputs | |
| virtual bool | has_key_image (const crypto::key_image &img) const override |
| check if a key image is stored as spent | |
| virtual void | remove_block () override |
| remove data about the top block | |
| virtual uint64_t | add_transaction_data (const crypto::hash &blk_hash, const std::pair< cryptonote::transaction, cryptonote::blobdata_ref > &tx, const crypto::hash &tx_hash, const crypto::hash &tx_prunable_hash) override |
| virtual void | remove_transaction_data (const crypto::hash &tx_hash, const cryptonote::transaction &tx) override |
| remove data about a transaction | |
| virtual uint64_t | add_output (const crypto::hash &tx_hash, const cryptonote::tx_out &tx_output, const uint64_t &local_index, const uint64_t unlock_time, const rct::key *commitment) override |
| store an output | |
| virtual void | add_tx_amount_output_indices (const uint64_t tx_index, const std::vector< uint64_t > &amount_output_indices) override |
| store amount output indices for a tx's outputs | |
| virtual void | add_spent_key (const crypto::key_image &k_image) override |
| store a spent key | |
| virtual void | remove_spent_key (const crypto::key_image &k_image) override |
| remove a spent key | |
| virtual bool | for_all_key_images (std::function< bool(const crypto::key_image &)>) const override |
| runs a function over all key images stored | |
| virtual bool | for_blocks_range (const uint64_t &, const uint64_t &, std::function< bool(uint64_t, const crypto::hash &, const cryptonote::block &)>) const override |
| runs a function over a range of blocks | |
| virtual bool | for_all_transactions (std::function< bool(const crypto::hash &, const cryptonote::transaction &)>, bool pruned) const override |
| runs a function over all transactions stored | |
| 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 override |
| runs a function over all outputs stored | |
| virtual bool | for_all_outputs (uint64_t amount, const std::function< bool(uint64_t height)> &f) const override |
| virtual bool | is_read_only () const override |
| is BlockchainDB in read-only mode? | |
| 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 override |
| return a histogram of outputs on the blockchain | |
| 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 override |
| virtual void | add_txpool_tx (const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const cryptonote::txpool_tx_meta_t &details) override |
| add a txpool transaction | |
| virtual void | update_txpool_tx (const crypto::hash &txid, const cryptonote::txpool_tx_meta_t &details) override |
| update a txpool transaction's metadata | |
| virtual uint64_t | get_txpool_tx_count (relay_category tx_relay=relay_category::broadcasted) const override |
| get the number of transactions in the txpool | |
| virtual bool | txpool_has_tx (const crypto::hash &txid, relay_category tx_category) const override |
| check whether a txid is in the txpool and meets tx_category requirements | |
| virtual void | remove_txpool_tx (const crypto::hash &txid) override |
| remove a txpool transaction | |
| virtual bool | get_txpool_tx_meta (const crypto::hash &txid, cryptonote::txpool_tx_meta_t &meta) const override |
| get a txpool transaction's metadata | |
| virtual bool | get_txpool_tx_blob (const crypto::hash &txid, cryptonote::blobdata &bd, relay_category tx_category) const override |
| get a txpool transaction's blob | |
| virtual uint64_t | get_database_size () const override |
| get disk space requirements | |
| virtual cryptonote::blobdata | get_txpool_tx_blob (const crypto::hash &txid, relay_category tx_category) const override |
| get a txpool transaction's blob | |
| virtual bool | for_all_txpool_txes (std::function< bool(const crypto::hash &, const cryptonote::txpool_tx_meta_t &, const cryptonote::blobdata_ref *)>, bool include_blob=false, relay_category category=relay_category::broadcasted) const override |
| virtual void | add_block (const cryptonote::block &blk, size_t block_weight, uint64_t long_term_block_weight, const cryptonote::difficulty_type &cumulative_difficulty, const uint64_t &coins_generated, uint64_t num_rct_outs, const crypto::hash &blk_hash) override |
| add the block and metadata to the db | |
| virtual cryptonote::block | get_block_from_height (const uint64_t &height) const override |
| fetch a block by height | |
| virtual void | set_hard_fork_version (uint64_t height, uint8_t version) override |
| sets which hardfork version a height is on | |
| virtual uint8_t | get_hard_fork_version (uint64_t height) const override |
| checks which hardfork version a height is on | |
| virtual void | check_hard_fork_info () override |
| verify hard fork info in database | |
| virtual uint32_t | get_blockchain_pruning_seed () const override |
| get the blockchain pruning seed | |
| virtual bool | prune_blockchain (uint32_t pruning_seed=0) override |
| prunes the blockchain | |
| virtual bool | update_pruning () override |
| prunes recent blockchain changes as needed, iff pruning is enabled | |
| virtual bool | check_pruning () override |
| checks pruning was done correctly, iff enabled | |
| virtual void | prune_outputs (uint64_t amount) override |
| prune output data for the given amount | |
| virtual uint64_t | get_max_block_size () override |
| get the max block size | |
| virtual void | add_max_block_size (uint64_t sz) override |
| add a new max block size | |
| virtual void | add_alt_block (const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob) override |
| add a new alternative block | |
| virtual bool | get_alt_block (const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob) override |
| get an alternative block by hash | |
| virtual void | remove_alt_block (const crypto::hash &blkid) override |
| remove an alternative block | |
| virtual uint64_t | get_alt_block_count () override |
| get the number of alternative blocks stored | |
| virtual void | drop_alt_blocks () override |
| drop all alternative 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 override |
| runs a function over all alternative blocks stored | |
| Public Member Functions inherited from cryptonote::BlockchainDB | |
| BlockchainDB () | |
| An empty constructor. | |
| virtual | ~BlockchainDB () |
| An empty destructor. | |
| void | reset_stats () |
| reset profiling stats | |
| void | show_stats () |
| show profiling stats | |
| bool | is_open () const |
| Gets the current open/ready state of the BlockchainDB. | |
| virtual void | set_hard_fork (HardFork *hf) |
| 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 | |
| virtual block | get_block (const crypto::hash &h) const |
| fetches the block with the given hash | |
| virtual void | pop_block (block &blk, std::vector< transaction > &txs) |
| pops the top block off the blockchain | |
| virtual transaction | get_pruned_tx (const crypto::hash &h) const |
| fetches the transaction base with the given hash | |
| virtual bool | get_pruned_tx (const crypto::hash &h, transaction &tx) const |
| fetches the transaction base with the given hash | |
| bool | txpool_tx_matches_category (const crypto::hash &tx_hash, relay_category category) |
| Check if tx_hash relay status is in category. | |
| 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 | |
| virtual void | fixup () |
| fix up anything that may be wrong due to past bugs | |
| void | set_auto_remove_logs (bool auto_remove) |
| set whether or not to automatically remove logs | |
Additional Inherited Members | |
| Static Public Member Functions inherited from cryptonote::BlockchainDB | |
| static void | init_options (boost::program_options::options_description &desc) |
| init command line options | |
| Public Attributes inherited from cryptonote::BlockchainDB | |
| bool | m_open |
| Whether or not the BlockchainDB is open/ready for use. | |
| epee::critical_section | m_synchronization_lock |
| A lock, currently for when BlockchainLMDB needs to resize the backing db file. | |
| Protected Member Functions inherited from cryptonote::BlockchainDB | |
| 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 | |
| Protected Attributes inherited from cryptonote::BlockchainDB | |
| uint64_t | time_tx_exists = 0 |
| a performance metric | |
| uint64_t | time_commit1 = 0 |
| a performance metric | |
| bool | m_auto_remove_logs = true |
| whether or not to automatically remove old logs | |
| HardFork * | m_hardfork |
|
inline |
|
inlineoverridevirtual |
add a new alternative block
| blkid the block hash | |
| data: the metadata for the block | |
| blob: the block's blob |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
add the block and metadata to the db
The subclass implementing this will add the specified block and block metadata to its backing store. This does not include its transactions, those are added in a separate step.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| blk | the block to be added |
| block_weight | the weight of the block (transactions and all) |
| long_term_block_weight | the long term block weight of the block (transactions and all) |
| cumulative_difficulty | the accumulated difficulty after this block |
| coins_generated | the number of coins generated total after this block |
| blk_hash | the hash of the block |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
add a new max block size
The max block size will be the maximum of sz and the current block size
| sz the block size |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
store an output
The subclass implementing this will add the output data passed to its backing store in a suitable manner. In addition, the subclass is responsible for keeping track of the global output count in some manner, so that outputs may be indexed by the order in which they were created. In the future, this tracking (of the number, at least) should be moved to this class, as it is necessary and the same among all BlockchainDB.
It returns an amount output index, which is the index of the output for its specified amount.
This data should be stored in such a manner that the only thing needed to reverse the process is the tx_out.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| tx_hash | hash of the transaction the output was created by |
| tx_output | the output |
| local_index | index of the output in its transaction |
| unlock_time | unlock time/height of the output |
| commitment | the rct commitment to the output amount |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
store a spent key
The subclass implementing this will store the spent key image.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| k_image | the spent key image to store |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
store amount output indices for a tx's outputs
The subclass implementing this will add the amount output indices to its backing store in a suitable manner. The tx_id will be the same one that was returned from add_output().
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| tx_id | ID of the transaction containing these outputs |
| amount_output_indices | the amount output indices of the transaction |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
add a txpool transaction
| details | the details of the transaction to add |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
aborts a batch transaction
If the subclass implements batching, this function should abort the batch it is currently on.
If no batch is in-progress, this function should throw a DB_ERROR. This exception may change in the future if it is deemed necessary to have a more granular exception type for this scenario.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
tells the BlockchainDB to start a new "batch" of blocks
If the subclass implements a batching method of caching blocks in RAM to be added to a backing store in groups, it should start a batch which will end either when <batch_num_blocks> has been added or batch_stop() has been called. In either case, it should end the batch and write to its backing store.
If a batch is already in-progress, this function must return false. If a batch was started by this call, it must return true.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| batch_num_blocks | number of blocks to batch together |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
ends a batch transaction
If the subclass implements batching, this function should store the batch it is currently on and mark it finished.
If no batch is in-progress, this function should throw a DB_ERROR. This exception may change in the future if it is deemed necessary to have a more granular exception type for this scenario.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
checks if a block exists
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
verify hard fork info in database
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
checks pruning was done correctly, iff enabled
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
close the BlockchainDB
At minimum, this call ensures that further use of the BlockchainDB instance will not have effect. In any case where it is necessary to do so, a subclass implementing this will sync with disk.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
correct blocks cumulative difficulties that were incorrectly calculated due to the 'difficulty drift' bug
If the block does not exist, the subclass should throw BLOCK_DNE
| start_height | the height where the drift starts |
| new_cumulative_difficulties | new cumulative difficulties to be stored |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
drop all alternative blocks
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
delete hard fork info from database
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
runs a function over all alternative blocks stored
The subclass should run the passed function for each alt block it has stored, passing (blkid, data, blob) as its parameters.
If any call to the function returns false, the subclass should return false. Otherwise, the subclass returns true.
The subclass should throw DB_ERROR if any of the expected values are not found. Current implementations simply return false.
| std::function | f the function to run |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
runs a function over all key images stored
The subclass should run the passed function for each key image it has stored, passing the key image as its parameter.
If any call to the function returns false, the subclass should return false. Otherwise, the subclass returns true.
| std::function | fn the function to run |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
runs a function over all outputs stored
The subclass should run the passed function for each output it has stored, passing (amount, transaction_hash, tx_local_output_index) as its parameters.
If any call to the function returns false, the subclass should return false. Otherwise, the subclass returns true.
The subclass should throw DB_ERROR if any of the expected values are not found. Current implementations simply return false.
| std::function | f the function to run |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
runs a function over all transactions stored
The subclass should run the passed function for each transaction it has stored, passing (transaction_hash, transaction) as its parameters.
If any call to the function returns false, the subclass should return false. Otherwise, the subclass returns true.
The subclass should throw DB_ERROR if any of the expected values are not found. Current implementations simply return false.
| std::function | fn the function to run |
| bool | pruned whether to only get pruned tx data, or the whole |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
runs a function over a range of blocks
The subclass should run the passed function for each block in the specified range, passing (block_height, block_hash, block) as its parameters.
If any call to the function returns false, the subclass should return false. Otherwise, the subclass returns true.
The subclass should throw DB_ERROR if any of the expected values are not found. Current implementations simply return false.
| h1 | the start height |
| h2 | the end height |
| std::function | fn the function to run |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get an alternative block by hash
| blkid the block hash | |
| data: the metadata for the block | |
| blob: the block's blob |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get the number of alternative blocks stored
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's already generated coins
The subclass should return the total coins generated as of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the block with the given hash
The subclass should return the requested block.
If the block does not exist, the subclass should throw BLOCK_DNE
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block blob by height
The subclass should return the block at the given height.
If the block does not exist, that is to say if the blockchain is not that high, then the subclass should throw BLOCK_DNE
| height | the height to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's cumulative difficulty
The subclass should return the cumulative difficulty of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's cumulative number of rct outputs
The subclass should return the numer of rct outputs in the blockchain up to the block with the given height (inclusive).
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's difficulty
The subclass should return the difficulty of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block by height
If the block does not exist, that is to say if the blockchain is not that high, then the subclass should throw BLOCK_DNE
| height | the height to look for |
Reimplemented from cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's hash
The subclass should return hash of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block header
The subclass should return the block header from the block with the given hash.
If the block does not exist, the subclass should throw BLOCK_DNE
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets the height of the block with a given hash
The subclass should return the requested height.
If the block does not exist, the subclass should throw BLOCK_DNE
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's long term weight
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's timestamp
The subclass should return the timestamp of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a block's weight
The subclass should return the weight of the block with the given height.
If the block does not exist, the subclass should throw BLOCK_DNE
| height | the height requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the last N blocks' weights
If there are fewer than N blocks, the returned array will be smaller than N
| count | the number of blocks requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get the blockchain pruning seed
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches a variable number of blocks and transactions from the given height, in canonical blockchain order
The subclass should return the blocks and transactions stored from the one with the given height. The number of blocks returned is variable, based on the max_size passed.
| start_height | the height of the first block |
| min_block_count | the minimum number of blocks to return, if they exist |
| max_block_count | the maximum number of blocks to return |
| max_tx_count | the maximum number of txes to return |
| max_size | the maximum size of block/transaction data to return (will be exceeded by one blocks's worth at most, if min_count is met) |
| blocks | the returned block/transaction data |
| pruned | whether to return full or pruned tx data |
| skip_coinbase | whether to return or skip coinbase transactions (they're in blocks regardless) |
| get_miner_tx_hash | whether to calculate and return the miner (coinbase) tx hash |
The call will return at least min_block_count if possible, even if this contravenes max_tx_count
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a list of blocks
The subclass should return a vector of blocks with heights starting at h1 and ending at h2, inclusively.
If the height range requested goes past the end of the blockchain, the subclass should throw BLOCK_DNE. (current implementations simply don't catch this exception as thrown by methods called within)
| h1 | the start height |
| h2 | the end height |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
gets the name of the folder the BlockchainDB's file(s) should be in
The subclass implementation should return the name of the folder in which it stores files, or an empty string if there is none.
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get all files used by the BlockchainDB (if any)
This function is largely for ease of automation, namely for unit tests.
The subclass implementation should return all filenames it uses.
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
checks which hardfork version a height is on
| height | the height |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a list of block hashes
The subclass should return a vector of block hashes from blocks with heights starting at h1 and ending at h2, inclusively.
If the height range requested goes past the end of the blockchain, the subclass should throw BLOCK_DNE. (current implementations simply don't catch this exception as thrown by methods called within)
| h1 | the start height |
| h2 | the end height |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
return index of the first element (should be hidden, but isn't)
Reimplemented from cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the last N blocks' long term weights
If there are fewer than N blocks, the returned array will be smaller than N
| count | the number of blocks requested |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get the max block size
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the number of outputs of a given amount
The subclass should return a count of outputs of the given amount, or zero if there are none.
| amount | the output amount being looked up |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
return a histogram of outputs on the blockchain
| amounts | optional set of amounts to lookup |
| unlocked | whether to restrict count to unlocked outputs |
| recent_cutoff | timestamp to determine whether an output is recent |
| min_count | return only amounts with at least that many instances |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets outputs' data
This function is a mirror of get_output_data(const uint64_t& amount, const uint64_t& index) but for a list of outputs rather than just one.
| amounts | an output amount, or as many as offsets |
| offsets | a list of amount-specific output indices |
| outputs | return-by-reference a list of outputs' metadata |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get some of an output's data
The subclass should return the public key, unlock time, and block height for the output with the given amount and index, collected in a struct.
If the output cannot be found, the subclass should throw OUTPUT_DNE.
If any of these parts cannot be found, but some are, the subclass should throw DB_ERROR with a message stating as much.
| amount | the output amount |
| index | the output's index (indexed by amount) |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets some outputs' tx hashes and indices
This function is a mirror of get_output_tx_and_index(const uint64_t& amount, const uint64_t& index), but for a list of outputs rather than just one.
| amount | an output amount |
| offsets | a list of amount-specific output indices |
| indices | return-by-reference a list of tx hashes and output indices (as pairs) |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets an output's tx hash and index
The subclass should return the hash of the transaction which created the output with the amount and index given, as well as its index in that transaction.
| amount | an output amount |
| index | an output's amount-specific index |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets an output's tx hash and index
The subclass should return the hash of the transaction which created the output with the global index given, as well as its index in that transaction.
| index | an output's global index |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the prunable transaction blob with the given hash
The subclass should return the prunable transaction stored which has the given hash.
If the transaction does not exist, or if we do not have that prunable data, the subclass should return false.
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the prunable transaction hash
The subclass should return the hash of the prunable transaction data.
If the transaction hash does not exist, the subclass should return false.
| h | the tx hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the pruned transaction blob with the given hash
The subclass should return the pruned transaction stored which has the given hash.
If the transaction does not exist, the subclass should return false.
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches a number of pruned transaction blob from the given hash, in canonical blockchain order
The subclass should return the pruned transactions stored from the one with the given hash.
If the first transaction does not exist, the subclass should return false. If the first transaction exists, but there are fewer transactions starting with it than requested, the subclass should return false.
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the top block
The subclass should return most recent block
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the top block's timestamp
The subclass should return the timestamp of the most recent block.
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the transaction with the given hash
If the transaction does not exist, the subclass should throw TX_DNE.
| h | the hash to look for |
Reimplemented from cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the transaction with the given hash
If the transaction does not exist, the subclass should return false.
| h | the hash to look for |
Reimplemented from cryptonote::BlockchainDB.
|
inlineoverridevirtual |
gets output indices (amount-specific) for a transaction's outputs
The subclass should fetch the amount-specific output indices for each output in the transaction with the given ID.
If the transaction does not exist, the subclass should throw TX_DNE.
If an output cannot be found, the subclass should throw OUTPUT_DNE.
| tx_id | a transaction ID |
| n_txes | how many txes to get data for, starting with tx_id |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the transaction blob with the given hash
The subclass should return the transaction stored which has the given hash.
If the transaction does not exist, the subclass should return false.
| h | the hash to look for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the height of a transaction's block
The subclass should attempt to return the height of the block containing the transaction with the given hash.
If the transaction cannot be found, the subclass should throw TX_DNE.
| h | the hash of the transaction |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches the total number of transactions ever
The subclass should return a count of all the transactions from all blocks.
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetches a list of transactions based on their hashes
The subclass should attempt to fetch each transaction referred to by the hashes passed.
Currently, if any of the transactions is not in BlockchainDB, the call to get_tx in the implementation will throw TX_DNE.
| hlist | a list of hashes |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch a transaction's unlock time/height
The subclass should return the stored unlock time for the transaction with the given hash.
If no such transaction exists, the subclass should throw TX_DNE.
| h | the hash of the requested transaction |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get a txpool transaction's blob
| txid | the transaction id of the transation to lookup |
| bd | the blob to return |
| tx_category | for filtering out hidden/private txes |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get a txpool transaction's blob
| txid | the transaction id of the transation to lookup |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get the number of transactions in the txpool
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
get a txpool transaction's metadata
| txid | the transaction id of the transation to lookup |
| meta | the metadata to return |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
check if a key image is stored as spent
| img | the key image to check for |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the current blockchain height
The subclass should return the current blockchain height
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
is BlockchainDB in read-only mode?
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
acquires the BlockchainDB lock
This function is a stub until such a time as locking is implemented at this level.
The subclass implementation should return true unless implementing a locking scheme of some sort, in which case it should return true upon acquisition of the lock and block until then.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
open a db, or create it if necessary.
This function opens an existing database or creates it if it does not exist.
The subclass implementing this will handle all file opening/creation, and is responsible for maintaining its state.
The parameter <filename> may not refer to a file name, necessarily, but could be an IP:PORT for a database which needs it, and so on. Calling it <filename> is convenient and should be descriptive enough, however.
For now, db_flags are specific to the subclass being instantiated. This is subject to change, and the db_flags parameter may be deprecated.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| filename | a string referring to the BlockchainDB to open |
| db_flags | flags relevant to how to open/use the BlockchainDB |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
prunes the blockchain
| pruning_seed | the seed to use, 0 for default (highly recommended) |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
prune output data for the given amount
| amount | the amount for which to prune data |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
remove data about the top block
The subclass implementing this will remove the block data from the top block in the chain. The data to be removed is that which was added in BlockchainDB::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, const crypto::hash& blk_hash)
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
remove file(s) storing the database
This function is for resetting the database (for core tests, functional tests, etc). The function reset() is not usable because it needs to open the database file first which can fail if the existing database file is in an incompatible format. As such, this function needs to be called before calling open().
| folder | The path of the folder containing the database file(s) which must not end with slash '/'. |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
remove a spent key
The subclass implementing this will remove the key image.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| k_image | the spent key image to remove |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
remove data about a transaction
The subclass implementing this will remove the transaction data for the passed transaction. The data to be removed was added in add_transaction_data(). Additionally, current subclasses have behavior which requires the transaction itself as a parameter here. Future implementations should note that this parameter is subject to be removed at a later time.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| tx_hash | the hash of the transaction to be removed |
| tx | the transaction |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
remove a txpool transaction
| txid | the transaction id of the transation to remove |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Remove everything from the BlockchainDB.
This function should completely remove all data from a BlockchainDB.
Use with caution!
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
toggle safe syncs for the DB
Used to switch DBF_SAFE on or off after starting up with DBF_FAST.
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
sets whether or not to batch transactions
If the subclass implements batching, this function tells it to begin batching automatically.
If the subclass implements batching and has a batch in-progress, a parameter of false should disable batching and call batch_stop() to store the current batch.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
| bool | batch whether or not to use batch transactions. |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
sets which hardfork version a height is on
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
sync the BlockchainDB with disk
This function should write any changes to whatever permanent backing store the subclass uses. Example: a BlockchainDB instance which keeps the whole blockchain in RAM won't need to regularly access a disk, but should write out its state when this is called.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
fetch the top block's hash
The subclass should return the hash of the most recent block
| block_height | if non NULL, returns the height of that block (ie, the blockchain height minus 1) |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
check if a transaction with a given hash exists
The subclass should check if a transaction is stored which has the given hash and return true if so, false otherwise.
| h | the hash to check against |
| tx_id | (optional) returns the tx_id for the tx hash |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
check whether a txid is in the txpool and meets tx_category requirements
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
This function releases the BlockchainDB lock.
The subclass, should it have implemented lock(), will release any lock held by the calling thread. In the case of recursive locking, it should release one instance of a lock.
If any of this cannot be done, the subclass should throw the corresponding subclass of DB_EXCEPTION
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
prunes recent blockchain changes as needed, iff pruning is enabled
Implements cryptonote::BlockchainDB.
|
inlineoverridevirtual |
update a txpool transaction's metadata
| txid | the txid of the transaction to update |
| details | the details of the transaction to update |
Implements cryptonote::BlockchainDB.