rippled
Loading...
Searching...
No Matches
LedgerReplayer.h
1#pragma once
2
3#include <xrpld/app/ledger/LedgerMaster.h>
4#include <xrpld/app/ledger/LedgerReplayTask.h>
5#include <xrpld/app/main/Application.h>
6
7#include <xrpl/beast/utility/Journal.h>
8
9#include <mutex>
10#include <vector>
11
12namespace xrpl {
13
14namespace test {
15class LedgerReplayClient;
16} // namespace test
17
18namespace LedgerReplayParameters {
19// timeout value for LedgerReplayTask
21
22// for LedgerReplayTask to calculate max allowed timeouts
23// = max( TASK_MAX_TIMEOUTS_MINIMUM,
24// (# of ledger to replay) * TASK_MAX_TIMEOUTS_MULTIPLIER)
27
28// timeout value for subtasks: LedgerDeltaAcquire and SkipListAcquire
30// max of allowed subtask timeouts
32
33// max number of peers that do not support the ledger replay feature
34// returned by the PeerSet before switch to fallback
35auto constexpr MAX_NO_FEATURE_PEER_COUNT = 2;
36// subtask timeout value after fallback
38
39// for LedgerReplayer to limit the number of LedgerReplayTask
40std::uint32_t constexpr MAX_TASKS = 10;
41
42// for LedgerReplayer to limit the number of ledgers to replay in one task
44
45// to limit the number of LedgerReplay related jobs in JobQueue
47} // namespace LedgerReplayParameters
48
52class LedgerReplayer final
53{
54public:
56 Application& app,
57 InboundLedgers& inboundLedgers,
58 std::unique_ptr<PeerSetBuilder> peerSetBuilder);
59
61
69 void
70 replay(InboundLedger::Reason r, uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers);
71
73 void
75
82 void
83 gotSkipList(LedgerHeader const& info, boost::intrusive_ptr<SHAMapItem const> const& data);
84
91 void
93 LedgerHeader const& info,
95
97 void
98 sweep();
99
100 void
101 stop();
102
104 tasksSize() const
105 {
107 return tasks_.size();
108 }
109
112 {
114 return deltas_.size();
115 }
116
119 {
121 return skipLists_.size();
122 }
123
124private:
129
134
136};
137
138} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Manages the lifetime of inbound ledgers.
Manages the lifetime of ledger replay tasks.
hash_map< uint256, std::weak_ptr< SkipListAcquire > > skipLists_
InboundLedgers & inboundLedgers_
void replay(InboundLedger::Reason r, uint256 const &finishLedgerHash, std::uint32_t totalNumLedgers)
Replay a range of ledgers.
void gotReplayDelta(LedgerHeader const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&txns)
Process a ledger delta (extracted from a TMReplayDeltaResponse message)
std::size_t skipListsSize() const
std::size_t tasksSize() const
void gotSkipList(LedgerHeader const &info, boost::intrusive_ptr< SHAMapItem const > const &data)
Process a skip list (extracted from a TMProofPathResponse message)
std::unique_ptr< PeerSetBuilder > peerSetBuilder_
std::vector< std::shared_ptr< LedgerReplayTask > > tasks_
void sweep()
Remove completed tasks.
void createDeltas(std::shared_ptr< LedgerReplayTask > task)
Create LedgerDeltaAcquire subtasks for the LedgerReplayTask task.
hash_map< uint256, std::weak_ptr< LedgerDeltaAcquire > > deltas_
std::size_t deltasSize() const
Ledger replay client side.
auto constexpr SUB_TASK_FALLBACK_TIMEOUT
auto constexpr MAX_NO_FEATURE_PEER_COUNT
std::uint32_t constexpr TASK_MAX_TIMEOUTS_MINIMUM
std::uint32_t constexpr TASK_MAX_TIMEOUTS_MULTIPLIER
std::uint32_t constexpr MAX_TASKS
std::uint32_t constexpr MAX_QUEUED_TASKS
std::uint32_t constexpr SUB_TASK_MAX_TIMEOUTS
std::uint32_t constexpr MAX_TASK_SIZE
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Information about the notional ledger backing the view.