|
Clio
develop
The XRP Ledger API server.
|
Publishes ledgers in a synchronized fashion. More...
#include <LedgerPublisher.hpp>


Public Member Functions | |
| LedgerPublisher (util::async::AnyExecutionContext ctx, std::shared_ptr< BackendInterface > backend, std::shared_ptr< feed::SubscriptionManagerInterface > subscriptions, SystemState const &state, std::chrono::steady_clock::duration maxWaitForDbProgress=kDefaultMaxWaitForDbProgress) | |
| 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}) override |
| Attempt to read the specified ledger from the database, and then publish that ledger to the ledgers stream. | |
| void | publish (xrpl::LedgerHeader const &lgrInfo) |
| Publish the passed ledger asynchronously. | |
| std::uint32_t | lastPublishAgeSeconds () const override |
| Get time passed since last publish, in seconds. | |
| std::chrono::time_point< std::chrono::system_clock > | getLastPublish () const override |
| Get last publish time as a time point. | |
| std::uint32_t | lastCloseAgeSeconds () const override |
| 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. | |
| void | stop () override |
| Stops publishing. | |
Static Public Attributes | |
| static constexpr std::chrono::steady_clock::duration | kDefaultMaxWaitForDbProgress |
| Default for how long publish() waits while the DB is reachable but stays behind the requested ledger without making progress. | |
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 |
Create an instance of the publisher.
| ctx | The execution context used for the publishing strand |
| backend | The backend to read ledgers from |
| subscriptions | The subscription manager to publish ledgers to |
| state | The shared ETL state |
| maxWaitForDbProgress | How long publish() waits while the DB stays behind the requested ledger without making progress before asserting |
|
inlineoverridevirtual |
Get last publish time as a time point.
Implements etl::LedgerPublisherInterface.
|
inlineoverridevirtual |
Get time passed since last ledger close, in seconds.
Implements etl::LedgerPublisherInterface.
|
inlineoverridevirtual |
Get time passed since last publish, in seconds.
Implements etl::LedgerPublisherInterface.
|
inlineoverridevirtual |
Attempt to read the specified ledger from the database, and then publish that ledger to the ledgers stream.
The caller must only request ledgers that it has already seen committed to the database. While the ledger range can't be fetched, this waits indefinitely (until stop() is called). If the range is fetched but stays behind the requested ledger without progressing for longer than the configured maximum wait, the invariant is considered broken and this asserts: a restart is then the only way for the node to recover.
| 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 |
Implements etl::LedgerPublisherInterface.
|
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 |
|
inlineoverridevirtual |
Stops publishing.
Any ongoing or future publish(seq, ...) call returns false without waiting for the ledger to appear in the database.
Implements etl::LedgerPublisherInterface.
|
staticconstexpr |
Default for how long publish() waits while the DB is reachable but stays behind the requested ledger without making progress.