xrpld
Loading...
Searching...
No Matches
TransactionAcquire.h
1#pragma once
2
3#include <xrpld/app/ledger/detail/TimeoutCounter.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/overlay/Peer.h>
6#include <xrpld/overlay/PeerSet.h>
7
8#include <xrpl/basics/CountedObject.h>
9#include <xrpl/basics/base_uint.h>
10#include <xrpl/shamap/SHAMap.h>
11#include <xrpl/shamap/SHAMapAddNode.h>
12#include <xrpl/shamap/SHAMapNodeID.h>
13#include <xrpl/shamap/SHAMapTreeNode.h>
14
15#include <chrono>
16#include <cstddef>
17#include <memory>
18#include <utility>
19#include <vector>
20
21namespace xrpl {
22
23// VFALCO TODO rename to PeerTxRequest
24// A transaction set we are trying to acquire
26 public std::enable_shared_from_this<TransactionAcquire>,
27 public CountedObject<TransactionAcquire>
28{
29public:
31
36
45 Application& app,
46 UInt256 const& hash,
49 ~TransactionAcquire() override = default;
50
54 std::shared_ptr<Peer> const& peer);
55
56 void
57 init(int startPeers);
58
59 void
60 stillNeed();
61
62protected:
63 // Kept protected so a test subclass can read the map's state.
64 // Production callers reach a set through InboundTransactions.
66
67private:
68 bool haveRoot_{false};
70
71 void
72 onTimer(bool progress, ScopedLockType& sl) override;
73
79 void
80 done();
81
82 void
83 addPeers(std::size_t limit);
84
85 void
88 pmDowncast() override;
89};
90
91} // namespace xrpl
std::unique_lock< std::recursive_mutex > ScopedLockType
TimeoutCounter(Application &app, UInt256 const &targetHash, std::chrono::milliseconds timeoutInterval, QueueJobParameter &&jobParameter, beast::Journal journal)
void done()
Settle the acquired set and hand it on, or report the failure.
SHAMapAddNode takeNodes(std::vector< std::pair< SHAMapNodeID, SHAMapTreeNodePtr > > data, std::shared_ptr< Peer > const &peer)
std::shared_ptr< SHAMap > map_
void addPeers(std::size_t limit)
std::shared_ptr< TransactionAcquire > pointer
void onTimer(bool progress, ScopedLockType &sl) override
Hook called from invokeOnTimer().
void trigger(std::shared_ptr< Peer > const &)
TransactionAcquire(Application &app, UInt256 const &hash, std::unique_ptr< PeerSet > peerSet, std::chrono::milliseconds retryInterval=kRetryInterval)
~TransactionAcquire() override=default
static constexpr std::chrono::milliseconds kRetryInterval
How long to wait between retries, and so how long one timeout takes.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
std::unique_ptr< PeerSet > peerSet_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
BaseUInt< 256 > UInt256
Definition base_uint.h:581