|
rippled
|
Manage the retrieval of a ledger delta (header and transactions) from the network. More...
#include <LedgerDeltaAcquire.h>


Public Types | |
| using | OnDeltaDataCB = std::function< void(bool successful, uint256 const &hash)> |
| A callback used to notify that the delta's data is ready or failed. | |
Public Member Functions | |
| LedgerDeltaAcquire (Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::uint32_t ledgerSeq, std::unique_ptr< PeerSet > peerSet) | |
| Constructor. | |
| ~LedgerDeltaAcquire () override | |
| void | init (int numPeers) |
| Start the LedgerDeltaAcquire task. | |
| void | processData (LedgerHeader const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&orderedTxns) |
| Process the data extracted from a peer's reply. | |
| std::shared_ptr< Ledger const > | tryBuild (std::shared_ptr< Ledger const > const &parent) |
| Try to build the ledger if not already. | |
| void | addDataCallback (InboundLedger::Reason reason, OnDeltaDataCB &&cb) |
| Add a reason and a callback to the LedgerDeltaAcquire subtask. | |
| virtual void | cancel () |
| Cancel the task by marking it as failed if the task is not done. | |
| T | shared_from_this (T... args) |
| T | weak_from_this (T... args) |
Protected Types | |
| using | ScopedLockType = std::unique_lock< std::recursive_mutex > |
Protected Member Functions | |
| void | setTimer (ScopedLockType &) |
| Schedule a call to queueJob() after mTimerInterval. | |
| void | queueJob (ScopedLockType &) |
| Queue a job to call invokeOnTimer(). | |
| bool | isDone () const |
Protected Attributes | |
| Application & | app_ |
| beast::Journal | journal_ |
| std::recursive_mutex | mtx_ |
| uint256 const | hash_ |
| The hash of the object (in practice, always a ledger) we are trying to fetch. | |
| int | timeouts_ |
| bool | complete_ |
| bool | failed_ |
| bool | progress_ |
| Whether forward progress has been made. | |
| std::chrono::milliseconds | timerInterval_ |
| The minimum time to wait between calls to execute(). | |
| QueueJobParameter | queueJobParameter_ |
Private Member Functions | |
| void | onTimer (bool progress, ScopedLockType &peerSetLock) override |
| Hook called from invokeOnTimer(). | |
| std::weak_ptr< TimeoutCounter > | pmDowncast () override |
| Return a weak pointer to this. | |
| void | trigger (std::size_t limit, ScopedLockType &sl) |
| Trigger another round. | |
| void | onLedgerBuilt (ScopedLockType &sl, std::optional< InboundLedger::Reason > reason={}) |
| Process a newly built ledger, such as store it. | |
| void | notify (ScopedLockType &sl) |
| Call the OnDeltaDataCB callbacks. | |
| void | invokeOnTimer () |
| Calls onTimer() if in the right state. | |
Static Private Member Functions | |
| static auto & | getCounter () noexcept |
Private Attributes | |
| InboundLedgers & | inboundLedgers_ |
| std::uint32_t const | ledgerSeq_ |
| std::unique_ptr< PeerSet > | peerSet_ |
| std::shared_ptr< Ledger const > | replayTemp_ = {} |
| std::shared_ptr< Ledger const > | fullLedger_ = {} |
| std::map< std::uint32_t, std::shared_ptr< STTx const > > | orderedTxns_ |
| std::vector< OnDeltaDataCB > | dataReadyCallbacks_ |
| std::set< InboundLedger::Reason > | reasons_ |
| std::uint32_t | noFeaturePeerCount = 0 |
| bool | fallBack_ = false |
| boost::asio::basic_waitable_timer< std::chrono::steady_clock > | timer_ |
Friends | |
| class | LedgerReplayTask |
| class | test::LedgerReplayClient |
Manage the retrieval of a ledger delta (header and transactions) from the network.
Before asking peers, always check if the local node has the ledger.
Definition at line 24 of file LedgerDeltaAcquire.h.
| using xrpl::LedgerDeltaAcquire::OnDeltaDataCB = std::function<void(bool successful, uint256 const& hash)> |
A callback used to notify that the delta's data is ready or failed.
| successful | if the ledger delta data was acquired successfully |
| hash | hash of the ledger to build |
Definition at line 34 of file LedgerDeltaAcquire.h.
|
protectedinherited |
Definition at line 63 of file TimeoutCounter.h.
| xrpl::LedgerDeltaAcquire::LedgerDeltaAcquire | ( | Application & | app, |
| InboundLedgers & | inboundLedgers, | ||
| uint256 const & | ledgerHash, | ||
| std::uint32_t | ledgerSeq, | ||
| std::unique_ptr< PeerSet > | peerSet | ||
| ) |
Constructor.
| app | Application reference |
| inboundLedgers | InboundLedgers reference |
| ledgerHash | hash of the ledger |
| ledgerSeq | sequence number of the ledger |
| peerSet | manage a set of peers that we will ask for the ledger |
Definition at line 13 of file LedgerDeltaAcquire.cpp.
|
override |
Definition at line 32 of file LedgerDeltaAcquire.cpp.
| void xrpl::LedgerDeltaAcquire::init | ( | int | numPeers | ) |
Start the LedgerDeltaAcquire task.
| numPeers | number of peers to try initially |
Definition at line 38 of file LedgerDeltaAcquire.cpp.
| void xrpl::LedgerDeltaAcquire::processData | ( | LedgerHeader const & | info, |
| std::map< std::uint32_t, std::shared_ptr< STTx const > > && | orderedTxns | ||
| ) |
Process the data extracted from a peer's reply.
| info | info (header) of the ledger |
| orderedTxns | set of Txns of the ledger |
Definition at line 114 of file LedgerDeltaAcquire.cpp.
| std::shared_ptr< Ledger const > xrpl::LedgerDeltaAcquire::tryBuild | ( | std::shared_ptr< Ledger const > const & | parent | ) |
Try to build the ledger if not already.
| parent | parent ledger |
Definition at line 162 of file LedgerDeltaAcquire.cpp.
| void xrpl::LedgerDeltaAcquire::addDataCallback | ( | InboundLedger::Reason | reason, |
| OnDeltaDataCB && | cb | ||
| ) |
Add a reason and a callback to the LedgerDeltaAcquire subtask.
The reason is used to process the ledger once it is replayed. The callback is called when the delta's data is ready or failed
Definition at line 143 of file LedgerDeltaAcquire.cpp.
|
overrideprivatevirtual |
Hook called from invokeOnTimer().
Implements xrpl::TimeoutCounter.
Definition at line 92 of file LedgerDeltaAcquire.cpp.
|
overrideprivatevirtual |
Return a weak pointer to this.
Implements xrpl::TimeoutCounter.
Definition at line 108 of file LedgerDeltaAcquire.cpp.
|
private |
Trigger another round.
| limit | number of new peers to send the request |
| sl | lock. this function must be called with the lock |
Definition at line 49 of file LedgerDeltaAcquire.cpp.
|
private |
Process a newly built ledger, such as store it.
| sl | lock. this function must be called with the lock |
| reason | specific new reason if any |
Definition at line 195 of file LedgerDeltaAcquire.cpp.
|
private |
Call the OnDeltaDataCB callbacks.
| sl | lock. this function must be called with the lock |
Definition at line 227 of file LedgerDeltaAcquire.cpp.
|
virtualinherited |
Cancel the task by marking it as failed if the task is not done.
Definition at line 94 of file TimeoutCounter.cpp.
|
protectedinherited |
Schedule a call to queueJob() after mTimerInterval.
Definition at line 32 of file TimeoutCounter.cpp.
|
protectedinherited |
Queue a job to call invokeOnTimer().
Definition at line 50 of file TimeoutCounter.cpp.
|
protectedinherited |
Definition at line 98 of file TimeoutCounter.h.
|
privateinherited |
Calls onTimer() if in the right state.
Only called by queueJob().
Definition at line 69 of file TimeoutCounter.cpp.
|
staticprivatenoexceptinherited |
Definition at line 109 of file CountedObject.h.
|
friend |
Definition at line 134 of file LedgerDeltaAcquire.h.
|
friend |
Definition at line 135 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 123 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 124 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 125 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 126 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 127 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 128 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 129 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 130 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 131 of file LedgerDeltaAcquire.h.
|
private |
Definition at line 132 of file LedgerDeltaAcquire.h.
|
protectedinherited |
Definition at line 105 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 106 of file TimeoutCounter.h.
|
mutableprotectedinherited |
Definition at line 107 of file TimeoutCounter.h.
|
protectedinherited |
The hash of the object (in practice, always a ledger) we are trying to fetch.
Definition at line 111 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 112 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 113 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 114 of file TimeoutCounter.h.
|
protectedinherited |
Whether forward progress has been made.
Definition at line 116 of file TimeoutCounter.h.
|
protectedinherited |
The minimum time to wait between calls to execute().
Definition at line 118 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 120 of file TimeoutCounter.h.
|
privateinherited |
Definition at line 129 of file TimeoutCounter.h.