diff options
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp | 110 | ||||
-rw-r--r-- | src/cryptonote_core/BlockchainDB_impl/db_lmdb.h | 70 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain_db.h | 62 |
3 files changed, 121 insertions, 121 deletions
diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp index a123a3643..2901f9ba7 100644 --- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp +++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp @@ -79,26 +79,26 @@ auto compare_uint64 = [](const MDB_val *a, const MDB_val *b) { else return 1; }; -const char* LMDB_BLOCKS = "blocks"; -const char* LMDB_BLOCK_TIMESTAMPS = "block_timestamps"; -const char* LMDB_BLOCK_HEIGHTS = "block_heights"; -const char* LMDB_BLOCK_HASHES = "block_hashes"; -const char* LMDB_BLOCK_SIZES = "block_sizes"; -const char* LMDB_BLOCK_DIFFS = "block_diffs"; -const char* LMDB_BLOCK_COINS = "block_coins"; - -const char* LMDB_TXS = "txs"; -const char* LMDB_TX_UNLOCKS = "tx_unlocks"; -const char* LMDB_TX_HEIGHTS = "tx_heights"; -const char* LMDB_TX_OUTPUTS = "tx_outputs"; - -const char* LMDB_OUTPUT_TXS = "output_txs"; -const char* LMDB_OUTPUT_INDICES = "output_indices"; -const char* LMDB_OUTPUT_AMOUNTS = "output_amounts"; -const char* LMDB_OUTPUT_KEYS = "output_keys"; -const char* LMDB_OUTPUTS = "outputs"; -const char* LMDB_OUTPUT_GINDICES = "output_gindices"; -const char* LMDB_SPENT_KEYS = "spent_keys"; +const char* const LMDB_BLOCKS = "blocks"; +const char* const LMDB_BLOCK_TIMESTAMPS = "block_timestamps"; +const char* const LMDB_BLOCK_HEIGHTS = "block_heights"; +const char* const LMDB_BLOCK_HASHES = "block_hashes"; +const char* const LMDB_BLOCK_SIZES = "block_sizes"; +const char* const LMDB_BLOCK_DIFFS = "block_diffs"; +const char* const LMDB_BLOCK_COINS = "block_coins"; + +const char* const LMDB_TXS = "txs"; +const char* const LMDB_TX_UNLOCKS = "tx_unlocks"; +const char* const LMDB_TX_HEIGHTS = "tx_heights"; +const char* const LMDB_TX_OUTPUTS = "tx_outputs"; + +const char* const LMDB_OUTPUT_TXS = "output_txs"; +const char* const LMDB_OUTPUT_INDICES = "output_indices"; +const char* const LMDB_OUTPUT_AMOUNTS = "output_amounts"; +const char* const LMDB_OUTPUT_KEYS = "output_keys"; +const char* const LMDB_OUTPUTS = "outputs"; +const char* const LMDB_OUTPUT_GINDICES = "output_gindices"; +const char* const LMDB_SPENT_KEYS = "spent_keys"; inline void lmdb_db_open(MDB_txn* txn, const char* name, int flags, MDB_dbi& dbi, const std::string& error_string) { @@ -628,7 +628,7 @@ blobdata BlockchainLMDB::output_to_blob(const tx_out& output) return b; } -tx_out BlockchainLMDB::output_from_blob(const blobdata& blob) +tx_out BlockchainLMDB::output_from_blob(const blobdata& blob) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); std::stringstream ss; @@ -645,13 +645,13 @@ tx_out BlockchainLMDB::output_from_blob(const blobdata& blob) return o; } -uint64_t BlockchainLMDB::get_output_global_index(const uint64_t& amount, const uint64_t& index) +uint64_t BlockchainLMDB::get_output_global_index(const uint64_t& amount, const uint64_t& index) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); return 0; } -void BlockchainLMDB::check_open() +void BlockchainLMDB::check_open() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); if (!m_open) @@ -821,7 +821,7 @@ void BlockchainLMDB::reset() // TODO: this } -std::vector<std::string> BlockchainLMDB::get_filenames() +std::vector<std::string> BlockchainLMDB::get_filenames() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); std::vector<std::string> filenames; @@ -853,7 +853,7 @@ void BlockchainLMDB::unlock() } -bool BlockchainLMDB::block_exists(const crypto::hash& h) +bool BlockchainLMDB::block_exists(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -888,7 +888,7 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) return true; } -block BlockchainLMDB::get_block(const crypto::hash& h) +block BlockchainLMDB::get_block(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -896,7 +896,7 @@ block BlockchainLMDB::get_block(const crypto::hash& h) return get_block_from_height(get_block_height(h)); } -uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) +uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -930,7 +930,7 @@ uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) return *(uint64_t*)result.mv_data; } -block_header BlockchainLMDB::get_block_header(const crypto::hash& h) +block_header BlockchainLMDB::get_block_header(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -939,7 +939,7 @@ block_header BlockchainLMDB::get_block_header(const crypto::hash& h) return get_block(h); } -block BlockchainLMDB::get_block_from_height(const uint64_t& height) +block BlockchainLMDB::get_block_from_height(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -983,7 +983,7 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) return b; } -uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) +uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1016,7 +1016,7 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) return *(uint64_t*)result.mv_data; } -uint64_t BlockchainLMDB::get_top_block_timestamp() +uint64_t BlockchainLMDB::get_top_block_timestamp() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1030,7 +1030,7 @@ uint64_t BlockchainLMDB::get_top_block_timestamp() return get_block_timestamp(m_height - 1); } -size_t BlockchainLMDB::get_block_size(const uint64_t& height) +size_t BlockchainLMDB::get_block_size(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1063,7 +1063,7 @@ size_t BlockchainLMDB::get_block_size(const uint64_t& height) return *(size_t*)result.mv_data; } -difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& height) +difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1096,7 +1096,7 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t& return *(difficulty_type*)result.mv_data; } -difficulty_type BlockchainLMDB::get_block_difficulty(const uint64_t& height) +difficulty_type BlockchainLMDB::get_block_difficulty(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1113,7 +1113,7 @@ difficulty_type BlockchainLMDB::get_block_difficulty(const uint64_t& height) return diff1 - diff2; } -uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& height) +uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1146,7 +1146,7 @@ uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& heigh return *(uint64_t*)result.mv_data; } -crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) +crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1179,7 +1179,7 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height) return *(crypto::hash*)result.mv_data; } -std::vector<block> BlockchainLMDB::get_blocks_range(const uint64_t& h1, const uint64_t& h2) +std::vector<block> BlockchainLMDB::get_blocks_range(const uint64_t& h1, const uint64_t& h2) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1193,7 +1193,7 @@ std::vector<block> BlockchainLMDB::get_blocks_range(const uint64_t& h1, const ui return v; } -std::vector<crypto::hash> BlockchainLMDB::get_hashes_range(const uint64_t& h1, const uint64_t& h2) +std::vector<crypto::hash> BlockchainLMDB::get_hashes_range(const uint64_t& h1, const uint64_t& h2) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1207,7 +1207,7 @@ std::vector<crypto::hash> BlockchainLMDB::get_hashes_range(const uint64_t& h1, c return v; } -crypto::hash BlockchainLMDB::top_block_hash() +crypto::hash BlockchainLMDB::top_block_hash() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1219,7 +1219,7 @@ crypto::hash BlockchainLMDB::top_block_hash() return null_hash; } -block BlockchainLMDB::get_top_block() +block BlockchainLMDB::get_top_block() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1233,7 +1233,7 @@ block BlockchainLMDB::get_top_block() return b; } -uint64_t BlockchainLMDB::height() +uint64_t BlockchainLMDB::height() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1242,7 +1242,7 @@ uint64_t BlockchainLMDB::height() } -bool BlockchainLMDB::tx_exists(const crypto::hash& h) +bool BlockchainLMDB::tx_exists(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1276,7 +1276,7 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) return true; } -uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) +uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1309,7 +1309,7 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) return *(uint64_t*)result.mv_data; } -transaction BlockchainLMDB::get_tx(const crypto::hash& h) +transaction BlockchainLMDB::get_tx(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1352,7 +1352,7 @@ transaction BlockchainLMDB::get_tx(const crypto::hash& h) return tx; } -uint64_t BlockchainLMDB::get_tx_count() +uint64_t BlockchainLMDB::get_tx_count() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1376,7 +1376,7 @@ uint64_t BlockchainLMDB::get_tx_count() return db_stats.ms_entries; } -std::vector<transaction> BlockchainLMDB::get_tx_list(const std::vector<crypto::hash>& hlist) +std::vector<transaction> BlockchainLMDB::get_tx_list(const std::vector<crypto::hash>& hlist) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1390,7 +1390,7 @@ std::vector<transaction> BlockchainLMDB::get_tx_list(const std::vector<crypto::h return v; } -uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) +uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1424,7 +1424,7 @@ uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) } //FIXME: make sure the random method used here is appropriate -uint64_t BlockchainLMDB::get_random_output(const uint64_t& amount) +uint64_t BlockchainLMDB::get_random_output(const uint64_t& amount) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1439,7 +1439,7 @@ uint64_t BlockchainLMDB::get_random_output(const uint64_t& amount) return crypto::rand<uint64_t>() % num_outputs; } -uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) +uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1478,7 +1478,7 @@ uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) return num_elems; } -crypto::public_key BlockchainLMDB::get_output_key(const uint64_t& amount, const uint64_t& index) +crypto::public_key BlockchainLMDB::get_output_key(const uint64_t& amount, const uint64_t& index) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1512,7 +1512,7 @@ crypto::public_key BlockchainLMDB::get_output_key(const uint64_t& amount, const return *(crypto::public_key*)v.mv_data; } -tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index) +tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1576,7 +1576,7 @@ tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index) // As this is not used, its return is now a blank output. // This will save on space in the db. -tx_out BlockchainLMDB::get_output(const uint64_t& index) +tx_out BlockchainLMDB::get_output(const uint64_t& index) const { return tx_out(); LOG_PRINT_L3("BlockchainLMDB::" << __func__); @@ -1612,7 +1612,7 @@ tx_out BlockchainLMDB::get_output(const uint64_t& index) return output_from_blob(b); } -tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) +tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1702,7 +1702,7 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, con return tx_out_index(tx_hash, *(uint64_t *)v.mv_data); } -std::vector<uint64_t> BlockchainLMDB::get_tx_output_indices(const crypto::hash& h) +std::vector<uint64_t> BlockchainLMDB::get_tx_output_indices(const crypto::hash& h) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1754,7 +1754,7 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_output_indices(const crypto::hash& return index_vec; } -bool BlockchainLMDB::has_key_image(const crypto::key_image& img) +bool BlockchainLMDB::has_key_image(const crypto::key_image& img) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); diff --git a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.h b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.h index e74ca4b73..3bac5d740 100644 --- a/src/cryptonote_core/BlockchainDB_impl/db_lmdb.h +++ b/src/cryptonote_core/BlockchainDB_impl/db_lmdb.h @@ -90,65 +90,65 @@ public: virtual void reset(); - virtual std::vector<std::string> get_filenames(); + virtual std::vector<std::string> get_filenames() const; virtual bool lock(); virtual void unlock(); - virtual bool block_exists(const crypto::hash& h); + virtual bool block_exists(const crypto::hash& h) const; - virtual block get_block(const crypto::hash& h); + virtual block get_block(const crypto::hash& h) const; - virtual uint64_t get_block_height(const crypto::hash& h); + virtual uint64_t get_block_height(const crypto::hash& h) const; - virtual block_header get_block_header(const crypto::hash& h); + virtual block_header get_block_header(const crypto::hash& h) const; - virtual block get_block_from_height(const uint64_t& height); + virtual block get_block_from_height(const uint64_t& height) const; - virtual uint64_t get_block_timestamp(const uint64_t& height) ; + virtual uint64_t get_block_timestamp(const uint64_t& height) const; - virtual uint64_t get_top_block_timestamp(); + virtual uint64_t get_top_block_timestamp() const; - virtual size_t get_block_size(const uint64_t& height); + virtual size_t get_block_size(const uint64_t& height) const; - virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height); + virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const; - virtual difficulty_type get_block_difficulty(const uint64_t& height); + virtual difficulty_type get_block_difficulty(const uint64_t& height) const; - virtual uint64_t get_block_already_generated_coins(const uint64_t& height); + virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const; - virtual crypto::hash get_block_hash_from_height(const uint64_t& height); + virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const; - virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2); + virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) const; - virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2); + virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const; - virtual crypto::hash top_block_hash(); + virtual crypto::hash top_block_hash() const; - virtual block get_top_block(); + virtual block get_top_block() const; - virtual uint64_t height(); + virtual uint64_t height() const; - virtual bool tx_exists(const crypto::hash& h); + virtual bool tx_exists(const crypto::hash& h) const; - virtual uint64_t get_tx_unlock_time(const crypto::hash& h); + virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const; - virtual transaction get_tx(const crypto::hash& h); + virtual transaction get_tx(const crypto::hash& h) const; - virtual uint64_t get_tx_count(); + virtual uint64_t get_tx_count() const; - virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist); + virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const; - virtual uint64_t get_tx_block_height(const crypto::hash& h); + virtual uint64_t get_tx_block_height(const crypto::hash& h) const; - virtual uint64_t get_random_output(const uint64_t& amount); + virtual uint64_t get_random_output(const uint64_t& amount) const; - virtual uint64_t get_num_outputs(const uint64_t& amount); + virtual uint64_t get_num_outputs(const uint64_t& amount) const; - virtual crypto::public_key get_output_key(const uint64_t& amount, const uint64_t& index); + virtual crypto::public_key get_output_key(const uint64_t& amount, const uint64_t& index) const; - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index); + virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const; /** * @brief get an output from its global index @@ -159,13 +159,13 @@ public: * Will throw OUTPUT_DNE if not output has that global index. * Will throw DB_ERROR if there is a non-specific LMDB error in fetching */ - tx_out get_output(const uint64_t& index); + tx_out get_output(const uint64_t& index) const; - virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index); + virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const; - virtual std::vector<uint64_t> get_tx_output_indices(const crypto::hash& h); + virtual std::vector<uint64_t> get_tx_output_indices(const crypto::hash& h) const; - virtual bool has_key_image(const crypto::key_image& img); + virtual bool has_key_image(const crypto::key_image& img) const; virtual uint64_t add_block( const block& blk , const size_t& block_size @@ -217,7 +217,7 @@ private: * * @return the resultant tx output */ - tx_out output_from_blob(const blobdata& blob); + tx_out output_from_blob(const blobdata& blob) const; /** * @brief get the global index of the index-th output of the given amount @@ -227,9 +227,9 @@ private: * * @return the global index of the desired output */ - uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index); + uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index) const; - void check_open(); + void check_open() const; MDB_env* m_env; diff --git a/src/cryptonote_core/blockchain_db.h b/src/cryptonote_core/blockchain_db.h index 95a01b9e3..b9ea79f01 100644 --- a/src/cryptonote_core/blockchain_db.h +++ b/src/cryptonote_core/blockchain_db.h @@ -323,7 +323,7 @@ public: virtual void reset() = 0; // get all files used by this db (if any) - virtual std::vector<std::string> get_filenames() = 0; + virtual std::vector<std::string> get_filenames() const = 0; // FIXME: these are just for functionality mocking, need to implement @@ -347,59 +347,59 @@ public: ); // return true if a block with hash <h> exists in the blockchain - virtual bool block_exists(const crypto::hash& h) = 0; + virtual bool block_exists(const crypto::hash& h) const = 0; // return block with hash <h> - virtual block get_block(const crypto::hash& h) = 0; + virtual block get_block(const crypto::hash& h) const = 0; // return the height of the block with hash <h> on the blockchain, // throw if it doesn't exist - virtual uint64_t get_block_height(const crypto::hash& h) = 0; + virtual uint64_t get_block_height(const crypto::hash& h) const = 0; // return header for block with hash <h> - virtual block_header get_block_header(const crypto::hash& h) = 0; + virtual block_header get_block_header(const crypto::hash& h) const = 0; // return block at height <height> - virtual block get_block_from_height(const uint64_t& height) = 0; + virtual block get_block_from_height(const uint64_t& height) const = 0; // return timestamp of block at height <height> - virtual uint64_t get_block_timestamp(const uint64_t& height) = 0; + virtual uint64_t get_block_timestamp(const uint64_t& height) const = 0; // return timestamp of most recent block - virtual uint64_t get_top_block_timestamp() = 0; + virtual uint64_t get_top_block_timestamp() const = 0; // return block size of block at height <height> - virtual size_t get_block_size(const uint64_t& height) = 0; + virtual size_t get_block_size(const uint64_t& height) const = 0; // return cumulative difficulty up to and including block at height <height> - virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) = 0; + virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const = 0; // return difficulty of block at height <height> - virtual difficulty_type get_block_difficulty(const uint64_t& height) = 0; + virtual difficulty_type get_block_difficulty(const uint64_t& height) const = 0; // return number of coins generated up to and including block at height <height> - virtual uint64_t get_block_already_generated_coins(const uint64_t& height) = 0; + virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const = 0; // return hash of block at height <height> - virtual crypto::hash get_block_hash_from_height(const uint64_t& height) = 0; + virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const = 0; // return vector of blocks in range <h1,h2> of height (inclusively) - virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) = 0; + virtual std::vector<block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) const = 0; // return vector of block hashes in range <h1, h2> of height (inclusively) - virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) = 0; + virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const = 0; // return the hash of the top block on the chain - virtual crypto::hash top_block_hash() = 0; + virtual crypto::hash top_block_hash() const = 0; // return the block at the top of the blockchain - virtual block get_top_block() = 0; + virtual block get_top_block() const = 0; // return the index of the top block on the chain // NOTE: for convenience using heights as indices, this is not the total // size of the blockchain, but rather the index of the top block. As the // chain is 0-indexed, the total size will be height() + 1. - virtual uint64_t height() = 0; + virtual uint64_t height() const = 0; // pops the top block off the blockchain. // Returns by reference the popped block and its associated transactions @@ -412,48 +412,48 @@ public: // return true if a transaction with hash <h> exists - virtual bool tx_exists(const crypto::hash& h) = 0; + virtual bool tx_exists(const crypto::hash& h) const = 0; // return unlock time of tx with hash <h> - virtual uint64_t get_tx_unlock_time(const crypto::hash& h) = 0; + virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const = 0; // return tx with hash <h> // throw if no such tx exists - virtual transaction get_tx(const crypto::hash& h) = 0; + virtual transaction get_tx(const crypto::hash& h) const = 0; // returns the total number of transactions in all blocks - virtual uint64_t get_tx_count() = 0; + virtual uint64_t get_tx_count() const = 0; // return list of tx with hashes <hlist>. // TODO: decide if a missing hash means return empty list // or just skip that hash - virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) = 0; + virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const = 0; // returns height of block that contains transaction with hash <h> - virtual uint64_t get_tx_block_height(const crypto::hash& h) = 0; + virtual uint64_t get_tx_block_height(const crypto::hash& h) const = 0; // return global output index of a random output of amount <amount> - virtual uint64_t get_random_output(const uint64_t& amount) = 0; + virtual uint64_t get_random_output(const uint64_t& amount) const = 0; // returns the total number of outputs of amount <amount> - virtual uint64_t get_num_outputs(const uint64_t& amount) = 0; + virtual uint64_t get_num_outputs(const uint64_t& amount) const = 0; // return public key for output with global output amount <amount> and index <index> - virtual crypto::public_key get_output_key(const uint64_t& amount, const uint64_t& index) = 0; + virtual crypto::public_key get_output_key(const uint64_t& amount, const uint64_t& index) const = 0; // returns the output indexed by <index> in the transaction with hash <h> - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) = 0; + virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const = 0; // returns the transaction-local reference for the output with <amount> at <index> // return type is pair of tx hash and index - virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) = 0; + virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const = 0; // return a vector of indices corresponding to the global output index for // each output in the transaction with hash <h> - virtual std::vector<uint64_t> get_tx_output_indices(const crypto::hash& h) = 0; + virtual std::vector<uint64_t> get_tx_output_indices(const crypto::hash& h) const = 0; // returns true if key image <img> is present in spent key images storage - virtual bool has_key_image(const crypto::key_image& img) = 0; + virtual bool has_key_image(const crypto::key_image& img) const = 0; }; // class BlockchainDB |