xrpld
Loading...
Searching...
No Matches
PathRequestManager.h
1#pragma once
2
3#include <xrpld/app/main/Application.h>
4#include <xrpld/rpc/detail/AssetCache.h>
5#include <xrpld/rpc/detail/PathRequest.h>
6
7#include <xrpl/beast/insight/Collector.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/json/json_value.h>
10#include <xrpl/ledger/ReadView.h>
11#include <xrpl/resource/Consumer.h>
12#include <xrpl/server/InfoSub.h>
13
14#include <atomic>
15#include <chrono>
16#include <functional>
17#include <memory>
18#include <mutex>
19#include <vector>
20
21namespace xrpl {
22
24{
25public:
30 Application& app,
31 beast::Journal journal,
32 beast::insight::Collector::ptr const& collector)
33 : app_(app), journal_(journal), lastIdentifier_(0)
34 {
35 fast_ = collector->makeEvent("pathfind_fast");
36 full_ = collector->makeEvent("pathfind_full");
37 }
38
44 void
46
47 bool
48 requestsPending() const;
49
51 getAssetCache(std::shared_ptr<ReadView const> const& ledger, bool authoritative);
52
53 // Create a new-style path request that pushes
54 // updates to a subscriber
57 std::shared_ptr<InfoSub> const& subscriber,
59 json::Value const& request);
60
61 // Create an old-style path request that is
62 // managed by a coroutine and updated by
63 // the path engine
67 std::function<void(void)> completion,
68 resource::Consumer& consumer,
69 std::shared_ptr<ReadView const> const& inLedger,
70 json::Value const& request);
71
72 // Execute an old-style path request immediately
73 // with the ledger specified by the caller
76 resource::Consumer& consumer,
77 std::shared_ptr<ReadView const> const& inLedger,
78 json::Value const& request);
79
80 void
82 {
83 fast_.notify(ms);
84 }
85
86 void
88 {
89 full_.notify(ms);
90 }
91
92private:
93 void
95
98
101
102 // Track all requests
104
105 // Use a AssetCache
107
109
111};
112
113} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
std::shared_ptr< Collector > ptr
Definition Collector.h:29
A metric for reporting event timing.
Definition Event.h:22
Represents a JSON value.
Definition json_value.h:117
std::atomic< int > lastIdentifier_
std::vector< PathRequest::wptr > requests_
std::shared_ptr< AssetCache > getAssetCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current AssetCache, updating it if necessary.
std::weak_ptr< AssetCache > assetCache_
json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, json::Value const &request)
beast::insight::Event full_
void reportFull(std::chrono::milliseconds ms)
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 updateAll(std::shared_ptr< ReadView const > const &ledger)
Update all of the contained PathRequest instances.
beast::insight::Event fast_
void reportFast(std::chrono::milliseconds ms)
void insertPathRequest(PathRequest::pointer const &)
std::recursive_mutex lock_
PathRequestManager(Application &app, beast::Journal journal, beast::insight::Collector::ptr const &collector)
A collection of all PathRequest instances.
json::Value doLegacyPathRequest(resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, json::Value const &request)
std::shared_ptr< PathRequest > pointer
Definition PathRequest.h:48
An endpoint that consumes resources.
Definition Consumer.h:20
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5