diff --git a/src/cpp/ripple/PFRequest.h b/src/cpp/ripple/PFRequest.h new file mode 100644 index 000000000..9c0f4d0b0 --- /dev/null +++ b/src/cpp/ripple/PFRequest.h @@ -0,0 +1,61 @@ +#ifndef _PFREQUEST__H +#define _PFREQUEST__H + +#include +#include + +#include +#include +#include + +#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 wptr; + typedef boost::shared_ptr pointer; + typedef const pointer& ref; + typedef std::pair currIssuer_t; + + +protected: + boost::weak_ptr wpSubscriber; // Who this request came from + Json::Value jvStatus; // Last result + + // Client request parameters + RippleAddress raSrcAccount; + RippleAddress raDstAccount; + STAmount saDstAmount; + std::set sciSourceCurrencies; + std::vector vjvBridges; + + // Track all requests + static std::set sRequests; + static boost::recursive_mutex sLock; + +public: + + PFRequest(const boost::shared_ptr& 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 &); +}; + +#endif diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index e5af79c75..fdd87534d 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -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 }, diff --git a/src/cpp/ripple/RPCHandler.h b/src/cpp/ripple/RPCHandler.h index 710ed1212..f5b73c39b 100644 --- a/src/cpp/ripple/RPCHandler.h +++ b/src/cpp/ripple/RPCHandler.h @@ -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);