mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
LevelDB import operation.
This commit is contained in:
@@ -187,7 +187,7 @@ void Application::setup()
|
||||
mLedgerDB->getDB()->setupCheckpointing(&mJobQueue);
|
||||
|
||||
if (!theConfig.RUN_STANDALONE)
|
||||
updateTables();
|
||||
updateTables(theConfig.LDB_IMPORT);
|
||||
|
||||
if (theConfig.START_UP == Config::FRESH)
|
||||
{
|
||||
|
||||
@@ -103,7 +103,7 @@ class Application
|
||||
|
||||
volatile bool mShutdown;
|
||||
|
||||
void updateTables();
|
||||
void updateTables(bool);
|
||||
void startNewLedger();
|
||||
bool loadOldLedger(const std::string&);
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ Config::Config()
|
||||
|
||||
SSL_VERIFY = true;
|
||||
|
||||
LDB_IMPORT = false;
|
||||
RUN_STANDALONE = false;
|
||||
START_UP = NORMAL;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
boost::filesystem::path DATA_DIR;
|
||||
boost::filesystem::path DEBUG_LOGFILE;
|
||||
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_URI; // URI of validators.txt.
|
||||
|
||||
@@ -101,9 +101,28 @@ static void addTxnSeqField()
|
||||
db->executeSQL("END TRANSACTION;");
|
||||
}
|
||||
|
||||
void Application::updateTables()
|
||||
void Application::updateTables(bool ldbImport)
|
||||
{ // perform any needed table updates
|
||||
assert(schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TransID"));
|
||||
assert(!schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "foobar"));
|
||||
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
|
||||
}
|
||||
|
||||
@@ -150,6 +150,9 @@ int main(int argc, char* argv[])
|
||||
("start", "Start from a fresh Ledger.")
|
||||
("net", "Get the initial ledger from the network.")
|
||||
("fg", "Run in the foreground.")
|
||||
#ifdef USE_LEVELDB
|
||||
("import", "Import SQLite node DB into LevelDB.")
|
||||
#endif
|
||||
;
|
||||
|
||||
// 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("import")) theConfig.LDB_IMPORT = true;
|
||||
if (vm.count("ledger"))
|
||||
{
|
||||
theConfig.START_LEDGER = vm["ledger"].as<std::string>();
|
||||
|
||||
Reference in New Issue
Block a user