Remove dead code, fix import.

This commit is contained in:
JoelKatz
2013-07-10 13:51:37 -07:00
committed by Vinnie Falco
parent 77288cc897
commit 884fec075f
6 changed files with 10 additions and 120 deletions

View File

@@ -2401,14 +2401,6 @@ Json::Value RPCHandler::doGetCounts (Json::Value params, LoadType* loadType, Sco
if (dbKB > 0)
ret["dbKBLedger"] = dbKB;
if (!getApp().getNodeStore ().isLevelDB ())
{
dbKB = getApp().getHashNodeDB ()->getDB ()->getKBUsedDB ();
if (dbKB > 0)
ret["dbKBHashNode"] = dbKB;
}
dbKB = getApp().getTxnDB ()->getDB ()->getKBUsedDB ();
if (dbKB > 0)

View File

@@ -256,7 +256,7 @@ public:
void sweep ();
private:
void updateTables (bool);
void updateTables ();
void startNewLedger ();
bool loadOldLedger (const std::string&);
@@ -445,53 +445,6 @@ void Application::setup ()
options.create_if_missing = true;
options.block_cache = leveldb::NewLRUCache (theConfig.getSize (siHashNodeDBCache) * 1024 * 1024);
if (theConfig.NODE_SIZE >= 2)
options.filter_policy = leveldb::NewBloomFilterPolicy (10);
if (theConfig.LDB_IMPORT)
options.write_buffer_size = 32 << 20;
if (m_nodeStore.isLevelDB ())
{
WriteLog (lsINFO, Application) << "LevelDB used for nodes";
leveldb::Status status = leveldb::DB::Open (options, (theConfig.DATA_DIR / "hashnode").string (), &mHashNodeLDB);
if (!status.ok () || !mHashNodeLDB)
{
WriteLog (lsFATAL, Application) << "Unable to open/create hash node db: "
<< (theConfig.DATA_DIR / "hashnode").string ()
<< " " << status.ToString ();
StopSustain ();
exit (3);
}
}
else
{
WriteLog (lsINFO, Application) << "SQLite used for nodes";
boost::thread t5 (BIND_TYPE (&InitDB, &mHashNodeDB, "hashnode.db", HashNodeDBInit, HashNodeDBCount));
t5.join ();
}
if (!theConfig.LDB_EPHEMERAL.empty ())
{
leveldb::Status status = leveldb::DB::Open (options, theConfig.LDB_EPHEMERAL, &mEphemeralLDB);
if (!status.ok () || !mEphemeralLDB)
{
WriteLog (lsFATAL, Application) << "Unable to open/create epehemeral db: "
<< theConfig.LDB_EPHEMERAL << " " << status.ToString ();
StopSustain ();
exit (3);
}
}
if (!m_nodeStore.isLevelDB ())
{
getApp().getHashNodeDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
(theConfig.getSize (siHashNodeDBCache) * 1024)));
getApp().getHashNodeDB ()->getDB ()->setupCheckpointing (&mJobQueue);
}
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
(theConfig.getSize (siLgrDBCache) * 1024)));
getApp().getTxnDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
@@ -501,7 +454,7 @@ void Application::setup ()
mLedgerDB->getDB ()->setupCheckpointing (&mJobQueue);
if (!theConfig.RUN_STANDALONE)
updateTables (theConfig.LDB_IMPORT);
updateTables ();
mFeatures->addInitialFeatures ();
@@ -980,7 +933,7 @@ static void addTxnSeqField ()
db->executeSQL ("END TRANSACTION;");
}
void Application::updateTables (bool ldbImport)
void Application::updateTables ()
{
// perform any needed table updates
assert (schemaHas (getApp().getTxnDB (), "AccountTransactions", 0, "TransID"));
@@ -994,27 +947,8 @@ void Application::updateTables (bool ldbImport)
exit (1);
}
if (getApp().getNodeStore ().isLevelDB ())
{
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists (hashPath))
{
if (theConfig.LDB_IMPORT)
{
Log (lsWARNING) << "Importing SQLite -> LevelDB";
getApp().getNodeStore ().import (hashPath.string ());
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";
StopSustain ();
exit (1);
}
}
}
if (!theConfig.DB_IMPORT.empty())
getApp().getNodeStore().import(theConfig.DB_IMPORT);
}
//------------------------------------------------------------------------------

View File

@@ -174,7 +174,7 @@ int rippleMain (int argc, char** argv)
("start", "Start from a fresh Ledger.")
("net", "Get the initial ledger from the network.")
("fg", "Run in the foreground.")
("import", "Import SQLite node DB into LevelDB.")
("import", po::value<std::string> (), "Import old DB into new DB.")
;
// Interpret positional arguments as --parameters.
@@ -271,7 +271,8 @@ int rippleMain (int argc, char** argv)
if (vm.count ("start")) theConfig.START_UP = Config::FRESH;
if (vm.count ("import")) theConfig.LDB_IMPORT = true;
if (vm.count ("import"))
theConfig.DB_IMPORT = vm["import"].as<std::string> ();
if (vm.count ("ledger"))
{