rippled
Loading...
Searching...
No Matches
SkipListAcquire.h
1#pragma once
2
3#include <xrpld/app/ledger/InboundLedger.h>
4#include <xrpld/app/ledger/Ledger.h>
5#include <xrpld/app/ledger/detail/TimeoutCounter.h>
6#include <xrpld/app/main/Application.h>
7
8#include <xrpl/shamap/SHAMap.h>
9
10namespace xrpl {
11class InboundLedgers;
12class PeerSet;
13namespace test {
14class LedgerReplayClient;
15} // namespace test
16
21class SkipListAcquire final : public TimeoutCounter,
22 public std::enable_shared_from_this<SkipListAcquire>,
23 public CountedObject<SkipListAcquire>
24{
25public:
31 using OnSkipListDataCB = std::function<void(bool successful, uint256 const& hash)>;
32
43
52 Application& app,
53 InboundLedgers& inboundLedgers,
54 uint256 const& ledgerHash,
56
57 ~SkipListAcquire() override;
58
63 void
64 init(int numPeers);
65
72 void
73 processData(std::uint32_t ledgerSeq, boost::intrusive_ptr<SHAMapItem const> const& item);
74
80 void
82
84 getData() const;
85
86private:
87 void
88 onTimer(bool progress, ScopedLockType& peerSetLock) override;
89
91 pmDowncast() override;
92
98 void
100
106 void
108
115 void
117
122 void
124
130 bool fallBack_ = false;
131
133};
134
135} // namespace xrpl
Tracks the number of instances of an object.
Manages the lifetime of inbound ledgers.
Manage the retrieval of a skip list in a ledger from the network.
void addDataCallback(OnSkipListDataCB &&cb)
Add a callback that will be called when the skipList is ready or failed.
std::uint32_t noFeaturePeerCount_
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
std::unique_ptr< PeerSet > peerSet_
std::shared_ptr< SkipListData const > data_
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
void notify(ScopedLockType &sl)
Call the OnSkipListDataCB callbacks.
std::vector< OnSkipListDataCB > dataReadyCallbacks_
std::shared_ptr< SkipListData const > getData() const
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
InboundLedgers & inboundLedgers_
std::function< void(bool successful, uint256 const &hash)> OnSkipListDataCB
A callback used to notify that the SkipList is ready or failed.
void onSkipListAcquired(std::vector< uint256 > const &skipList, std::uint32_t ledgerSeq, ScopedLockType &sl)
Process the skip list.
void retrieveSkipList(std::shared_ptr< Ledger const > const &ledger, ScopedLockType &sl)
Retrieve the skip list from the ledger.
void processData(std::uint32_t ledgerSeq, boost::intrusive_ptr< SHAMapItem const > const &item)
Process the data extracted from a peer's reply.
void init(int numPeers)
Start the SkipListAcquire task.
This class is an "active" object.
std::unique_lock< std::recursive_mutex > ScopedLockType
Ledger replay client side.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::vector< xrpl::uint256 > const skipList
SkipListData(std::uint32_t const ledgerSeq, std::vector< xrpl::uint256 > const &skipList)