rippled
Loading...
Searching...
No Matches
LedgerReplayer.h
1#ifndef XRPL_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED
2#define XRPL_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED
3
4#include <xrpld/app/ledger/LedgerMaster.h>
5#include <xrpld/app/ledger/LedgerReplayTask.h>
6#include <xrpld/app/main/Application.h>
7
8#include <xrpl/beast/utility/Journal.h>
9
10#include <mutex>
11#include <vector>
12
13namespace ripple {
14
15namespace test {
16class LedgerReplayClient;
17} // namespace test
18
19namespace LedgerReplayParameters {
20// timeout value for LedgerReplayTask
22
23// for LedgerReplayTask to calculate max allowed timeouts
24// = max( TASK_MAX_TIMEOUTS_MINIMUM,
25// (# of ledger to replay) * TASK_MAX_TIMEOUTS_MULTIPLIER)
28
29// timeout value for subtasks: LedgerDeltaAcquire and SkipListAcquire
31// max of allowed subtask timeouts
33
34// max number of peers that do not support the ledger replay feature
35// returned by the PeerSet before switch to fallback
36auto constexpr MAX_NO_FEATURE_PEER_COUNT = 2;
37// subtask timeout value after fallback
39
40// for LedgerReplayer to limit the number of LedgerReplayTask
41std::uint32_t constexpr MAX_TASKS = 10;
42
43// for LedgerReplayer to limit the number of ledgers to replay in one task
45
46// to limit the number of LedgerReplay related jobs in JobQueue
48} // namespace LedgerReplayParameters
49
53class LedgerReplayer final
54{
55public:
57 Application& app,
58 InboundLedgers& inboundLedgers,
59 std::unique_ptr<PeerSetBuilder> peerSetBuilder);
60
62
70 void
71 replay(
73 uint256 const& finishLedgerHash,
74 std::uint32_t totalNumLedgers);
75
77 void
79
86 void
88 LedgerInfo const& info,
89 boost::intrusive_ptr<SHAMapItem const> const& data);
90
97 void
99 LedgerInfo const& info,
101
103 void
104 sweep();
105
106 void
107 stop();
108
110 tasksSize() const
111 {
113 return tasks_.size();
114 }
115
118 {
120 return deltas_.size();
121 }
122
125 {
127 return skipLists_.size();
128 }
129
130private:
135
140
142};
143
144} // namespace ripple
145
146#endif
A generic endpoint for log messages.
Definition Journal.h:41
Manages the lifetime of inbound ledgers.
Manages the lifetime of ledger replay tasks.
void gotReplayDelta(LedgerInfo const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&txns)
Process a ledger delta (extracted from a TMReplayDeltaResponse message)
void createDeltas(std::shared_ptr< LedgerReplayTask > task)
Create LedgerDeltaAcquire subtasks for the LedgerReplayTask task.
std::size_t deltasSize() const
void sweep()
Remove completed tasks.
std::vector< std::shared_ptr< LedgerReplayTask > > tasks_
std::unique_ptr< PeerSetBuilder > peerSetBuilder_
std::size_t tasksSize() const
void gotSkipList(LedgerInfo const &info, boost::intrusive_ptr< SHAMapItem const > const &data)
Process a skip list (extracted from a TMProofPathResponse message)
hash_map< uint256, std::weak_ptr< SkipListAcquire > > skipLists_
void replay(InboundLedger::Reason r, uint256 const &finishLedgerHash, std::uint32_t totalNumLedgers)
Replay a range of ledgers.
InboundLedgers & inboundLedgers_
std::size_t skipListsSize() const
hash_map< uint256, std::weak_ptr< LedgerDeltaAcquire > > deltas_
std::uint32_t constexpr TASK_MAX_TIMEOUTS_MINIMUM
auto constexpr SUB_TASK_FALLBACK_TIMEOUT
std::uint32_t constexpr MAX_QUEUED_TASKS
std::uint32_t constexpr SUB_TASK_MAX_TIMEOUTS
auto constexpr MAX_NO_FEATURE_PEER_COUNT
std::uint32_t constexpr MAX_TASK_SIZE
std::uint32_t constexpr MAX_TASKS
std::uint32_t constexpr TASK_MAX_TIMEOUTS_MULTIPLIER
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Information about the notional ledger backing the view.