1#include <xrpld/app/ledger/InboundLedger.h>
2#include <xrpld/app/ledger/LedgerReplayer.h>
3#include <xrpld/app/ledger/detail/SkipListAcquire.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/overlay/PeerSet.h>
17 LedgerReplayParameters::SUB_TASK_TIMEOUT,
21 app.journal(
"LedgerReplaySkipList"))
22 , inboundLedgers_(inboundLedgers)
23 , peerSet_(std::move(peerSet))
25 JLOG(journal_.trace()) <<
"Create " << hash_;
60 peer->hasLedger(
hash_, 0);
66 <<
"Add a peer " << peer->id() <<
" for " <<
hash_;
67 protocol::TMProofPathRequest request;
72 protocol::TMLedgerMapType::lmACCOUNT_STATE);
73 peerSet_->sendRequest(request, peer);
78 << peer->id() <<
" for " <<
hash_;
120 boost::intrusive_ptr<SHAMapItem const>
const& item)
123 ledgerSeq != 0 && item,
124 "ripple::SkipListAcquire::processData : valid inputs");
136 if (
auto const& skipList = sle->getFieldV256(sfHashes).value();
147 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from verified data "
160 <<
"task added to a finished SkipListAcquire " <<
hash_;
177 if (
auto const hashIndex = ledger->read(
keylet::skip());
178 hashIndex && hashIndex->isFieldPresent(sfHashes))
180 auto const& slist = hashIndex->getFieldV256(sfHashes).value();
189 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from a ledger "
209 XRPL_ASSERT(
isDone(),
"ripple::SkipListAcquire::notify : is done");
215 for (
auto& cb : toCall)
Stream trace() const
Severity stream access functions.
virtual LedgerMaster & getLedgerMaster()=0
Manages the lifetime of inbound ledgers.
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
void init(int numPeers)
Start the SkipListAcquire task.
void addDataCallback(OnSkipListDataCB &&cb)
Add a callback that will be called when the skipList is ready or failed.
InboundLedgers & inboundLedgers_
std::shared_ptr< SkipListData const > getData() const
SkipListAcquire(Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::unique_ptr< PeerSet > peerSet)
Constructor.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
void notify(ScopedLockType &sl)
Call the OnSkipListDataCB callbacks.
void retrieveSkipList(std::shared_ptr< Ledger const > const &ledger, ScopedLockType &sl)
Retrieve the skip list from the ledger.
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
std::shared_ptr< SkipListData const > data_
void processData(std::uint32_t ledgerSeq, boost::intrusive_ptr< SHAMapItem const > const &item)
Process the data extracted from a peer's reply.
void onSkipListAcquired(std::vector< uint256 > const &skipList, std::uint32_t ledgerSeq, ScopedLockType &sl)
Process the skip list.
std::vector< OnSkipListDataCB > dataReadyCallbacks_
std::unique_ptr< PeerSet > peerSet_
~SkipListAcquire() override
std::uint32_t noFeaturePeerCount_
This class is an "active" object.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
std::recursive_mutex mtx_
static constexpr std::size_t size()
auto constexpr SUB_TASK_FALLBACK_TIMEOUT
std::uint32_t constexpr MAX_QUEUED_TASKS
std::uint32_t constexpr SUB_TASK_MAX_TIMEOUTS
auto constexpr MAX_NO_FEATURE_PEER_COUNT
Keylet const & skip() noexcept
The index of the "short" skip list.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T shared_from_this(T... args)