aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-07-13 21:19:05 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-07-13 21:38:34 +0100
commitd7b681cd6518834ce9b76676980561cb8e235cff (patch)
tree51ff9d28bb4be6e929fd3440613932dbb039900c /src/blockchain_db/lmdb
parentMerge pull request #889 (diff)
downloadmonero-d7b681cd6518834ce9b76676980561cb8e235cff.tar.xz
remove hf_starting_height db
It's not really needed, it used to be an optimization for when that code was not using the db and needed to recalculate things fast on startup.
Diffstat (limited to 'src/blockchain_db/lmdb')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp76
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
2 files changed, 2 insertions, 76 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 8c51c09b1..9824d7376 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -117,13 +117,6 @@ int compare_uint64(const MDB_val *a, const MDB_val *b)
return (va < vb) ? -1 : va > vb;
}
-int compare_uint8(const MDB_val *a, const MDB_val *b)
-{
- const uint8_t va = *(const uint8_t*)a->mv_data;
- const uint8_t vb = *(const uint8_t*)b->mv_data;
- return va - vb;
-};
-
int compare_hash32(const MDB_val *a, const MDB_val *b)
{
uint32_t *va = (uint32_t*) a->mv_data;
@@ -1103,9 +1096,10 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
mdb_set_dupsort(txn, m_output_txs, compare_uint64);
mdb_set_dupsort(txn, m_block_info, compare_uint64);
- mdb_set_compare(txn, m_hf_starting_heights, compare_uint8);
mdb_set_compare(txn, m_properties, compare_string);
+ mdb_drop(txn, m_hf_starting_heights, 1);
+
// get and keep current height
MDB_stat db_stats;
if ((result = mdb_stat(txn, m_blocks, &db_stats)))
@@ -2638,29 +2632,6 @@ std::map<uint64_t, uint64_t> BlockchainLMDB::get_output_histogram(const std::vec
void BlockchainLMDB::check_hard_fork_info()
{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__);
- check_open();
-
- TXN_PREFIX(0);
-
- MDB_stat db_stat1, db_stat2;
- if (mdb_stat(*txn_ptr, m_blocks, &db_stat1))
- throw0(DB_ERROR("Failed to query m_blocks"));
- if (mdb_stat(*txn_ptr, m_hf_versions, &db_stat2))
- throw0(DB_ERROR("Failed to query m_hf_starting_heights"));
- if (db_stat1.ms_entries != db_stat2.ms_entries)
- {
- // Empty, but don't delete. This allows this function to be called after
- // startup, after the subdbs have already been created, and rest of startup
- // can proceed. If these don't exist, hard fork's init() will fail.
- //
- // If these are empty, hard fork's init() will repopulate the hard fork
- // data.
- mdb_drop(*txn_ptr, m_hf_starting_heights, 0);
- mdb_drop(*txn_ptr, m_hf_versions, 0);
- }
-
- TXN_POSTFIX_SUCCESS();
}
void BlockchainLMDB::drop_hard_fork_info()
@@ -2676,49 +2647,6 @@ void BlockchainLMDB::drop_hard_fork_info()
TXN_POSTFIX_SUCCESS();
}
-void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t height)
-{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__);
- check_open();
-
- TXN_BLOCK_PREFIX(0);
-
- MDB_val_copy<uint8_t> val_key(version);
- MDB_val_copy<uint64_t> val_value(height);
- if (auto result = mdb_put(*txn_ptr, m_hf_starting_heights, &val_key, &val_value, MDB_APPEND))
- throw1(DB_ERROR(lmdb_error("Error adding hard fork starting height to db transaction: ", result).c_str()));
-
- TXN_BLOCK_POSTFIX_SUCCESS();
-}
-
-uint64_t BlockchainLMDB::get_hard_fork_starting_height(uint8_t version) const
-{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__);
- check_open();
-
- TXN_PREFIX_RDONLY();
-
- MDB_val_copy<uint8_t> val_key(version);
- MDB_val val_ret;
- uint64_t ret = 0;
- auto result = mdb_get(m_txn, m_hf_starting_heights, &val_key, &val_ret);
- if (result == MDB_SUCCESS)
- {
-#ifdef MISALIGNED_OK
- ret = *(const uint64_t*)val_ret.mv_data;
-#else
- memcpy(&ret, val_ret.mv_data, sizeof(uint64_t));
-#endif
- } else if (result == MDB_NOTFOUND)
- {
- ret = std::numeric_limits<uint64_t>::max();
- } else if (result)
- throw0(DB_ERROR(lmdb_error("Error attempting to retrieve a hard fork starting height from the db", result).c_str()));
-
- TXN_POSTFIX_RDONLY();
- return ret;
-}
-
void BlockchainLMDB::set_hard_fork_version(uint64_t height, uint8_t version)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index c7121bf63..d7a78617e 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -307,8 +307,6 @@ private:
virtual void remove_spent_key(const crypto::key_image& k_image);
// Hard fork
- virtual void set_hard_fork_starting_height(uint8_t version, uint64_t height);
- virtual uint64_t get_hard_fork_starting_height(uint8_t version) const;
virtual void set_hard_fork_version(uint64_t height, uint8_t version);
virtual uint8_t get_hard_fork_version(uint64_t height) const;
virtual void check_hard_fork_info();