xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
detail
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
21
namespace
xrpl
{
22
23
class
PathRequestManager
24
{
25
public
:
29
PathRequestManager
(
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
45
updateAll
(
std::shared_ptr<ReadView const>
const
& ledger);
46
47
bool
48
requestsPending
()
const
;
49
50
std::shared_ptr<AssetCache>
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
55
json::Value
56
makePathRequest
(
57
std::shared_ptr<InfoSub>
const
& subscriber,
58
std::shared_ptr<ReadView const>
const
& ledger,
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
64
json::Value
65
makeLegacyPathRequest
(
66
PathRequest::pointer
& req,
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
74
json::Value
75
doLegacyPathRequest
(
76
resource::Consumer
& consumer,
77
std::shared_ptr<ReadView const>
const
& inLedger,
78
json::Value
const
& request);
79
80
void
81
reportFast
(
std::chrono::milliseconds
ms)
82
{
83
fast_
.notify(ms);
84
}
85
86
void
87
reportFull
(
std::chrono::milliseconds
ms)
88
{
89
full_
.notify(ms);
90
}
91
92
private
:
93
void
94
insertPathRequest
(
PathRequest::pointer
const
&);
95
96
Application
&
app_
;
97
beast::Journal
journal_
;
98
99
beast::insight::Event
fast_
;
100
beast::insight::Event
full_
;
101
102
// Track all requests
103
std::vector<PathRequest::Wptr>
requests_
;
104
105
// Use a AssetCache
106
std::weak_ptr<AssetCache>
assetCache_
;
107
108
std::atomic<int>
lastIdentifier_
;
109
110
std::recursive_mutex
mutable
lock_
;
111
};
112
113
}
// namespace xrpl
atomic
chrono
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::insight::Collector::Ptr
std::shared_ptr< Collector > Ptr
Definition
Collector.h:29
beast::insight::Event
A metric for reporting event timing.
Definition
Event.h:22
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::Application
Definition
Application.h:94
xrpl::PathRequestManager::app_
Application & app_
Definition
PathRequestManager.h:96
xrpl::PathRequestManager::lastIdentifier_
std::atomic< int > lastIdentifier_
Definition
PathRequestManager.h:108
xrpl::PathRequestManager::requestsPending
bool requestsPending() const
Definition
PathRequestManager.cpp:209
xrpl::PathRequestManager::getAssetCache
std::shared_ptr< AssetCache > getAssetCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current AssetCache, updating it if necessary.
Definition
PathRequestManager.cpp:34
xrpl::PathRequestManager::assetCache_
std::weak_ptr< AssetCache > assetCache_
Definition
PathRequestManager.h:106
xrpl::PathRequestManager::makePathRequest
json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, json::Value const &request)
Definition
PathRequestManager.cpp:234
xrpl::PathRequestManager::full_
beast::insight::Event full_
Definition
PathRequestManager.h:100
xrpl::PathRequestManager::reportFull
void reportFull(std::chrono::milliseconds ms)
Definition
PathRequestManager.h:87
xrpl::PathRequestManager::makeLegacyPathRequest
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)
Definition
PathRequestManager.cpp:254
xrpl::PathRequestManager::updateAll
void updateAll(std::shared_ptr< ReadView const > const &ledger)
Update all of the contained PathRequest instances.
Definition
PathRequestManager.cpp:61
xrpl::PathRequestManager::fast_
beast::insight::Event fast_
Definition
PathRequestManager.h:99
xrpl::PathRequestManager::reportFast
void reportFast(std::chrono::milliseconds ms)
Definition
PathRequestManager.h:81
xrpl::PathRequestManager::insertPathRequest
void insertPathRequest(PathRequest::pointer const &)
Definition
PathRequestManager.cpp:216
xrpl::PathRequestManager::PathRequestManager
PathRequestManager(Application &app, beast::Journal journal, beast::insight::Collector::Ptr const &collector)
A collection of all PathRequest instances.
Definition
PathRequestManager.h:29
xrpl::PathRequestManager::lock_
std::recursive_mutex lock_
Definition
PathRequestManager.h:110
xrpl::PathRequestManager::doLegacyPathRequest
json::Value doLegacyPathRequest(resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, json::Value const &request)
Definition
PathRequestManager.cpp:287
xrpl::PathRequestManager::journal_
beast::Journal journal_
Definition
PathRequestManager.h:97
xrpl::PathRequestManager::requests_
std::vector< PathRequest::Wptr > requests_
Definition
PathRequestManager.h:103
xrpl::PathRequest::pointer
std::shared_ptr< PathRequest > pointer
Definition
PathRequest.h:48
xrpl::resource::Consumer
An endpoint that consumes resources.
Definition
Consumer.h:20
std::chrono::milliseconds
std::function
functional
memory
mutex
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
std::recursive_mutex
std::shared_ptr
vector
std::weak_ptr
Generated by
1.17.0