|
rippled
|
Manage the retrieval of a skip list in a ledger from the network. More...
#include <SkipListAcquire.h>


Classes | |
| struct | SkipListData |
Public Types | |
| using | OnSkipListDataCB = std::function< void(bool successful, uint256 const &hash)> |
| A callback used to notify that the SkipList is ready or failed. | |
Public Member Functions | |
| SkipListAcquire (Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::unique_ptr< PeerSet > peerSet) | |
| Constructor. | |
| ~SkipListAcquire () override | |
| void | init (int numPeers) |
| Start the SkipListAcquire task. | |
| void | processData (std::uint32_t ledgerSeq, boost::intrusive_ptr< SHAMapItem const > const &item) |
| Process the data extracted from a peer's reply. | |
| void | addDataCallback (OnSkipListDataCB &&cb) |
| Add a callback that will be called when the skipList is ready or failed. | |
| std::shared_ptr< SkipListData const > | getData () const |
| 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 | retrieveSkipList (std::shared_ptr< Ledger const > const &ledger, ScopedLockType &sl) |
| Retrieve the skip list from the ledger. | |
| void | onSkipListAcquired (std::vector< uint256 > const &skipList, std::uint32_t ledgerSeq, ScopedLockType &sl) |
| Process the skip list. | |
| void | notify (ScopedLockType &sl) |
| Call the OnSkipListDataCB callbacks. | |
| void | invokeOnTimer () |
| Calls onTimer() if in the right state. | |
Static Private Member Functions | |
| static auto & | getCounter () noexcept |
Private Attributes | |
| InboundLedgers & | inboundLedgers_ |
| std::unique_ptr< PeerSet > | peerSet_ |
| std::vector< OnSkipListDataCB > | dataReadyCallbacks_ |
| std::shared_ptr< SkipListData const > | data_ |
| std::uint32_t | noFeaturePeerCount_ = 0 |
| bool | fallBack_ = false |
| boost::asio::basic_waitable_timer< std::chrono::steady_clock > | timer_ |
Friends | |
| class | test::LedgerReplayClient |
Manage the retrieval of a skip list in a ledger from the network.
Before asking peers, always check if the local node has the ledger.
Definition at line 22 of file SkipListAcquire.h.
| using ripple::SkipListAcquire::OnSkipListDataCB = std::function<void(bool successful, uint256 const& hash)> |
A callback used to notify that the SkipList is ready or failed.
| successful | if the skipList data was acquired successfully |
| hash | hash of the ledger that has the skipList |
Definition at line 33 of file SkipListAcquire.h.
|
protectedinherited |
Definition at line 64 of file TimeoutCounter.h.
| ripple::SkipListAcquire::SkipListAcquire | ( | Application & | app, |
| InboundLedgers & | inboundLedgers, | ||
| uint256 const & | ledgerHash, | ||
| std::unique_ptr< PeerSet > | peerSet | ||
| ) |
Constructor.
| app | Application reference |
| inboundLedgers | InboundLedgers reference |
| ledgerHash | hash of the ledger that has the skip list |
| peerSet | manage a set of peers that we will ask for the skip list |
Definition at line 9 of file SkipListAcquire.cpp.
|
override |
Definition at line 28 of file SkipListAcquire.cpp.
| void ripple::SkipListAcquire::init | ( | int | numPeers | ) |
Start the SkipListAcquire task.
| numPeers | number of peers to try initially |
Definition at line 34 of file SkipListAcquire.cpp.
| void ripple::SkipListAcquire::processData | ( | std::uint32_t | ledgerSeq, |
| boost::intrusive_ptr< SHAMapItem const > const & | item | ||
| ) |
Process the data extracted from a peer's reply.
| ledgerSeq | sequence number of the ledger that has the skip list |
| item | holder of the skip list |
Definition at line 118 of file SkipListAcquire.cpp.
| void ripple::SkipListAcquire::addDataCallback | ( | OnSkipListDataCB && | cb | ) |
Add a callback that will be called when the skipList is ready or failed.
Definition at line 153 of file SkipListAcquire.cpp.
| std::shared_ptr< SkipListAcquire::SkipListData const > ripple::SkipListAcquire::getData | ( | ) | const |
Definition at line 166 of file SkipListAcquire.cpp.
|
overrideprivatevirtual |
Hook called from invokeOnTimer().
Implements ripple::TimeoutCounter.
Definition at line 96 of file SkipListAcquire.cpp.
|
overrideprivatevirtual |
Return a weak pointer to this.
Implements ripple::TimeoutCounter.
Definition at line 112 of file SkipListAcquire.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 45 of file SkipListAcquire.cpp.
|
private |
Retrieve the skip list from the ledger.
| ledger | the ledger that has the skip list |
| sl | lock. this function must be called with the lock |
Definition at line 173 of file SkipListAcquire.cpp.
|
private |
Process the skip list.
| skipList | skip list |
| ledgerSeq | sequence number of the ledger that has the skip list |
| sl | lock. this function must be called with the lock |
Definition at line 195 of file SkipListAcquire.cpp.
|
private |
Call the OnSkipListDataCB callbacks.
| sl | lock. this function must be called with the lock |
Definition at line 207 of file SkipListAcquire.cpp.
|
virtualinherited |
Cancel the task by marking it as failed if the task is not done.
Definition at line 99 of file TimeoutCounter.cpp.
|
protectedinherited |
Schedule a call to queueJob() after mTimerInterval.
Definition at line 31 of file TimeoutCounter.cpp.
|
protectedinherited |
Queue a job to call invokeOnTimer().
Definition at line 50 of file TimeoutCounter.cpp.
|
protectedinherited |
Definition at line 99 of file TimeoutCounter.h.
|
privateinherited |
Calls onTimer() if in the right state.
Only called by queueJob().
Definition at line 74 of file TimeoutCounter.cpp.
|
staticprivatenoexceptinherited |
Definition at line 110 of file CountedObject.h.
|
friend |
Definition at line 144 of file SkipListAcquire.h.
|
private |
Definition at line 137 of file SkipListAcquire.h.
|
private |
Definition at line 138 of file SkipListAcquire.h.
|
private |
Definition at line 139 of file SkipListAcquire.h.
|
private |
Definition at line 140 of file SkipListAcquire.h.
|
private |
Definition at line 141 of file SkipListAcquire.h.
|
private |
Definition at line 142 of file SkipListAcquire.h.
|
protectedinherited |
Definition at line 106 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 107 of file TimeoutCounter.h.
|
mutableprotectedinherited |
Definition at line 108 of file TimeoutCounter.h.
|
protectedinherited |
The hash of the object (in practice, always a ledger) we are trying to fetch.
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 |
Definition at line 115 of file TimeoutCounter.h.
|
protectedinherited |
Whether forward progress has been made.
Definition at line 117 of file TimeoutCounter.h.
|
protectedinherited |
The minimum time to wait between calls to execute().
Definition at line 119 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 121 of file TimeoutCounter.h.
|
privateinherited |
Definition at line 130 of file TimeoutCounter.h.