1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/main/Application.h>
3#include <xrpld/app/paths/PathRequests.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/core/JobQueue.h>
7#include <xrpl/protocol/ErrorCodes.h>
8#include <xrpl/protocol/RPCErr.h>
9#include <xrpl/protocol/jss.h>
25 std::uint32_t const lineSeq = lineCache ? lineCache->getLedger()->seq() : 0;
27 JLOG(
mJournal.
debug()) <<
"getLineCache has cache for " << lineSeq <<
", considering " << lgrSeq;
30 (authoritative && (lgrSeq > lineSeq)) ||
31 (authoritative && ((lgrSeq + 8) < lineSeq)) ||
32 (lgrSeq > (lineSeq + 8)))
34 JLOG(
mJournal.
debug()) <<
"getLineCache creating new cache for " << lgrSeq;
59 bool mustBreak =
false;
61 JLOG(
mJournal.
trace()) <<
"updateAll seq=" << cache->getLedger()->seq() <<
", " << requests.
size() <<
" requests";
63 int processed = 0, removed = 0;
66 if (
auto ipSub = request->getSubscriber(); ipSub && ipSub->getRequest() == request)
70 request->doAborting();
77 for (
auto const& wr : requests)
82 auto request = wr.lock();
84 JLOG(
mJournal.
trace()) <<
"updateAll request " << (request ?
"" :
"not ") <<
"found";
88 auto continueCallback = [&getSubscriber, &request]() {
92 return (
bool)getSubscriber(request);
94 if (!request->needsUpdate(newRequests, cache->getLedger()->seq()))
98 if (
auto ipSub = getSubscriber(request))
100 if (!ipSub->getConsumer().warn())
106 Json::Value update = request->doUpdate(cache,
false, continueCallback);
107 request->updateComplete();
108 update[jss::type] =
"path_find";
109 if ((ipSub = getSubscriber(request)))
111 ipSub->send(update,
false);
117 else if (request->hasCompletion())
120 request->doUpdate(cache,
false);
121 request->updateComplete();
136 if (r && r != request)
157 else if (newRequests)
183 JLOG(
mJournal.
debug()) <<
"updateAll complete: " << processed <<
" processed and " << removed <<
" removed";
204 return r && !r->isNew();
223 subscriber->setRequest(req);
227 return std::move(jvRes);
260 return std::move(jvRes);
273 auto [
valid, jvRes] = req->doCreate(cache, request);
275 jvRes = req->doUpdate(cache,
false);
276 return std::move(jvRes);
Stream trace() const
Severity stream access functions.
virtual beast::Journal journal(std::string const &name)=0
std::unique_ptr< LoadEvent > makeLoadEvent(JobType t, std::string const &name)
Return a scoped LoadEvent.
std::weak_ptr< RippleLineCache > lineCache_
bool requestsPending() const
std::shared_ptr< RippleLineCache > getLineCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current RippleLineCache, updating it if necessary.
Json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, Json::Value const &request)
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)
void insertPathRequest(PathRequest::pointer const &)
Json::Value doLegacyPathRequest(Resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, Json::Value const &request)
void updateAll(std::shared_ptr< ReadView const > const &ledger)
Update all of the contained PathRequest instances.
std::recursive_mutex mLock
std::atomic< int > mLastIdentifier
std::vector< PathRequest::wptr > requests_
An endpoint that consumes resources.
virtual JobQueue & getJobQueue()=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)