mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
Make it possible to start from a specific chosen ledger.
This commit is contained in:
@@ -129,7 +129,7 @@ void Application::run()
|
||||
{
|
||||
cLog(lsINFO) << "Loading Old Ledger";
|
||||
|
||||
loadOldLedger();
|
||||
loadOldLedger(theConfig.START_LEDGER);
|
||||
}
|
||||
else if (theConfig.START_UP == Config::NETWORK)
|
||||
{ // This should probably become the default once we have a stable network
|
||||
@@ -317,44 +317,54 @@ void Application::startNewLedger()
|
||||
}
|
||||
}
|
||||
|
||||
void Application::loadOldLedger()
|
||||
void Application::loadOldLedger(const std::string& l)
|
||||
{
|
||||
try
|
||||
{
|
||||
Ledger::pointer lastLedger = Ledger::getLastFullLedger();
|
||||
Ledger::pointer loadLedger;
|
||||
if (l.empty() || (l == "latest"))
|
||||
loadLedger = Ledger::getLastFullLedger();
|
||||
if (l.length() == 64)
|
||||
{
|
||||
uint256 hash;
|
||||
hash.SetHex(l);
|
||||
loadLedger = Ledger::loadByHash(hash);
|
||||
}
|
||||
else
|
||||
loadLedger = Ledger::loadByIndex(boost::lexical_cast<uint32>(l));
|
||||
|
||||
if (!lastLedger)
|
||||
if (!loadLedger)
|
||||
{
|
||||
cLog(lsFATAL) << "No Ledger found?" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
lastLedger->setClosed();
|
||||
loadLedger->setClosed();
|
||||
|
||||
cLog(lsINFO) << "Loading ledger " << lastLedger->getHash() << " seq:" << lastLedger->getLedgerSeq();
|
||||
cLog(lsINFO) << "Loading ledger " << loadLedger->getHash() << " seq:" << loadLedger->getLedgerSeq();
|
||||
|
||||
if (lastLedger->getAccountHash().isZero())
|
||||
if (loadLedger->getAccountHash().isZero())
|
||||
{
|
||||
cLog(lsFATAL) << "Ledger is empty.";
|
||||
assert(false);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!lastLedger->walkLedger())
|
||||
if (!loadLedger->walkLedger())
|
||||
{
|
||||
cLog(lsFATAL) << "Ledger is missing nodes.";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!lastLedger->assertSane())
|
||||
if (!loadLedger->assertSane())
|
||||
{
|
||||
cLog(lsFATAL) << "Ledger is not sane.";
|
||||
exit(-1);
|
||||
}
|
||||
mLedgerMaster.setLedgerRangePresent(0, lastLedger->getLedgerSeq());
|
||||
mLedgerMaster.setLedgerRangePresent(loadLedger->getLedgerSeq(), loadLedger->getLedgerSeq());
|
||||
|
||||
Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*lastLedger));
|
||||
mLedgerMaster.switchLedgers(lastLedger, openLedger);
|
||||
mNetOps.setLastCloseTime(lastLedger->getCloseTimeNC());
|
||||
Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*loadLedger));
|
||||
mLedgerMaster.switchLedgers(loadLedger, openLedger);
|
||||
mNetOps.setLastCloseTime(loadLedger->getCloseTimeNC());
|
||||
}
|
||||
catch (SHAMapMissingNode& mn)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ class Application
|
||||
boost::recursive_mutex mPeerMapLock;
|
||||
|
||||
void startNewLedger();
|
||||
void loadOldLedger();
|
||||
void loadOldLedger(const std::string&);
|
||||
|
||||
public:
|
||||
Application();
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
|
||||
enum StartUpType { FRESH, NORMAL, LOAD, NETWORK };
|
||||
StartUpType START_UP;
|
||||
std::string START_LEDGER;
|
||||
|
||||
// Database
|
||||
std::string DATABASE_PATH;
|
||||
|
||||
@@ -102,6 +102,7 @@ int main(int argc, char* argv[])
|
||||
("quiet,q", "Reduce diagnotics.")
|
||||
("verbose,v", "Verbose logging.")
|
||||
("load", "Load the current ledger from the local DB.")
|
||||
("ledger", po::value<std::string>(), "Load the specified ledger and start from .")
|
||||
("start", "Start from a fresh Ledger.")
|
||||
("net", "Get the initial ledger from the network.")
|
||||
;
|
||||
@@ -171,7 +172,15 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (vm.count("start")) theConfig.START_UP = Config::FRESH;
|
||||
else if (vm.count("load")) theConfig.START_UP = Config::LOAD;
|
||||
if (vm.count("ledger"))
|
||||
{
|
||||
theConfig.START_LEDGER = vm["ledger"].as<std::string>();
|
||||
theConfig.START_UP = Config::LOAD;
|
||||
}
|
||||
else if (vm.count("load"))
|
||||
{
|
||||
theConfig.START_UP = Config::LOAD;
|
||||
}
|
||||
else if (vm.count("net")) theConfig.START_UP = Config::NETWORK;
|
||||
|
||||
if (iResult)
|
||||
|
||||
Reference in New Issue
Block a user