rippled
Loading...
Searching...
No Matches
LegacyPathFind.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012-2014 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#include <xrpld/app/main/Application.h>
21#include <xrpld/app/misc/LoadFeeTrack.h>
22#include <xrpld/core/Job.h>
23#include <xrpld/core/JobQueue.h>
24#include <xrpld/rpc/detail/LegacyPathFind.h>
25#include <xrpld/rpc/detail/Tuning.h>
26
27namespace ripple {
28namespace RPC {
29
31{
32 if (isAdmin)
33 {
34 ++inProgress;
35 m_isOk = true;
36 return;
37 }
38
39 auto const& jobCount = app.getJobQueue().getJobCountGE(jtCLIENT);
40 if (jobCount > Tuning::maxPathfindJobCount ||
42 return;
43
44 while (true)
45 {
46 int prevVal = inProgress.load();
47 if (prevVal >= Tuning::maxPathfindsInProgress)
48 return;
49
51 prevVal,
52 prevVal + 1,
55 {
56 m_isOk = true;
57 return;
58 }
59 }
60}
61
67
69
70} // namespace RPC
71} // namespace ripple
virtual LoadFeeTrack & getFeeTrack()=0
virtual JobQueue & getJobQueue()=0
int getJobCountGE(JobType t) const
All waiting jobs at or greater than this priority.
Definition JobQueue.cpp:162
bool isLoadedLocal() const
static std::atomic< int > inProgress
LegacyPathFind(bool isAdmin, Application &app)
T compare_exchange_strong(T... args)
T is_same_v
T load(T... args)
static int constexpr maxPathfindJobCount
static int constexpr maxPathfindsInProgress
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
bool isAdmin(Port const &port, Json::Value const &params, beast::IP::Address const &remoteIp)
Definition Role.cpp:85
@ jtCLIENT
Definition Job.h:45