Ledger load fixes.

Quick and dirty check for filesystme space.
This commit is contained in:
JoelKatz
2013-01-07 23:57:06 -08:00
parent cc2588aba2
commit fc1dc50afc

View File

@@ -127,7 +127,7 @@ void Application::run()
} }
else if (theConfig.START_UP == Config::LOAD) else if (theConfig.START_UP == Config::LOAD)
{ {
cLog(lsINFO) << "Loading Old Ledger"; cLog(lsINFO) << "Loading specified Ledger";
loadOldLedger(theConfig.START_LEDGER); loadOldLedger(theConfig.START_LEDGER);
} }
@@ -270,6 +270,14 @@ void Application::run()
void Application::sweep() void Application::sweep()
{ {
boost::filesystem::space_info space = boost::filesystem::space(theConfig.DATA_DIR);
if (space.available < (128 * 1024 * 1024))
{
cLog(lsFATAL) << "Remaining free disk space is less than 128MB";
theApp->stop();
}
mMasterTransaction.sweep(); mMasterTransaction.sweep();
mHashedObjectStore.sweep(); mHashedObjectStore.sweep();
mLedgerMaster.sweep(); mLedgerMaster.sweep();
@@ -324,13 +332,13 @@ void Application::loadOldLedger(const std::string& l)
Ledger::pointer loadLedger; Ledger::pointer loadLedger;
if (l.empty() || (l == "latest")) if (l.empty() || (l == "latest"))
loadLedger = Ledger::getLastFullLedger(); loadLedger = Ledger::getLastFullLedger();
if (l.length() == 64) else if (l.length() == 64)
{ { // by hash
uint256 hash; uint256 hash;
hash.SetHex(l); hash.SetHex(l);
loadLedger = Ledger::loadByHash(hash); loadLedger = Ledger::loadByHash(hash);
} }
else else // assume by sequence
loadLedger = Ledger::loadByIndex(boost::lexical_cast<uint32>(l)); loadLedger = Ledger::loadByIndex(boost::lexical_cast<uint32>(l));
if (!loadLedger) if (!loadLedger)
@@ -368,7 +376,12 @@ void Application::loadOldLedger(const std::string& l)
} }
catch (SHAMapMissingNode& mn) catch (SHAMapMissingNode& mn)
{ {
cLog(lsFATAL) << "Cannot load ledger. " << mn; cLog(lsFATAL) << "Data is missing for selected ledger";
exit(-1);
}
catch (boost::bad_lexical_cast& blc)
{
cLog(lsFATAL) << "Ledger specified '" << l << "' is not valid";
exit(-1); exit(-1);
} }
} }