rippled
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 <ripple/app/main/Application.h>
24 #include <ripple/app/paths/PathRequest.h>
25 #include <ripple/app/paths/RippleLineCache.h>
26 #include <ripple/core/Job.h>
27 #include <atomic>
28 #include <mutex>
29 #include <vector>
30 
31 namespace ripple {
32 
34 {
35 public:
38  beast::Journal journal, beast::insight::Collector::ptr const& collector)
39  : app_ (app)
40  , mJournal (journal)
41  , mLastIdentifier (0)
42  {
43  mFast = collector->make_event ("pathfind_fast");
44  mFull = collector->make_event ("pathfind_full");
45  }
46 
52  void updateAll (std::shared_ptr<ReadView const> const& ledger,
53  Job::CancelCallback shouldCancel);
54 
56  std::shared_ptr <ReadView const> const& ledger, bool authoritative);
57 
58  // Create a new-style path request that pushes
59  // updates to a subscriber
61  std::shared_ptr <InfoSub> const& subscriber,
62  std::shared_ptr<ReadView const> const& ledger,
63  Json::Value const& request);
64 
65  // Create an old-style path request that is
66  // managed by a coroutine and updated by
67  // the path engine
70  std::function <void (void)> completion,
71  Resource::Consumer& consumer,
72  std::shared_ptr<ReadView const> const& inLedger,
73  Json::Value const& request);
74 
75  // Execute an old-style path request immediately
76  // with the ledger specified by the caller
78  Resource::Consumer& consumer,
79  std::shared_ptr<ReadView const> const& inLedger,
80  Json::Value const& request);
81 
83  {
84  mFast.notify (ms);
85  }
86 
88  {
89  mFull.notify (ms);
90  }
91 
92 private:
94 
97 
100 
101  // Track all requests
103 
104  // Use a RippleLineCache
106 
108 
110 
111 };
112 
113 } // ripple
114 
115 #endif
ripple::Application
Definition: Application.h:85
ripple::PathRequests::doLegacyPathRequest
Json::Value doLegacyPathRequest(Resource::Consumer &consumer, std::shared_ptr< ReadView const > const &inLedger, Json::Value const &request)
Definition: PathRequests.cpp:261
ripple::PathRequests::PathRequests
PathRequests(Application &app, beast::Journal journal, beast::insight::Collector::ptr const &collector)
A collection of all PathRequest instances.
Definition: PathRequests.h:37
std::shared_ptr< Collector >
ripple::PathRequests::makePathRequest
Json::Value makePathRequest(std::shared_ptr< InfoSub > const &subscriber, std::shared_ptr< ReadView const > const &ledger, Json::Value const &request)
Definition: PathRequests.cpp:205
ripple::PathRequests::mFast
beast::insight::Event mFast
Definition: PathRequests.h:98
vector
std::chrono::milliseconds
ripple::PathRequests::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: PathRequests.cpp:227
std::recursive_mutex
STL class.
std::function
ripple::PathRequests::mLastIdentifier
std::atomic< int > mLastIdentifier
Definition: PathRequests.h:107
ripple::PathRequests::app_
Application & app_
Definition: PathRequests.h:95
ripple::PathRequests::insertPathRequest
void insertPathRequest(PathRequest::pointer const &)
Definition: PathRequests.cpp:183
ripple::PathRequests::getLineCache
std::shared_ptr< RippleLineCache > getLineCache(std::shared_ptr< ReadView const > const &ledger, bool authoritative)
Get the current RippleLineCache, updating it if necessary.
Definition: PathRequests.cpp:37
beast::insight::Event
A metric for reporting event timing.
Definition: Event.h:42
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::PathRequests::mJournal
beast::Journal mJournal
Definition: PathRequests.h:96
ripple::PathRequests::mFull
beast::insight::Event mFull
Definition: PathRequests.h:99
atomic
ripple::PathRequests::mLock
std::recursive_mutex mLock
Definition: PathRequests.h:109
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::PathRequests::reportFast
void reportFast(std::chrono::milliseconds ms)
Definition: PathRequests.h:82
ripple::Resource::Consumer
An endpoint that consumes resources.
Definition: Consumer.h:33
ripple::PathRequests::reportFull
void reportFull(std::chrono::milliseconds ms)
Definition: PathRequests.h:87
ripple::PathRequests::mLineCache
std::shared_ptr< RippleLineCache > mLineCache
Definition: PathRequests.h:105
mutex
ripple::PathRequests
Definition: PathRequests.h:33
ripple::PathRequests::updateAll
void updateAll(std::shared_ptr< ReadView const > const &ledger, Job::CancelCallback shouldCancel)
Update all of the contained PathRequest instances.
Definition: PathRequests.cpp:56
ripple::PathRequests::requests_
std::vector< PathRequest::wptr > requests_
Definition: PathRequests.h:102
Json::Value
Represents a JSON value.
Definition: json_value.h:141
beast::insight::Event::notify
void notify(std::chrono::duration< Rep, Period > const &value) const
Push an event notification.
Definition: Event.h:65