1#include <xrpld/app/ledger/ConsensusTransSetSF.h>
2#include <xrpld/app/ledger/InboundLedgers.h>
3#include <xrpld/app/ledger/InboundTransactions.h>
4#include <xrpld/app/ledger/detail/TransactionAcquire.h>
5#include <xrpld/app/main/Application.h>
6#include <xrpld/app/misc/NetworkOPs.h>
12using namespace std::chrono_literals;
25 , mPeerSet(std::move(peerSet))
47 auto const pap = &
app_;
54 jtTXN_DATA,
"ComplAcquire", [pap, hash, map]() { pap->getInboundTransactions().giveSet(hash, map,
true); });
96 JLOG(
journal_.
trace()) <<
"TransactionAcquire::trigger " << (peer ?
"havePeer" :
"noPeer") <<
" no root";
97 protocol::TMGetLedger tmGL;
99 tmGL.set_itype(protocol::liTS_CANDIDATE);
100 tmGL.set_querydepth(3);
103 tmGL.set_querytype(protocol::qtINDIRECT);
108 else if (!
mMap->isValid())
116 auto nodes =
mMap->getMissingNodes(256, &sf);
129 protocol::TMGetLedger tmGL;
131 tmGL.set_itype(protocol::liTS_CANDIDATE);
134 tmGL.set_querytype(protocol::qtINDIRECT);
136 for (
auto const& node : nodes)
138 *tmGL.add_nodeids() = node.first.getRawString();
170 for (
auto const& d : data)
172 if (d.first.isRoot())
175 JLOG(
journal_.
debug()) <<
"Got root TXS node, already have it";
176 else if (!
mMap->addRootNode(
SHAMapHash{hash_}, d.second,
nullptr).isGood())
178 JLOG(
journal_.
warn()) <<
"TX acquire got bad root node";
183 else if (!
mMap->addKnownNode(d.first, d.second, &sf).isGood())
185 JLOG(
journal_.
warn()) <<
"TX acquire got bad non-root node";
196 JLOG(
journal_.
error()) <<
"Peer " << peer->id() <<
" sent us junky transaction node data: " << ex.
what();
205 limit, [
this](
auto peer) {
return peer->hasTxSet(
hash_); }, [
this](
auto peer) {
trigger(peer); });
Stream trace() const
Severity stream access functions.
virtual JobQueue & getJobQueue()=0
virtual NodeCache & getTempNodeCache()=0
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
static SHAMapAddNode useful()
static SHAMapAddNode invalid()
Identifies a node inside a SHAMap.
std::string getRawString() const
This class is an "active" object.
std::recursive_mutex mtx_
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
bool progress_
Whether forward progress has been made.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
void init(int startPeers)
std::shared_ptr< SHAMap > mMap
void addPeers(std::size_t limit)
void trigger(std::shared_ptr< Peer > const &)
TransactionAcquire(Application &app, uint256 const &hash, std::unique_ptr< PeerSet > peerSet)
SHAMapAddNode takeNodes(std::vector< std::pair< SHAMapNodeID, Slice > > const &data, std::shared_ptr< Peer > const &)
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
std::unique_ptr< PeerSet > mPeerSet
static constexpr std::size_t size()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
auto constexpr TX_ACQUIRE_TIMEOUT
T shared_from_this(T... args)