Clio develop
The XRP Ledger API server.
|
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. | |
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.
|
inline |
Publish the passed ledger asynchronously.
All ledgers are published thru publishStrand_ which ensures that all publishes are performed in a serial fashion.
lgrInfo | the ledger to publish |
|
inline |
Attempt to read the specified ledger from the database, and then publish that ledger to the ledgers stream.
ledgerSequence | the sequence of the ledger to publish |
maxAttempts | the number of times to attempt to read the ledger from the database |
attemptsDelay | the delay between attempts to read the ledger from the database |