Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
etl::impl::LedgerPublisher< CacheType > Class Template Reference

Publishes ledgers in a synchronized fashion. More...

#include <LedgerPublisher.hpp>

Public Member Functions

 LedgerPublisher (boost::asio::io_context &ioc, std::shared_ptr< BackendInterface > backend, CacheType &cache, std::shared_ptr< feed::SubscriptionManagerInterface > subscriptions, SystemState const &state)
 Create an instance of the publisher.
 
bool publish (uint32_t ledgerSequence, std::optional< uint32_t > maxAttempts, std::chrono::steady_clock::duration attemptsDelay=std::chrono::seconds{1})
 Attempt to read the specified ledger from the database, and then publish that ledger to the ledgers stream.
 
void publish (ripple::LedgerHeader const &lgrInfo)
 Publish the passed ledger asynchronously.
 
std::uint32_t lastPublishAgeSeconds () const
 Get time passed since last publish, in seconds.
 
std::chrono::time_point< std::chrono::system_clock > getLastPublish () const
 Get last publish time as a time point.
 
std::uint32_t lastCloseAgeSeconds () const
 Get time passed since last ledger close, in seconds.
 
std::optional< uint32_t > getLastPublishedSequence () const
 Get the sequence of the last schueduled ledger to publish, Be aware that the ledger may not have been published to network.
 

Detailed Description

template<typename CacheType>
class etl::impl::LedgerPublisher< CacheType >

Publishes ledgers in a synchronized fashion.

If ETL is started far behind the network, ledgers will be written and published very rapidly. Monitoring processes will publish ledgers as they are written. However, to publish a ledger, the monitoring process needs to read all of the transactions for that ledger from the database. Reading the transactions from the database requires network calls, which can be slow. It is imperative however that the monitoring processes keep up with the writer, else the monitoring processes will not be able to detect if the writer failed. Therefore, publishing each ledger (which includes reading all of the transactions from the database) is done from the application wide asio io_service, and a strand is used to ensure ledgers are published in order.

Member Function Documentation

◆ publish() [1/2]

template<typename CacheType >
void etl::impl::LedgerPublisher< CacheType >::publish ( ripple::LedgerHeader const & lgrInfo)
inline

Publish the passed ledger asynchronously.

All ledgers are published thru publishStrand_ which ensures that all publishes are performed in a serial fashion.

Parameters
lgrInfothe ledger to publish

◆ publish() [2/2]

template<typename CacheType >
bool etl::impl::LedgerPublisher< CacheType >::publish ( uint32_t ledgerSequence,
std::optional< uint32_t > maxAttempts,
std::chrono::steady_clock::duration attemptsDelay = std::chrono::seconds{1} )
inline

Attempt to read the specified ledger from the database, and then publish that ledger to the ledgers stream.

Parameters
ledgerSequencethe sequence of the ledger to publish
maxAttemptsthe number of times to attempt to read the ledger from the database
attemptsDelaythe delay between attempts to read the ledger from the database
Returns
Whether the ledger was found in the database and published

The documentation for this class was generated from the following file: