rippled
Loading...
Searching...
No Matches
SkipListAcquire.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_SKIPLISTACQUIRE_H_INCLUDED
21#define RIPPLE_APP_LEDGER_SKIPLISTACQUIRE_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#include <xrpld/app/main/Application.h>
27#include <xrpld/shamap/SHAMap.h>
28#include <queue>
29
30namespace ripple {
31class InboundLedgers;
32class PeerSet;
33namespace test {
34class LedgerReplayClient;
35} // namespace test
36
41class SkipListAcquire final
42 : public TimeoutCounter,
43 public std::enable_shared_from_this<SkipListAcquire>,
44 public CountedObject<SkipListAcquire>
45{
46public:
53 std::function<void(bool successful, uint256 const& hash)>;
54
56 {
59
64 {
65 }
66 };
67
76 Application& app,
77 InboundLedgers& inboundLedgers,
78 uint256 const& ledgerHash,
80
81 ~SkipListAcquire() override;
82
87 void
88 init(int numPeers);
89
96 void
98 std::uint32_t ledgerSeq,
99 boost::intrusive_ptr<SHAMapItem const> const& item);
100
106 void
108
110 getData() const;
111
112private:
113 void
114 onTimer(bool progress, ScopedLockType& peerSetLock) override;
115
117 pmDowncast() override;
118
124 void
126
132 void
134 std::shared_ptr<Ledger const> const& ledger,
135 ScopedLockType& sl);
136
143 void
145 std::vector<uint256> const& skipList,
146 std::uint32_t ledgerSeq,
147 ScopedLockType& sl);
148
153 void
155
161 bool fallBack_ = false;
162
164};
165
166} // namespace ripple
167
168#endif
Tracks the number of instances of an object.
Manages the lifetime of inbound ledgers.
Manage the retrieval of a skip list in a ledger from the network.
void init(int numPeers)
Start the SkipListAcquire task.
void addDataCallback(OnSkipListDataCB &&cb)
Add a callback that will be called when the skipList is ready or failed.
std::function< void(bool successful, uint256 const &hash)> OnSkipListDataCB
A callback used to notify that the SkipList is ready or failed.
InboundLedgers & inboundLedgers_
std::shared_ptr< SkipListData const > getData() const
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
void notify(ScopedLockType &sl)
Call the OnSkipListDataCB callbacks.
void retrieveSkipList(std::shared_ptr< Ledger const > const &ledger, ScopedLockType &sl)
Retrieve the skip list from the ledger.
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
std::shared_ptr< SkipListData const > data_
void processData(std::uint32_t ledgerSeq, boost::intrusive_ptr< SHAMapItem const > const &item)
Process the data extracted from a peer's reply.
void onSkipListAcquired(std::vector< uint256 > const &skipList, std::uint32_t ledgerSeq, ScopedLockType &sl)
Process the skip list.
std::vector< OnSkipListDataCB > dataReadyCallbacks_
std::unique_ptr< PeerSet > peerSet_
std::uint32_t noFeaturePeerCount_
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:26
SkipListData(std::uint32_t const ledgerSeq, std::vector< ripple::uint256 > const &skipList)
std::vector< ripple::uint256 > const skipList