xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
handlers
orderbook
PathFind.cpp
1
#include <xrpld/app/ledger/LedgerMaster.h>
2
#include <xrpld/app/main/Application.h>
3
#include <xrpld/rpc/Context.h>
4
#include <xrpld/rpc/detail/PathRequestManager.h>
5
6
#include <xrpl/json/json_value.h>
7
#include <xrpl/protocol/ErrorCodes.h>
8
#include <xrpl/protocol/RPCErr.h>
9
#include <xrpl/protocol/jss.h>
10
#include <xrpl/resource/Fees.h>
11
#include <xrpl/server/InfoSub.h>
12
13
namespace
xrpl
{
14
15
json::Value
16
doPathFind
(
rpc::JsonContext
& context)
17
{
18
if
(context.
app
.
config
().
pathSearchMax
== 0)
19
return
rpcError
(
RpcNotSupported
);
20
21
auto
lpLedger = context.
ledgerMaster
.
getClosedLedger
();
22
23
if
(!context.
params
.
isMember
(jss::subcommand) || !context.
params
[jss::subcommand].
isString
())
24
{
25
return
rpcError
(
RpcInvalidParams
);
26
}
27
28
if
(!context.
infoSub
)
29
return
rpcError
(
RpcNoEvents
);
30
31
context.
infoSub
->
setApiVersion
(context.
apiVersion
);
32
33
auto
sSubCommand = context.
params
[jss::subcommand].
asString
();
34
35
if
(sSubCommand ==
"create"
)
36
{
37
context.
loadType
=
resource::kFeeHeavyBurdenRpc
;
38
context.
infoSub
->
clearRequest
();
39
return
context.
app
.
getPathRequestManager
().
makePathRequest
(
40
context.
infoSub
, lpLedger, context.
params
);
41
}
42
43
if
(sSubCommand ==
"close"
)
44
{
45
InfoSubRequest::pointer
const
request = context.
infoSub
->
getRequest
();
46
47
if
(!request)
48
return
rpcError
(
RpcNoPfRequest
);
49
50
context.
infoSub
->
clearRequest
();
51
return
request->
doClose
();
52
}
53
54
if
(sSubCommand ==
"status"
)
55
{
56
InfoSubRequest::pointer
const
request = context.
infoSub
->
getRequest
();
57
58
if
(!request)
59
return
rpcError
(
RpcNoPfRequest
);
60
61
return
request->
doStatus
(context.
params
);
62
}
63
64
return
rpcError
(
RpcInvalidParams
);
65
}
66
67
}
// namespace xrpl
json::Value::isString
bool isString() const
Definition
json_value.cpp:1134
json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition
json_value.cpp:494
json::Value::isMember
bool isMember(char const *key) const
Return true if the object has a member named key.
Definition
json_value.cpp:1049
xrpl::Application::config
virtual Config & config()=0
xrpl::Config::pathSearchMax
int pathSearchMax
Definition
src/xrpld/core/Config.h:201
xrpl::InfoSubRequest::pointer
std::shared_ptr< InfoSubRequest > pointer
Definition
InfoSub.h:63
xrpl::InfoSubRequest::doClose
virtual json::Value doClose()=0
xrpl::InfoSubRequest::doStatus
virtual json::Value doStatus(json::Value const &)=0
xrpl::InfoSub::clearRequest
void clearRequest()
Definition
libxrpl/server/InfoSub.cpp:292
xrpl::InfoSub::setApiVersion
void setApiVersion(unsigned int apiVersion)
Definition
libxrpl/server/InfoSub.cpp:310
xrpl::InfoSub::getRequest
std::shared_ptr< InfoSubRequest > const & getRequest()
Definition
libxrpl/server/InfoSub.cpp:304
xrpl::LedgerMaster::getClosedLedger
std::shared_ptr< Ledger const > getClosedLedger()
The finalized ledger is the last closed/accepted ledger.
Definition
LedgerMaster.h:193
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::ServiceRegistry::getPathRequestManager
virtual PathRequestManager & getPathRequestManager()=0
xrpl::resource::kFeeHeavyBurdenRpc
Charge const kFeeHeavyBurdenRpc
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::RpcNotSupported
@ RpcNotSupported
Definition
ErrorCodes.h:115
xrpl::RpcNoPfRequest
@ RpcNoPfRequest
Definition
ErrorCodes.h:69
xrpl::RpcNoEvents
@ RpcNoEvents
Definition
ErrorCodes.h:37
xrpl::RpcInvalidParams
@ RpcInvalidParams
Definition
ErrorCodes.h:67
xrpl::doPathFind
json::Value doPathFind(rpc::JsonContext &)
Definition
PathFind.cpp:16
xrpl::rpcError
json::Value rpcError(ErrorCodeI iError)
Definition
RPCErr.cpp:13
xrpl::rpc::Context::loadType
resource::Charge & loadType
Definition
Context.h:30
xrpl::rpc::Context::infoSub
InfoSub::pointer infoSub
Definition
Context.h:36
xrpl::rpc::Context::apiVersion
unsigned int apiVersion
Definition
Context.h:37
xrpl::rpc::Context::app
Application & app
Definition
Context.h:29
xrpl::rpc::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition
Context.h:32
xrpl::rpc::JsonContext
Definition
Context.h:41
xrpl::rpc::JsonContext::params
json::Value params
Definition
Context.h:51
Generated by
1.17.0