LevelDB import operation.

This commit is contained in:
JoelKatz
2013-05-04 01:22:17 -07:00
parent ecfe553ef9
commit 1938a30c67
6 changed files with 28 additions and 3 deletions

View File

@@ -187,7 +187,7 @@ void Application::setup()
mLedgerDB->getDB()->setupCheckpointing(&mJobQueue); mLedgerDB->getDB()->setupCheckpointing(&mJobQueue);
if (!theConfig.RUN_STANDALONE) if (!theConfig.RUN_STANDALONE)
updateTables(); updateTables(theConfig.LDB_IMPORT);
if (theConfig.START_UP == Config::FRESH) if (theConfig.START_UP == Config::FRESH)
{ {

View File

@@ -103,7 +103,7 @@ class Application
volatile bool mShutdown; volatile bool mShutdown;
void updateTables(); void updateTables(bool);
void startNewLedger(); void startNewLedger();
bool loadOldLedger(const std::string&); bool loadOldLedger(const std::string&);

View File

@@ -248,6 +248,7 @@ Config::Config()
SSL_VERIFY = true; SSL_VERIFY = true;
LDB_IMPORT = false;
RUN_STANDALONE = false; RUN_STANDALONE = false;
START_UP = NORMAL; START_UP = NORMAL;
} }

View File

@@ -88,6 +88,7 @@ public:
boost::filesystem::path DATA_DIR; boost::filesystem::path DATA_DIR;
boost::filesystem::path DEBUG_LOGFILE; boost::filesystem::path DEBUG_LOGFILE;
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg. boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
bool LDB_IMPORT; // Import into LevelDB
std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet. std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet.
std::string VALIDATORS_URI; // URI of validators.txt. std::string VALIDATORS_URI; // URI of validators.txt.

View File

@@ -101,9 +101,28 @@ static void addTxnSeqField()
db->executeSQL("END TRANSACTION;"); db->executeSQL("END TRANSACTION;");
} }
void Application::updateTables() void Application::updateTables(bool ldbImport)
{ // perform any needed table updates { // perform any needed table updates
assert(schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TransID")); assert(schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TransID"));
assert(!schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "foobar")); assert(!schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "foobar"));
addTxnSeqField(); addTxnSeqField();
#ifdef USE_LEVELDB
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists(hashPath))
{
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
} }

View File

@@ -150,6 +150,9 @@ int main(int argc, char* argv[])
("start", "Start from a fresh Ledger.") ("start", "Start from a fresh Ledger.")
("net", "Get the initial ledger from the network.") ("net", "Get the initial ledger from the network.")
("fg", "Run in the foreground.") ("fg", "Run in the foreground.")
#ifdef USE_LEVELDB
("import", "Import SQLite node DB into LevelDB.")
#endif
; ;
// Interpret positional arguments as --parameters. // Interpret positional arguments as --parameters.
@@ -240,6 +243,7 @@ int main(int argc, char* argv[])
} }
if (vm.count("start")) theConfig.START_UP = Config::FRESH; if (vm.count("start")) theConfig.START_UP = Config::FRESH;
if (vm.count("import")) theConfig.LDB_IMPORT = true;
if (vm.count("ledger")) if (vm.count("ledger"))
{ {
theConfig.START_LEDGER = vm["ledger"].as<std::string>(); theConfig.START_LEDGER = vm["ledger"].as<std::string>();