1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/main/Application.h>
3#include <xrpld/rpc/detail/PathRequestManager.h>
5#include <xrpl/core/JobQueue.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/RPCErr.h>
8#include <xrpl/protocol/jss.h>
24 std::uint32_t const lineSeq = lineCache ? lineCache->getLedger()->seq() : 0;
26 JLOG(
mJournal.
debug()) <<
"getLineCache has cache for " << lineSeq <<
", considering "
30 (authoritative && (lgrSeq > lineSeq)) ||
31 (authoritative && ((lgrSeq + 8) < lineSeq)) ||
32 (lgrSeq > (lineSeq + 8)))
34 JLOG(
mJournal.
debug()) <<
"getLineCache creating new cache for " << lgrSeq;
60 bool mustBreak =
false;
62 JLOG(
mJournal.
trace()) <<
"updateAll seq=" << cache->getLedger()->seq() <<
", "
63 << requests.
size() <<
" requests";
65 int processed = 0, removed = 0;
68 if (
auto ipSub = request->getSubscriber(); ipSub && ipSub->getRequest() == request)
72 request->doAborting();
79 for (
auto const& wr : requests)
84 auto request = wr.lock();
86 JLOG(
mJournal.
trace()) <<
"updateAll request " << (request ?
"" :
"not ") <<
"found";
90 auto continueCallback = [&getSubscriber, &request]() {
94 return (
bool)getSubscriber(request);
96 if (!request->needsUpdate(newRequests, cache->getLedger()->seq()))
102 if (
auto ipSub = getSubscriber(request))
104 if (!ipSub->getConsumer().warn())
110 Json::Value update = request->doUpdate(cache,
false, continueCallback);
111 request->updateComplete();
112 update[jss::type] =
"path_find";
113 if ((ipSub = getSubscriber(request)))
115 ipSub->send(update,
false);
121 else if (request->hasCompletion())
124 request->doUpdate(cache,
false);
125 request->updateComplete();
141 if (r && r != request)
162 else if (newRequests)
188 JLOG(
mJournal.
debug()) <<
"updateAll complete: " << processed <<
" processed and " << removed
210 return r && !r->isNew();
229 subscriber->setRequest(req);
233 return std::move(jvRes);
267 return std::move(jvRes);
281 auto [
valid, jvRes] = req->doCreate(cache, request);
283 jvRes = req->doUpdate(cache,
false);
284 return std::move(jvRes);
Stream trace() const
Severity stream access functions.
std::unique_ptr< LoadEvent > makeLoadEvent(JobType t, std::string const &name)
Return a scoped LoadEvent.
std::atomic< int > mLastIdentifier
bool requestsPending() const
std::vector< PathRequest::wptr > requests_
std::shared_ptr< RippleLineCache > getLineCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current RippleLineCache, updating it if necessary.
void updateAll(std::shared_ptr< ReadView const > const &ledger)
Update all of the contained PathRequest instances.
Json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, Json::Value const &request)
std::weak_ptr< RippleLineCache > lineCache_
Json::Value doLegacyPathRequest(Resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, Json::Value const &request)
void insertPathRequest(PathRequest::pointer const &)
std::recursive_mutex mLock
Json::Value makeLegacyPathRequest(PathRequest::pointer &req, std::function< void(void)> completion, Resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, Json::Value const &request)
An endpoint that consumes resources.
virtual JobQueue & getJobQueue()=0
virtual beast::Journal getJournal(std::string const &name)=0
virtual LedgerMaster & getLedgerMaster()=0
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value rpcError(error_code_i iError)