20 #include <ripple/app/ledger/ConsensusTransSetSF.h>
21 #include <ripple/app/ledger/InboundLedgers.h>
22 #include <ripple/app/ledger/InboundTransactions.h>
23 #include <ripple/app/ledger/impl/TransactionAcquire.h>
24 #include <ripple/app/main/Application.h>
25 #include <ripple/app/misc/NetworkOPs.h>
26 #include <ripple/overlay/Overlay.h>
27 #include <ripple/overlay/impl/ProtocolMessage.h>
33 using namespace std::chrono_literals;
52 app.journal(
"TransactionAcquire"))
54 , mPeerSet(std::move(peerSet))
56 mMap = std::make_shared<SHAMap>(
77 auto const pap = &
app_;
84 jtTXN_DATA,
"completeAcquire", [pap, hash, map]() {
85 pap->getInboundTransactions().giveSet(hash, map,
true);
129 << (peer ?
"havePeer" :
"noPeer") <<
" no root";
130 protocol::TMGetLedger tmGL;
132 tmGL.set_itype(protocol::liTS_CANDIDATE);
133 tmGL.set_querydepth(3);
136 tmGL.set_querytype(protocol::qtINDIRECT);
141 else if (!
mMap->isValid())
149 auto nodes =
mMap->getMissingNodes(256, &sf);
162 protocol::TMGetLedger tmGL;
164 tmGL.set_itype(protocol::liTS_CANDIDATE);
167 tmGL.set_querytype(protocol::qtINDIRECT);
169 for (
auto const& node : nodes)
171 *tmGL.add_nodeids() = node.first.getRawString();
203 for (
auto const& d : data)
205 if (d.first.isRoot())
209 <<
"Got root TXS node, already have it";
210 else if (!
mMap->addRootNode(
214 JLOG(
journal_.
warn()) <<
"TX acquire got bad root node";
219 else if (!
mMap->addKnownNode(d.first, d.second, &sf).isGood())
221 JLOG(
journal_.
warn()) <<
"TX acquire got bad non-root node";
233 <<
"Peer " << peer->id()
234 <<
" sent us junky transaction node data: " << ex.
what();
244 [
this](
auto peer) {
return peer->hasTxSet(
hash_); },
245 [
this](
auto peer) {
trigger(peer); });
constexpr auto TX_ACQUIRE_TIMEOUT
virtual NodeCache & getTempNodeCache()=0
Stream trace() const
Severity stream access functions.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
void trigger(std::shared_ptr< Peer > const &)
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void addPeers(std::size_t limit)
bool progress_
Whether forward progress has been made.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
Identifies a node inside a SHAMap.
This class is an "active" object.
std::recursive_mutex mtx_
constexpr static std::size_t size()
static SHAMapAddNode useful()
std::shared_ptr< SHAMap > mMap
T shared_from_this(T... args)
static SHAMapAddNode invalid()
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
std::string getRawString() const
virtual JobQueue & getJobQueue()=0
TransactionAcquire(Application &app, uint256 const &hash, std::unique_ptr< PeerSet > peerSet)
void init(int startPeers)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const uint256 hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
SHAMapAddNode takeNodes(std::vector< std::pair< SHAMapNodeID, Slice >> const &data, std::shared_ptr< Peer > const &)
std::unique_ptr< PeerSet > mPeerSet