rippled
Loading...
Searching...
No Matches
LedgerReplayer.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2020 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED
21#define RIPPLE_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED
22
23#include <xrpld/app/ledger/LedgerMaster.h>
24#include <xrpld/app/ledger/LedgerReplayTask.h>
25#include <xrpld/app/main/Application.h>
26
27#include <xrpl/beast/utility/Journal.h>
28
29#include <mutex>
30#include <vector>
31
32namespace ripple {
33
34namespace test {
35class LedgerReplayClient;
36} // namespace test
37
38namespace LedgerReplayParameters {
39// timeout value for LedgerReplayTask
41
42// for LedgerReplayTask to calculate max allowed timeouts
43// = max( TASK_MAX_TIMEOUTS_MINIMUM,
44// (# of ledger to replay) * TASK_MAX_TIMEOUTS_MULTIPLIER)
47
48// timeout value for subtasks: LedgerDeltaAcquire and SkipListAcquire
50// max of allowed subtask timeouts
52
53// max number of peers that do not support the ledger replay feature
54// returned by the PeerSet before switch to fallback
55auto constexpr MAX_NO_FEATURE_PEER_COUNT = 2;
56// subtask timeout value after fallback
58
59// for LedgerReplayer to limit the number of LedgerReplayTask
60std::uint32_t constexpr MAX_TASKS = 10;
61
62// for LedgerReplayer to limit the number of ledgers to replay in one task
64
65// to limit the number of LedgerReplay related jobs in JobQueue
67} // namespace LedgerReplayParameters
68
72class LedgerReplayer final
73{
74public:
76 Application& app,
77 InboundLedgers& inboundLedgers,
78 std::unique_ptr<PeerSetBuilder> peerSetBuilder);
79
81
89 void
90 replay(
92 uint256 const& finishLedgerHash,
93 std::uint32_t totalNumLedgers);
94
96 void
98
105 void
107 LedgerInfo const& info,
108 boost::intrusive_ptr<SHAMapItem const> const& data);
109
116 void
118 LedgerInfo const& info,
120
122 void
123 sweep();
124
125 void
126 stop();
127
129 tasksSize() const
130 {
132 return tasks_.size();
133 }
134
137 {
139 return deltas_.size();
140 }
141
144 {
146 return skipLists_.size();
147 }
148
149private:
154
159
161};
162
163} // namespace ripple
164
165#endif
A generic endpoint for log messages.
Definition: Journal.h:60
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_
Ledger replay client side.
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:26
Information about the notional ledger backing the view.
Definition: LedgerHeader.h:34