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
45 TaskParameter(InboundLedger::Reason r, uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers);
46
56 bool
57 update(uint256 const& hash, std::uint32_t seq, std::vector<uint256> const& sList);
58
60 bool
61 canMergeInto(TaskParameter const& existingTask) const;
62 };
63
74 Application& app,
75 InboundLedgers& inboundLedgers,
76 LedgerReplayer& replayer,
77 std::shared_ptr<SkipListAcquire>& skipListAcquirer,
78 TaskParameter&& parameter);
79
81
83 void
84 init();
85
91 void
93
94 TaskParameter const&
96 {
97 return parameter_;
98 }
99
101 bool
102 finished() const;
103
104private:
105 void
106 onTimer(bool progress, ScopedLockType& sl) override;
107
109 pmDowncast() override;
110
117 void
118 updateSkipList(uint256 const& hash, std::uint32_t seq, std::vector<uint256> const& sList);
119
124 void
125 deltaReady(uint256 const& deltaHash);
126
131 void
133
138 void
140
144 uint32_t maxTimeouts_;
147 uint32_t deltaToBuild_ = 0; // should not build until have parent
149
151};
152
153} // 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