xrpld
Loading...
Searching...
No Matches
LedgerDeltaAcquire.h
1#pragma once
2
3#include <xrpld/app/ledger/InboundLedger.h>
4#include <xrpld/app/ledger/detail/TimeoutCounter.h>
5#include <xrpld/app/main/Application.h>
6
7#include <xrpl/basics/CountedObject.h>
8#include <xrpl/basics/base_uint.h>
9#include <xrpl/ledger/Ledger.h>
10#include <xrpl/protocol/LedgerHeader.h>
11#include <xrpl/protocol/STTx.h>
12
13#include <cstddef>
14#include <cstdint>
15#include <functional>
16#include <map>
17#include <memory>
18#include <optional>
19#include <set>
20#include <vector>
21
22namespace xrpl {
23class InboundLedgers;
24class PeerSet;
25namespace test {
27} // namespace test
28
35 public std::enable_shared_from_this<LedgerDeltaAcquire>,
36 public CountedObject<LedgerDeltaAcquire>
37{
38public:
44 using OnDeltaDataCB = std::function<void(bool successful, uint256 const& hash)>;
45
55 Application& app,
56 InboundLedgers& inboundLedgers,
57 uint256 const& ledgerHash,
58 std::uint32_t ledgerSeq,
60
61 ~LedgerDeltaAcquire() override;
62
67 void
68 init(int numPeers);
69
77 void
79 LedgerHeader const& info,
81
91
99 void
101
102private:
103 void
104 onTimer(bool progress, ScopedLockType& peerSetLock) override;
105
107 pmDowncast() override;
108
114 void
116
125 void
127
132 void
134
144 bool fallBack_ = false;
145
146 friend class LedgerReplayTask; // for asserts only
148};
149
150} // namespace xrpl
Manages the lifetime of inbound ledgers.
std::uint32_t const ledgerSeq_
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
void init(int numPeers)
Start the LedgerDeltaAcquire task.
std::shared_ptr< Ledger const > fullLedger_
void onLedgerBuilt(ScopedLockType &sl, std::optional< InboundLedger::Reason > reason={})
Process a newly built ledger, such as store it.
LedgerDeltaAcquire(Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::uint32_t ledgerSeq, std::unique_ptr< PeerSet > peerSet)
Constructor.
std::vector< OnDeltaDataCB > dataReadyCallbacks_
void processData(LedgerHeader const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&orderedTxns)
Process the data extracted from a peer's reply.
std::unique_ptr< PeerSet > peerSet_
std::set< InboundLedger::Reason > reasons_
void notify(ScopedLockType &sl)
Call the OnDeltaDataCB callbacks.
std::shared_ptr< Ledger const > replayTemp_
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
std::shared_ptr< Ledger const > tryBuild(std::shared_ptr< Ledger const > const &parent)
Try to build the ledger if not already.
std::map< std::uint32_t, std::shared_ptr< STTx const > > orderedTxns_
void addDataCallback(InboundLedger::Reason reason, OnDeltaDataCB &&cb)
Add a reason and a callback to the LedgerDeltaAcquire subtask.
std::function< void(bool successful, uint256 const &hash)> OnDeltaDataCB
A callback used to notify that the delta's data is ready or failed.
Supports data retrieval by managing a set of peers.
Definition PeerSet.h:30
TimeoutCounter(Application &app, uint256 const &targetHash, std::chrono::milliseconds timeoutInterval, QueueJobParameter &&jobParameter, beast::Journal journal)
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
BaseUInt< 256 > uint256
Definition base_uint.h:580
Information about the notional ledger backing the view.