@@ -331,25 +331,7 @@ catchup(Application::pointer app, CatchupConfiguration cc,
331331 return 1 ;
332332 }
333333
334- // set known cursors before starting maintenance job
335- ExternalQueue ps (*app);
336- ps.setInitialCursors (app->getConfig ().KNOWN_CURSORS );
337- app->getMaintainer ().start ();
338-
339- auto done = false ;
340- app->getLedgerManager ().loadLastKnownLedger (
341- [&done](asio::error_code const & ec) {
342- if (ec)
343- {
344- throw std::runtime_error (
345- " Unable to restore last-known ledger state" );
346- }
347-
348- done = true ;
349- });
350- auto & clock = app->getClock ();
351- while (!done && clock.crank (true ))
352- ;
334+ app->start ();
353335
354336 try
355337 {
@@ -367,10 +349,11 @@ catchup(Application::pointer app, CatchupConfiguration cc,
367349 return 2 ;
368350 }
369351
352+ auto & clock = app->getClock ();
370353 auto & io = clock.getIOService ();
371354 auto synced = false ;
372355 asio::io_service::work mainWork (io);
373- done = false ;
356+ auto done = false ;
374357 while (!done && clock.crank (true ))
375358 {
376359 switch (app->getLedgerManager ().getState ())
@@ -425,4 +408,37 @@ catchup(Application::pointer app, CatchupConfiguration cc,
425408 catchupInfo = app->getJsonInfo ();
426409 return synced ? 0 : 3 ;
427410}
411+
412+ int
413+ publish (Application::pointer app)
414+ {
415+ if (!checkInitialized (app))
416+ {
417+ return 1 ;
418+ }
419+
420+ app->start ();
421+
422+ auto & clock = app->getClock ();
423+ auto & io = clock.getIOService ();
424+ asio::io_service::work mainWork (io);
425+
426+ auto lcl = app->getLedgerManager ().getLastClosedLedgerNum ();
427+ auto isCheckpoint =
428+ lcl == app->getHistoryManager ().checkpointContainingLedger (lcl);
429+ auto expectedPublishQueueSize = isCheckpoint ? 1 : 0 ;
430+
431+ app->getHistoryManager ().publishQueuedHistory ();
432+ while (app->getHistoryManager ().publishQueueLength () !=
433+ expectedPublishQueueSize &&
434+ clock.crank (true ))
435+ {
436+ }
437+
438+ LOG (INFO) << " *" ;
439+ LOG (INFO) << " * Publish finished." ;
440+ LOG (INFO) << " *" ;
441+
442+ return 0 ;
443+ }
428444}
0 commit comments