rippled
Loading...
Searching...
No Matches
PathRequests.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_PATHS_PATHREQUESTS_H_INCLUDED
21#define RIPPLE_APP_PATHS_PATHREQUESTS_H_INCLUDED
22
23#include <xrpld/app/main/Application.h>
24#include <xrpld/app/paths/PathRequest.h>
25#include <xrpld/app/paths/RippleLineCache.h>
26#include <xrpld/core/Job.h>
27#include <atomic>
28#include <mutex>
29#include <vector>
30
31namespace ripple {
32
34{
35public:
38 Application& app,
39 beast::Journal journal,
40 beast::insight::Collector::ptr const& collector)
41 : app_(app), mJournal(journal), mLastIdentifier(0)
42 {
43 mFast = collector->make_event("pathfind_fast");
44 mFull = collector->make_event("pathfind_full");
45 }
46
51 void
53
54 bool
55 requestsPending() const;
56
60 bool authoritative);
61
62 // Create a new-style path request that pushes
63 // updates to a subscriber
66 std::shared_ptr<InfoSub> const& subscriber,
68 Json::Value const& request);
69
70 // Create an old-style path request that is
71 // managed by a coroutine and updated by
72 // the path engine
76 std::function<void(void)> completion,
77 Resource::Consumer& consumer,
78 std::shared_ptr<ReadView const> const& inLedger,
79 Json::Value const& request);
80
81 // Execute an old-style path request immediately
82 // with the ledger specified by the caller
85 Resource::Consumer& consumer,
86 std::shared_ptr<ReadView const> const& inLedger,
87 Json::Value const& request);
88
89 void
91 {
92 mFast.notify(ms);
93 }
94
95 void
97 {
98 mFull.notify(ms);
99 }
100
101private:
102 void
104
107
110
111 // Track all requests
113
114 // Use a RippleLineCache
116
118
120};
121
122} // namespace ripple
123
124#endif
Represents a JSON value.
Definition: json_value.h:147
A generic endpoint for log messages.
Definition: Journal.h:59
A metric for reporting event timing.
Definition: Event.h:41
void notify(std::chrono::duration< Rep, Period > const &value) const
Push an event notification.
Definition: Event.h:64
PathRequests(Application &app, beast::Journal journal, beast::insight::Collector::ptr const &collector)
A collection of all PathRequest instances.
Definition: PathRequests.h:37
beast::Journal mJournal
Definition: PathRequests.h:106
void updateAll(std::shared_ptr< ReadView const > const &ledger)
Update all of the contained PathRequest instances.
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)
beast::insight::Event mFull
Definition: PathRequests.h:109
std::weak_ptr< RippleLineCache > lineCache_
Definition: PathRequests.h:115
void reportFast(std::chrono::milliseconds ms)
Definition: PathRequests.h:90
std::shared_ptr< RippleLineCache > getLineCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current RippleLineCache, updating it if necessary.
std::recursive_mutex mLock
Definition: PathRequests.h:119
bool requestsPending() const
std::atomic< int > mLastIdentifier
Definition: PathRequests.h:117
void reportFull(std::chrono::milliseconds ms)
Definition: PathRequests.h:96
Json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, Json::Value const &request)
beast::insight::Event mFast
Definition: PathRequests.h:108
std::vector< PathRequest::wptr > requests_
Definition: PathRequests.h:112
Application & app_
Definition: PathRequests.h:105
An endpoint that consumes resources.
Definition: Consumer.h:35
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26