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#include <xrpl/beast/utility/Journal.h>
27
28#include <mutex>
29#include <vector>
30
31namespace ripple {
32
33namespace test {
34class LedgerReplayClient;
35} // namespace test
36
37namespace LedgerReplayParameters {
38// timeout value for LedgerReplayTask
40
41// for LedgerReplayTask to calculate max allowed timeouts
42// = max( TASK_MAX_TIMEOUTS_MINIMUM,
43// (# of ledger to replay) * TASK_MAX_TIMEOUTS_MULTIPLIER)
46
47// timeout value for subtasks: LedgerDeltaAcquire and SkipListAcquire
49// max of allowed subtask timeouts
51
52// max number of peers that do not support the ledger replay feature
53// returned by the PeerSet before switch to fallback
54auto constexpr MAX_NO_FEATURE_PEER_COUNT = 2;
55// subtask timeout value after fallback
57
58// for LedgerReplayer to limit the number of LedgerReplayTask
59std::uint32_t constexpr MAX_TASKS = 10;
60
61// for LedgerReplayer to limit the number of ledgers to replay in one task
63
64// to limit the number of LedgerReplay related jobs in JobQueue
66} // namespace LedgerReplayParameters
67
71class LedgerReplayer final
72{
73public:
75 Application& app,
76 InboundLedgers& inboundLedgers,
77 std::unique_ptr<PeerSetBuilder> peerSetBuilder);
78
80
88 void
89 replay(
91 uint256 const& finishLedgerHash,
92 std::uint32_t totalNumLedgers);
93
95 void
97
104 void
106 LedgerInfo const& info,
107 boost::intrusive_ptr<SHAMapItem const> const& data);
108
115 void
117 LedgerInfo const& info,
119
121 void
122 sweep();
123
124 void
125 stop();
126
128 tasksSize() const
129 {
131 return tasks_.size();
132 }
133
136 {
138 return deltas_.size();
139 }
140
143 {
145 return skipLists_.size();
146 }
147
148private:
153
158
160};
161
162} // namespace ripple
163
164#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