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;
31 app.journal(
"TransactionAcquire"))
33 , mPeerSet(std::move(peerSet))
56 auto const pap = &
app_;
63 jtTXN_DATA,
"completeAcquire", [pap, hash, map]() {
64 pap->getInboundTransactions().giveSet(hash, map,
true);
108 << (peer ?
"havePeer" :
"noPeer") <<
" no root";
109 protocol::TMGetLedger tmGL;
111 tmGL.set_itype(protocol::liTS_CANDIDATE);
112 tmGL.set_querydepth(3);
115 tmGL.set_querytype(protocol::qtINDIRECT);
120 else if (!
mMap->isValid())
128 auto nodes =
mMap->getMissingNodes(256, &sf);
141 protocol::TMGetLedger tmGL;
143 tmGL.set_itype(protocol::liTS_CANDIDATE);
146 tmGL.set_querytype(protocol::qtINDIRECT);
148 for (
auto const& node : nodes)
150 *tmGL.add_nodeids() = node.first.getRawString();
182 for (
auto const& d : data)
184 if (d.first.isRoot())
188 <<
"Got root TXS node, already have it";
189 else if (!
mMap->addRootNode(
193 JLOG(
journal_.
warn()) <<
"TX acquire got bad root node";
198 else if (!
mMap->addKnownNode(d.first, d.second, &sf).isGood())
200 JLOG(
journal_.
warn()) <<
"TX acquire got bad non-root node";
212 <<
"Peer " << peer->id()
213 <<
" sent us junky transaction node data: " << ex.
what();
223 [
this](
auto peer) {
return peer->hasTxSet(
hash_); },
224 [
this](
auto peer) {
trigger(peer); });
Stream trace() const
Severity stream access functions.
virtual NodeCache & getTempNodeCache()=0
virtual JobQueue & getJobQueue()=0
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
static SHAMapAddNode invalid()
static SHAMapAddNode useful()
Identifies a node inside a SHAMap.
std::string getRawString() const
This class is an "active" object.
bool progress_
Whether forward progress has been made.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
std::recursive_mutex mtx_
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
void trigger(std::shared_ptr< Peer > const &)
TransactionAcquire(Application &app, uint256 const &hash, std::unique_ptr< PeerSet > peerSet)
void init(int startPeers)
std::shared_ptr< SHAMap > mMap
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void addPeers(std::size_t limit)
std::unique_ptr< PeerSet > mPeerSet
SHAMapAddNode takeNodes(std::vector< std::pair< SHAMapNodeID, Slice > > const &data, std::shared_ptr< Peer > const &)
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)