Skip to content

Commit

Permalink
blockchain_db: add consts where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
moneromooo-monero authored and warptangent committed Jan 5, 2015
1 parent 10fd6ca commit 23f3cb4
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 121 deletions.
110 changes: 55 additions & 55 deletions src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -888,15 +888,15 @@ 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();

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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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__);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 23f3cb4

Please sign in to comment.