Allow LevelDB and SQLite to co-exist in the build and have the backing

store for hashed nodes selectable in the config.
This commit is contained in:
JoelKatz
2013-05-07 15:04:23 -07:00
parent a417640c9d
commit e086fa5a5d
10 changed files with 131 additions and 59 deletions

View File

@@ -108,20 +108,23 @@ void Application::updateTables(bool ldbImport)
addTxnSeqField();
#ifdef USE_LEVELDB
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists(hashPath))
if (theApp->getHashedObjectStore().isLevelDB())
{
if (theConfig.LDB_IMPORT)
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists(hashPath))
{
Log(lsWARNING) << "Importing SQLite -> LevelDB";
theApp->getHashedObjectStore().import(hashPath.string(), true);
Log(lsWARNING) << "Remove or remname the hashnode.db file";
}
else
{
Log(lsWARNING) << "SQLite hashnode database exists. Please either remove or import";
Log(lsWARNING) << "To import, start with the '--import' option. Otherwise, remove hashnode.db";
exit(1);
if (theConfig.LDB_IMPORT)
{
Log(lsWARNING) << "Importing SQLite -> LevelDB";
theApp->getHashedObjectStore().import(hashPath.string(), true);
Log(lsWARNING) << "Remove or remname the hashnode.db file";
}
else
{
Log(lsWARNING) << "SQLite hashnode database exists. Please either remove or import";
Log(lsWARNING) << "To import, start with the '--import' option. Otherwise, remove hashnode.db";
exit(1);
}
}
}
#endif