20#include <xrpld/app/ledger/InboundLedger.h>
21#include <xrpld/app/ledger/LedgerReplayer.h>
22#include <xrpld/app/ledger/detail/SkipListAcquire.h>
23#include <xrpld/app/main/Application.h>
24#include <xrpld/overlay/PeerSet.h>
36 LedgerReplayParameters::SUB_TASK_TIMEOUT,
40 app.journal(
"LedgerReplaySkipList"))
41 , inboundLedgers_(inboundLedgers)
42 , peerSet_(std::move(peerSet))
44 JLOG(journal_.trace()) <<
"Create " << hash_;
79 peer->hasLedger(
hash_, 0);
85 <<
"Add a peer " << peer->id() <<
" for " <<
hash_;
86 protocol::TMProofPathRequest request;
91 protocol::TMLedgerMapType::lmACCOUNT_STATE);
92 peerSet_->sendRequest(request, peer);
97 << peer->id() <<
" for " <<
hash_;
139 boost::intrusive_ptr<SHAMapItem const>
const& item)
142 ledgerSeq != 0 && item,
143 "ripple::SkipListAcquire::processData : valid inputs");
152 std::make_shared<SLE>(
SerialIter{item->slice()}, item->key());
155 if (
auto const& skipList = sle->getFieldV256(sfHashes).value();
166 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from verified data "
179 <<
"task added to a finished SkipListAcquire " <<
hash_;
196 if (
auto const hashIndex = ledger->read(
keylet::skip());
197 hashIndex && hashIndex->isFieldPresent(sfHashes))
199 auto const& slist = hashIndex->getFieldV256(sfHashes).value();
208 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from a ledger "
220 data_ = std::make_shared<SkipListData>(ledgerSeq, skipList);
228 XRPL_ASSERT(
isDone(),
"ripple::SkipListAcquire::notify : is done");
234 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)