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>
32 using namespace std::chrono_literals;
51 app.journal(
"TransactionAcquire"))
53 , j_(app.journal(
"TransactionAcquire"))
76 JLOG(
j_.
warn()) <<
"Failed to acquire TX set " <<
mHash;
85 auto const pap = &
app_;
93 pap->getInboundTransactions().giveSet(hash, map,
true);
101 bool aggressive =
false;
132 JLOG(
j_.
info()) <<
"trigger after complete";
137 JLOG(
j_.
info()) <<
"trigger after fail";
143 JLOG(
j_.
trace()) <<
"TransactionAcquire::trigger "
144 << (peer ?
"havePeer" :
"noPeer") <<
" no root";
145 protocol::TMGetLedger tmGL;
147 tmGL.set_itype(protocol::liTS_CANDIDATE);
148 tmGL.set_querydepth(3);
151 tmGL.set_querytype(protocol::qtINDIRECT);
156 else if (!
mMap->isValid())
164 auto nodes =
mMap->getMissingNodes(256, &sf);
177 protocol::TMGetLedger tmGL;
179 tmGL.set_itype(protocol::liTS_CANDIDATE);
182 tmGL.set_querytype(protocol::qtINDIRECT);
184 for (
auto const& node : nodes)
186 *tmGL.add_nodeids() = node.first.getRawString();
202 JLOG(
j_.
trace()) <<
"TX set complete";
208 JLOG(
j_.
trace()) <<
"TX set failed";
221 while (nodeIDit != nodeIDs.
end())
223 if (nodeIDit->isRoot())
226 JLOG(
j_.
debug()) <<
"Got root TXS node, already have it";
227 else if (!
mMap->addRootNode(
234 JLOG(
j_.
warn()) <<
"TX acquire got bad root node";
239 else if (!
mMap->addKnownNode(*nodeIDit,
makeSlice(*nodeDatait), &sf)
242 JLOG(
j_.
warn()) <<
"TX acquire got bad non-root node";
256 JLOG(
j_.
error()) <<
"Peer sends us junky transaction node data";
constexpr auto TX_ACQUIRE_TIMEOUT
virtual NodeCache & getTempNodeCache()=0
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Stream trace() const
Severity stream access functions.
void trigger(std::shared_ptr< Peer > const &)
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
std::weak_ptr< PeerSet > pmDowncast() override
constexpr static std::size_t size()
static SHAMapAddNode useful()
std::shared_ptr< SHAMap > mMap
TransactionAcquire(Application &app, uint256 const &hash, clock_type &clock)
T shared_from_this(T... args)
virtual Family & family()=0
static SHAMapAddNode invalid()
void onTimer(bool progress, ScopedLockType &peerSetLock) override
std::string getRawString() const
virtual JobQueue & getJobQueue()=0
virtual std::size_t selectPeers(PeerSet &set, std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> score)=0
Select from active peers.
void init(int startPeers)
void sendRequest(const protocol::TMGetLedger &message)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
SHAMapAddNode takeNodes(const std::list< SHAMapNodeID > &IDs, const std::list< Blob > &data, std::shared_ptr< Peer > const &)
int getTimeouts() const
Returns the number of times we timed out.
Supports data retrieval by managing a set of peers.
virtual Overlay & overlay()=0
uint256 const & getHash() const
Returns the hash of the data we want.
void progress()
Called to indicate that forward progress has been made.
std::recursive_mutex mLock