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;
46 mMap = std::make_shared<SHAMap>(
76 auto const pap = &
app_;
84 pap->getInboundTransactions().giveSet(hash, map,
true);
128 << (peer ?
"havePeer" :
"noPeer") <<
" no root";
129 protocol::TMGetLedger tmGL;
131 tmGL.set_itype(protocol::liTS_CANDIDATE);
132 tmGL.set_querydepth(3);
135 tmGL.set_querytype(protocol::qtINDIRECT);
140 else if (!
mMap->isValid())
148 auto nodes =
mMap->getMissingNodes(256, &sf);
161 protocol::TMGetLedger tmGL;
163 tmGL.set_itype(protocol::liTS_CANDIDATE);
166 tmGL.set_querytype(protocol::qtINDIRECT);
168 for (
auto const& node : nodes)
170 *tmGL.add_nodeids() = node.first.getRawString();
205 while (nodeIDit != nodeIDs.
end())
207 if (nodeIDit->isRoot())
211 <<
"Got root TXS node, already have it";
212 else if (!
mMap->addRootNode(
223 else if (!
mMap->addKnownNode(*nodeIDit,
makeSlice(*nodeDatait), &sf)
226 JLOG(
m_journal.
warn()) <<
"TX acquire got bad non-root node";
240 JLOG(
m_journal.
error()) <<
"Peer sends us junky transaction node data";
249 limit, [
this](
auto peer) {
return peer->hasTxSet(
mHash); });
virtual Family & getNodeFamily()=0
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)
TransactionAcquire(Application &app, uint256 const &hash)
bool mProgress
Whether forward progress has been made.
Stream trace() const
Severity stream access functions.
void queueJob() override
Queue a job to call invokeOnTimer().
void trigger(std::shared_ptr< Peer > const &)
void addPeers(std::size_t limit)
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
Identifies a node inside a SHAMap.
std::weak_ptr< PeerSet > pmDowncast() override
Return a weak pointer to this.
void addPeers(std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> score)
Add at most limit peers to this set from the overlay.
const uint256 mHash
The hash of the object (in practice, always a ledger) we are trying to fetch.
constexpr static std::size_t size()
void sendRequest(const protocol::TMGetLedger &message, std::shared_ptr< Peer > const &peer)
Send a GetLedger message to one or all peers.
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
void init(int startPeers)
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 &)
Supports data retrieval by managing a set of peers.
void setTimer()
Schedule a call to queueJob() after mTimerInterval.
std::recursive_mutex mLock