rippled
Loading...
Searching...
No Matches
LedgerReplayTask.h
1#ifndef XRPL_APP_LEDGER_LEDGERREPLAYTASK_H_INCLUDED
2#define XRPL_APP_LEDGER_LEDGERREPLAYTASK_H_INCLUDED
3
4#include <xrpld/app/ledger/InboundLedger.h>
5#include <xrpld/app/ledger/detail/TimeoutCounter.h>
6#include <xrpld/app/main/Application.h>
7
8#include <vector>
9
10namespace ripple {
11class InboundLedgers;
12class Ledger;
13class LedgerDeltaAcquire;
14class LedgerReplayer;
15class SkipListAcquire;
16namespace test {
17class LedgerReplayClient;
18} // namespace test
19
21 : public TimeoutCounter,
22 public std::enable_shared_from_this<LedgerReplayTask>,
23 public CountedObject<LedgerReplayTask>
24{
25public:
27 {
28 public:
29 // set on construct
32 std::uint32_t totalLedgers_; // including the start and the finish
33
34 // to be updated
36 std::vector<uint256> skipList_ = {}; // including the finishHash
39 bool full_ = false;
40
49 uint256 const& finishLedgerHash,
50 std::uint32_t totalNumLedgers);
51
61 bool
62 update(
63 uint256 const& hash,
64 std::uint32_t seq,
65 std::vector<uint256> const& sList);
66
68 bool
69 canMergeInto(TaskParameter const& existingTask) const;
70 };
71
82 Application& app,
83 InboundLedgers& inboundLedgers,
84 LedgerReplayer& replayer,
85 std::shared_ptr<SkipListAcquire>& skipListAcquirer,
86 TaskParameter&& parameter);
87
89
91 void
92 init();
93
99 void
101
102 TaskParameter const&
104 {
105 return parameter_;
106 }
107
109 bool
110 finished() const;
111
112private:
113 void
114 onTimer(bool progress, ScopedLockType& sl) override;
115
117 pmDowncast() override;
118
125 void
127 uint256 const& hash,
128 std::uint32_t seq,
129 std::vector<uint256> const& sList);
130
135 void
136 deltaReady(uint256 const& deltaHash);
137
142 void
144
149 void
151
155 uint32_t maxTimeouts_;
158 uint32_t deltaToBuild_ = 0; // should not build until have parent
160
162};
163
164} // namespace ripple
165
166#endif
Tracks the number of instances of an object.
Manages the lifetime of inbound ledgers.
bool update(uint256 const &hash, std::uint32_t seq, std::vector< uint256 > const &sList)
fill all the fields that was not filled during construction
bool canMergeInto(TaskParameter const &existingTask) const
check if this task can be merged into an existing task
void trigger(ScopedLockType &sl)
Trigger another round.
bool finished() const
return if the task is finished
std::vector< std::shared_ptr< LedgerDeltaAcquire > > deltas_
void addDelta(std::shared_ptr< LedgerDeltaAcquire > const &delta)
add a new LedgerDeltaAcquire subtask
void deltaReady(uint256 const &deltaHash)
Notify this task (by a LedgerDeltaAcquire subtask) that a delta is ready.
void init()
Start the task.
InboundLedgers & inboundLedgers_
std::shared_ptr< SkipListAcquire > skipListAcquirer_
void updateSkipList(uint256 const &hash, std::uint32_t seq, std::vector< uint256 > const &sList)
Update this task (by a SkipListAcquire subtask) when skip list is ready.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
TaskParameter const & getTaskParameter() const
void tryAdvance(ScopedLockType &sl)
Try to build more ledgers.
std::shared_ptr< Ledger const > parent_
void onTimer(bool progress, ScopedLockType &sl) override
Hook called from invokeOnTimer().
Manages the lifetime of ledger replay tasks.
This class is an "active" object.
std::unique_lock< std::recursive_mutex > ScopedLockType
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6