20 #include <ripple/app/ledger/InboundLedger.h>
21 #include <ripple/app/ledger/LedgerReplayer.h>
22 #include <ripple/app/ledger/impl/SkipListAcquire.h>
23 #include <ripple/app/main/Application.h>
24 #include <ripple/core/JobQueue.h>
25 #include <ripple/overlay/PeerSet.h>
37 LedgerReplayParameters::SUB_TASK_TIMEOUT,
41 app.journal(
"LedgerReplaySkipList"))
42 , inboundLedgers_(inboundLedgers)
43 , peerSet_(std::move(peerSet))
45 JLOG(journal_.trace()) <<
"Create " << hash_;
80 peer->hasLedger(
hash_, 0);
86 <<
"Add a peer " << peer->id() <<
" for " <<
hash_;
87 protocol::TMProofPathRequest request;
92 protocol::TMLedgerMapType::lmACCOUNT_STATE);
93 peerSet_->sendRequest(request, peer);
98 << peer->id() <<
" for " <<
hash_;
140 boost::intrusive_ptr<SHAMapItem const>
const& item)
142 assert(ledgerSeq != 0 && item);
151 std::make_shared<SLE>(
SerialIter{item->slice()}, item->key());
154 if (
auto const& skipList = sle->getFieldV256(
sfHashes).value();
165 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from verified data "
178 <<
"task added to a finished SkipListAcquire " <<
hash_;
195 if (
auto const hashIndex = ledger->read(
keylet::skip());
196 hashIndex && hashIndex->isFieldPresent(
sfHashes))
198 auto const& slist = hashIndex->getFieldV256(
sfHashes).value();
207 JLOG(
journal_.
error()) <<
"failed to retrieve Skip list from a ledger "
219 data_ = std::make_shared<SkipListData>(ledgerSeq, skipList);
233 for (
auto& cb : toCall)
~SkipListAcquire() override
constexpr std::uint32_t SUB_TASK_MAX_TIMEOUTS
void retrieveSkipList(std::shared_ptr< Ledger const > const &ledger, ScopedLockType &sl)
Retrieve the skip list from the ledger.
constexpr auto SUB_TASK_FALLBACK_TIMEOUT
Stream trace() const
Severity stream access functions.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
InboundLedgers & inboundLedgers_
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
SkipListAcquire(Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::unique_ptr< PeerSet > peerSet)
Constructor.
Keylet const & skip() noexcept
The index of the "short" skip list.
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
std::uint32_t noFeaturePeerCount_
void onSkipListAcquired(std::vector< uint256 > const &skipList, std::uint32_t ledgerSeq, ScopedLockType &sl)
Process the skip list.
This class is an "active" object.
std::recursive_mutex mtx_
constexpr static std::size_t size()
constexpr std::uint32_t MAX_QUEUED_TASKS
T shared_from_this(T... args)
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
virtual LedgerMaster & getLedgerMaster()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
void init(int numPeers)
Start the SkipListAcquire task.
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
std::vector< OnSkipListDataCB > dataReadyCallbacks_
Manages the lifetime of inbound ledgers.
const SF_VECTOR256 sfHashes
std::shared_ptr< SkipListData const > data_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unique_ptr< PeerSet > peerSet_
void addDataCallback(OnSkipListDataCB &&cb)
Add a callback that will be called when the skipList is ready or failed.
const uint256 hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
void notify(ScopedLockType &sl)
Call the OnSkipListDataCB callbacks.
constexpr auto MAX_NO_FEATURE_PEER_COUNT
void processData(std::uint32_t ledgerSeq, boost::intrusive_ptr< SHAMapItem const > const &item)
Process the data extracted from a peer's reply.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
std::shared_ptr< SkipListData const > getData() const