rippled
Loading...
Searching...
No Matches
LedgerDeltaAcquire.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_LEDGERDELTAACQUIRE_H_INCLUDED
21#define RIPPLE_APP_LEDGER_LEDGERDELTAACQUIRE_H_INCLUDED
22
23#include <xrpld/app/ledger/InboundLedger.h>
24#include <xrpld/app/ledger/Ledger.h>
25#include <xrpld/app/ledger/detail/TimeoutCounter.h>
26
27#include <xrpl/basics/CountedObject.h>
28#include <xrpl/basics/base_uint.h>
29
30#include <map>
31
32namespace ripple {
33class InboundLedgers;
34class PeerSet;
35namespace test {
36class LedgerReplayClient;
37} // namespace test
38
45 : public TimeoutCounter,
46 public std::enable_shared_from_this<LedgerDeltaAcquire>,
47 public CountedObject<LedgerDeltaAcquire>
48{
49public:
56 std::function<void(bool successful, uint256 const& hash)>;
57
67 Application& app,
68 InboundLedgers& inboundLedgers,
69 uint256 const& ledgerHash,
70 std::uint32_t ledgerSeq,
72
73 ~LedgerDeltaAcquire() override;
74
79 void
80 init(int numPeers);
81
89 void
91 LedgerInfo const& info,
93
103
111 void
113
114private:
115 void
116 onTimer(bool progress, ScopedLockType& peerSetLock) override;
117
119 pmDowncast() override;
120
126 void
128
137 void
139 ScopedLockType& sl,
141
146 void
148
158 bool fallBack_ = false;
159
160 friend class LedgerReplayTask; // for asserts only
162};
163
164} // namespace ripple
165
166#endif
Tracks the number of instances of an object.
Manages the lifetime of inbound ledgers.
Manage the retrieval of a ledger delta (header and transactions) from the network.
std::shared_ptr< Ledger const > fullLedger_
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
std::set< InboundLedger::Reason > reasons_
void processData(LedgerInfo const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&orderedTxns)
Process the data extracted from a peer's reply.
std::map< std::uint32_t, std::shared_ptr< STTx const > > orderedTxns_
std::shared_ptr< Ledger const > tryBuild(std::shared_ptr< Ledger const > const &parent)
Try to build the ledger if not already.
std::shared_ptr< Ledger const > replayTemp_
std::uint32_t const ledgerSeq_
void init(int numPeers)
Start the LedgerDeltaAcquire task.
std::vector< OnDeltaDataCB > dataReadyCallbacks_
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
std::unique_ptr< PeerSet > peerSet_
void notify(ScopedLockType &sl)
Call the OnDeltaDataCB callbacks.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void addDataCallback(InboundLedger::Reason reason, OnDeltaDataCB &&cb)
Add a reason and a callback to the LedgerDeltaAcquire subtask.
void onLedgerBuilt(ScopedLockType &sl, std::optional< InboundLedger::Reason > reason={})
Process a newly built ledger, such as store it.
This class is an "active" object.
std::unique_lock< std::recursive_mutex > ScopedLockType
Ledger replay client side.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:25
Information about the notional ledger backing the view.
Definition: LedgerHeader.h:34