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:
55 LedgerReplayer(Application& app, InboundLedgers& inboundLedgers, std::unique_ptr<PeerSetBuilder> peerSetBuilder);
56
58
66 void
67 replay(InboundLedger::Reason r, uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers);
68
70 void
72
79 void
80 gotSkipList(LedgerHeader const& info, boost::intrusive_ptr<SHAMapItem const> const& data);
81
88 void
90
92 void
93 sweep();
94
95 void
96 stop();
97
99 tasksSize() const
100 {
102 return tasks_.size();
103 }
104
107 {
109 return deltas_.size();
110 }
111
114 {
116 return skipLists_.size();
117 }
118
119private:
124
129
131};
132
133} // 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.