mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 15:05:53 +00:00
New pathfinder API work.
This commit is contained in:
61
src/cpp/ripple/PFRequest.h
Normal file
61
src/cpp/ripple/PFRequest.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef _PFREQUEST__H
|
||||
#define _PFREQUEST__H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
#include "../json/value.h"
|
||||
|
||||
#include "uint256.h"
|
||||
#include "RippleAddress.h"
|
||||
#include "SerializedTypes.h"
|
||||
|
||||
// A pathfinding request submitted by a client
|
||||
// The request issuer must maintain a strong pointer
|
||||
|
||||
class Ledger;
|
||||
class InfoSub;
|
||||
class STAmount;
|
||||
|
||||
class PFRequest
|
||||
{
|
||||
public:
|
||||
typedef boost::weak_ptr<PFRequest> wptr;
|
||||
typedef boost::shared_ptr<PFRequest> pointer;
|
||||
typedef const pointer& ref;
|
||||
typedef std::pair<uint160, uint160> currIssuer_t;
|
||||
|
||||
|
||||
protected:
|
||||
boost::weak_ptr<InfoSub> wpSubscriber; // Who this request came from
|
||||
Json::Value jvStatus; // Last result
|
||||
|
||||
// Client request parameters
|
||||
RippleAddress raSrcAccount;
|
||||
RippleAddress raDstAccount;
|
||||
STAmount saDstAmount;
|
||||
std::set<currIssuer_t> sciSourceCurrencies;
|
||||
std::vector<Json::Value> vjvBridges;
|
||||
|
||||
// Track all requests
|
||||
static std::set<wptr> sRequests;
|
||||
static boost::recursive_mutex sLock;
|
||||
|
||||
public:
|
||||
|
||||
PFRequest(const boost::shared_ptr<InfoSub>& subscriber, Json::Value request);
|
||||
~PFRequest();
|
||||
|
||||
Json::Value create(const Json::Value&);
|
||||
Json::Value close(const Json::Value&);
|
||||
Json::Value status(const Json::Value&);
|
||||
void update();
|
||||
|
||||
static void updateAll(const boost::shared_ptr<Ledger> &);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1166,6 +1166,30 @@ Json::Value RPCHandler::doRandom(Json::Value jvRequest, int& cost, ScopedLock& M
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doPathFind(Json::Value jvRequest, int& cost, ScopedLock& MasterLockHolder)
|
||||
{
|
||||
if (!jvRequest.isMember("subcommand") || !jvRequest["subcommand"].isString())
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
std::string sSubCommand = jvRequest["subcommand"].asString();
|
||||
|
||||
if (sSubCommand == "create")
|
||||
{
|
||||
// WRITEME
|
||||
}
|
||||
|
||||
if (sSubCommand == "close")
|
||||
{
|
||||
// WRITEME
|
||||
}
|
||||
|
||||
if (sSubCommand == "status")
|
||||
{
|
||||
// WRITEME
|
||||
}
|
||||
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// - Add support for specifying non-endpoint issuer.
|
||||
// - Return fully expanded path with proof.
|
||||
@@ -3292,6 +3316,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int &
|
||||
// { "nickname_info", &RPCHandler::doNicknameInfo, false, optCurrent },
|
||||
{ "owner_info", &RPCHandler::doOwnerInfo, false, optCurrent },
|
||||
{ "peers", &RPCHandler::doPeers, true, optNone },
|
||||
{ "path_find", &RPCHandler::doPathFind, false, optCurrent },
|
||||
{ "ping", &RPCHandler::doPing, false, optNone },
|
||||
// { "profile", &RPCHandler::doProfile, false, optCurrent },
|
||||
{ "random", &RPCHandler::doRandom, false, optNone },
|
||||
|
||||
@@ -69,6 +69,7 @@ class RPCHandler
|
||||
Json::Value doNicknameInfo(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doOwnerInfo(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doPeers(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doPathFind(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doPing(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doProfile(Json::Value params, int& cost, ScopedLock& mlh);
|
||||
Json::Value doRandom(Json::Value jvRequest, int& cost, ScopedLock& mlh);
|
||||
|
||||
Reference in New Issue
Block a user