rippled
Loading...
Searching...
No Matches
LedgerReplayTask.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 <vector>
8
9namespace xrpl {
10class InboundLedgers;
11class Ledger;
12class LedgerDeltaAcquire;
13class LedgerReplayer;
14class SkipListAcquire;
15namespace test {
16class LedgerReplayClient;
17} // namespace test
18
19class LedgerReplayTask final : public TimeoutCounter,
20 public std::enable_shared_from_this<LedgerReplayTask>,
21 public CountedObject<LedgerReplayTask>
22{
23public:
25 {
26 public:
27 // set on construct
30 std::uint32_t totalLedgers_; // including the start and the finish
31
32 // to be updated
34 std::vector<uint256> skipList_ = {}; // including the finishHash
37 bool full_ = false;
38
47 uint256 const& finishLedgerHash,
48 std::uint32_t totalNumLedgers);
49
59 bool
60 update(uint256 const& hash, std::uint32_t seq, std::vector<uint256> const& sList);
61
63 bool
64 canMergeInto(TaskParameter const& existingTask) const;
65 };
66
77 Application& app,
78 InboundLedgers& inboundLedgers,
79 LedgerReplayer& replayer,
80 std::shared_ptr<SkipListAcquire>& skipListAcquirer,
81 TaskParameter const& parameter);
82
84
86 void
87 init();
88
94 void
96
97 TaskParameter const&
99 {
100 return parameter_;
101 }
102
104 bool
105 finished() const;
106
107private:
108 void
109 onTimer(bool progress, ScopedLockType& sl) override;
110
112 pmDowncast() override;
113
120 void
121 updateSkipList(uint256 const& hash, std::uint32_t seq, std::vector<uint256> const& sList);
122
127 void
128 deltaReady(uint256 const& deltaHash);
129
134 void
136
141 void
143
147 uint32_t maxTimeouts_;
150 uint32_t deltaToBuild_ = 0; // should not build until have parent
152
154};
155
156} // namespace xrpl
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.
void onTimer(bool progress, ScopedLockType &sl) override
Hook called from invokeOnTimer().
LedgerReplayer & replayer_
InboundLedgers & inboundLedgers_
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.
void tryAdvance(ScopedLockType &sl)
Try to build more ledgers.
void deltaReady(uint256 const &deltaHash)
Notify this task (by a LedgerDeltaAcquire subtask) that a delta is ready.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
TaskParameter const & getTaskParameter() const
std::vector< std::shared_ptr< LedgerDeltaAcquire > > deltas_
bool finished() const
return if the task is finished
void addDelta(std::shared_ptr< LedgerDeltaAcquire > const &delta)
add a new LedgerDeltaAcquire subtask
std::shared_ptr< Ledger const > parent_
std::shared_ptr< SkipListAcquire > skipListAcquirer_
void init()
Start the task.
Manages the lifetime of ledger replay tasks.
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