Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/software/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ stellar-core can be controlled via the following commands.
controls type used for printing (default: auto).<br>
Option --base64 alters the behavior to work on base64-encoded XDR rather than
raw XDR.
* **publish**: Execute publish of all items remaining in publish queue without
connecting to network. May not publish last checkpoint if last closed ledger
is on checkpoint boundary.
* **report-last-history-checkpoint**: Download and report last history
checkpoint from a history archive.
* **run**: Runs stellar-core service.
Expand Down
56 changes: 36 additions & 20 deletions src/main/ApplicationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,25 +331,7 @@ catchup(Application::pointer app, CatchupConfiguration cc,
return 1;
}

// set known cursors before starting maintenance job
ExternalQueue ps(*app);
ps.setInitialCursors(app->getConfig().KNOWN_CURSORS);
app->getMaintainer().start();

auto done = false;
app->getLedgerManager().loadLastKnownLedger(
[&done](asio::error_code const& ec) {
if (ec)
{
throw std::runtime_error(
"Unable to restore last-known ledger state");
}

done = true;
});
auto& clock = app->getClock();
while (!done && clock.crank(true))
;
app->start();

try
{
Expand All @@ -367,10 +349,11 @@ catchup(Application::pointer app, CatchupConfiguration cc,
return 2;
}

auto& clock = app->getClock();
auto& io = clock.getIOService();
auto synced = false;
asio::io_service::work mainWork(io);
done = false;
auto done = false;
while (!done && clock.crank(true))
{
switch (app->getLedgerManager().getState())
Expand Down Expand Up @@ -425,4 +408,37 @@ catchup(Application::pointer app, CatchupConfiguration cc,
catchupInfo = app->getJsonInfo();
return synced ? 0 : 3;
}

int
publish(Application::pointer app)
{
if (!checkInitialized(app))
{
return 1;
}

app->start();

auto& clock = app->getClock();
auto& io = clock.getIOService();
asio::io_service::work mainWork(io);

auto lcl = app->getLedgerManager().getLastClosedLedgerNum();
auto isCheckpoint =
lcl == app->getHistoryManager().checkpointContainingLedger(lcl);
auto expectedPublishQueueSize = isCheckpoint ? 1 : 0;

app->getHistoryManager().publishQueuedHistory();
while (app->getHistoryManager().publishQueueLength() !=
expectedPublishQueueSize &&
clock.crank(true))
{
}

LOG(INFO) << "*";
LOG(INFO) << "* Publish finished.";
LOG(INFO) << "*";

return 0;
}
}
1 change: 1 addition & 0 deletions src/main/ApplicationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ void writeCatchupInfo(Json::Value const& catchupInfo,
std::string const& outputFile);
int catchup(Application::pointer app, CatchupConfiguration cc,
Json::Value& catchupInfo);
int publish(Application::pointer app);
}
20 changes: 20 additions & 0 deletions src/main/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,21 @@ runCatchup(CommandLineArgs const& args)
});
}

int
runPublish(CommandLineArgs const& args)
{
CommandLine::ConfigOption configOption;

return runWithHelp(args, {configurationParser(configOption)}, [&] {
auto config = configOption.getConfig();
config.setNoListen();

VirtualClock clock(VirtualClock::REAL_TIME);
auto app = Application::create(clock, config, false);
return publish(app);
});
}

int
runCheckQuorum(CommandLineArgs const& args)
{
Expand Down Expand Up @@ -712,6 +727,11 @@ handleCommandLine(int argc, char* const* argv)
{"offline-info", "return information for an offline instance",
runOfflineInfo},
{"print-xdr", "pretty-print one XDR envelope, then quit", runPrintXdr},
{"publish",
"execute publish of all items remaining in publish queue without "
"connecting to network, may not publish last checkpoint if last "
"closed ledger is on checkpoint boundary",
runPublish},
{"report-last-history-checkpoint",
"report information about last checkpoint available in "
"history archives",
Expand Down