forked from lthn/blockchain
moved to v3 db
This commit is contained in:
parent
5f56d146c2
commit
dc5b5f72a3
5 changed files with 43 additions and 8 deletions
|
|
@ -67,6 +67,19 @@ namespace db
|
|||
return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX;
|
||||
}
|
||||
|
||||
std::string db_backend_selector::get_db_folder_path_old_1() const
|
||||
{
|
||||
//CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited");
|
||||
return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1;
|
||||
}
|
||||
|
||||
std::string db_backend_selector::get_db_folder_path_old_2() const
|
||||
{
|
||||
//CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited");
|
||||
return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2;
|
||||
}
|
||||
|
||||
|
||||
std::string db_backend_selector::get_temp_db_folder_path() const
|
||||
{
|
||||
//CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited");
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ namespace tools
|
|||
|
||||
std::shared_ptr<tools::db::i_db_backend> create_backend();
|
||||
|
||||
std::string get_db_folder_path_old_1() const;
|
||||
std::string get_db_folder_path_old_2() const;
|
||||
|
||||
private:
|
||||
db_engine_type m_engine_type;
|
||||
std::string m_config_folder;
|
||||
|
|
|
|||
|
|
@ -220,6 +220,23 @@ void blockchain_storage::set_db_l2_cache_size(uint64_t ceched_elements) const
|
|||
m_db_assets.set_cache_size(ceched_elements);
|
||||
m_db_addr_to_alias.set_cache_size(ceched_elements);
|
||||
}
|
||||
|
||||
void remove_old_db(const std::string old_db_folder_path)
|
||||
{
|
||||
try {
|
||||
if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path)))
|
||||
{
|
||||
LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0);
|
||||
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool blockchain_storage::init(const std::string& config_folder, const boost::program_options::variables_map& vm)
|
||||
{
|
||||
// CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
|
|
@ -251,12 +268,10 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
|
|||
m_config_folder = config_folder;
|
||||
|
||||
// remove old incompatible DB
|
||||
const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD;
|
||||
if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path)))
|
||||
{
|
||||
LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0);
|
||||
boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path));
|
||||
}
|
||||
std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD;
|
||||
remove_old_db(old_db_folder_path);
|
||||
remove_old_db(dbbs.get_db_folder_path_old_1());
|
||||
remove_old_db(dbbs.get_db_folder_path_old_2());
|
||||
|
||||
const std::string db_folder_path = dbbs.get_db_folder_path();
|
||||
LOG_PRINT_L0("Loading blockchain from " << db_folder_path);
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ namespace currency
|
|||
bool is_output_allowed_for_input(const txout_to_key& out_v, const txin_v& in_v) const;
|
||||
bool is_output_allowed_for_input(const txout_htlc& out_v, const txin_v& in_v, uint64_t top_minus_source_height) const;
|
||||
bool is_output_allowed_for_input(const tx_out_zarcanum& out, const txin_v& in_v) const;
|
||||
|
||||
void remove_old_dbs();
|
||||
|
||||
|
||||
//POS
|
||||
|
|
|
|||
|
|
@ -232,7 +232,11 @@
|
|||
#define CURRENCY_POOLDATA_FOLDERNAME_PREFIX "poolstate_"
|
||||
#define CURRENCY_POOLDATA_FOLDERNAME_SUFFIX "_v1"
|
||||
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX "blockchain_"
|
||||
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v2"
|
||||
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v3"
|
||||
|
||||
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1 "_v1"
|
||||
#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2 "_v2"
|
||||
|
||||
|
||||
#define P2P_NET_DATA_FILENAME "p2pstate.bin"
|
||||
#define MINER_CONFIG_FILENAME "miner_conf.json"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue