mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 04:55:52 +00:00
Let RPC ripple_path_find work on any ledger.
This commit is contained in:
@@ -442,16 +442,23 @@ Json::Value RPCParser::parseAccountItems(const Json::Value& jvParams)
|
|||||||
return jvRequest;
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ripple_path_find json
|
// ripple_path_find <json> [<ledger>]
|
||||||
Json::Value RPCParser::parseRipplePathFind(const Json::Value& jvParams)
|
Json::Value RPCParser::parseRipplePathFind(const Json::Value& jvParams)
|
||||||
{
|
{
|
||||||
Json::Value txJSON;
|
|
||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
|
Json::Value jvRequest;
|
||||||
|
bool bLedger = 2 == jvParams.size();
|
||||||
|
|
||||||
cLog(lsTRACE) << "RPC json:" << jvParams[0u];
|
cLog(lsTRACE) << "RPC json: " << jvParams[0u];
|
||||||
if (reader.parse(jvParams[0u].asString(), txJSON))
|
|
||||||
|
if (bLedger)
|
||||||
{
|
{
|
||||||
return txJSON;
|
jvParseLedger(jvRequest, jvParams[1u].asString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reader.parse(jvParams[0u].asString(), jvRequest))
|
||||||
|
{
|
||||||
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpcError(rpcINVALID_PARAMS);
|
return rpcError(rpcINVALID_PARAMS);
|
||||||
@@ -652,7 +659,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
{ "ping", &RPCParser::parseAsIs, 0, 0 },
|
{ "ping", &RPCParser::parseAsIs, 0, 0 },
|
||||||
// { "profile", &RPCParser::parseProfile, 1, 9 },
|
// { "profile", &RPCParser::parseProfile, 1, 9 },
|
||||||
{ "random", &RPCParser::parseAsIs, 0, 0 },
|
{ "random", &RPCParser::parseAsIs, 0, 0 },
|
||||||
{ "ripple_path_find", &RPCParser::parseRipplePathFind, 1, 1 },
|
{ "ripple_path_find", &RPCParser::parseRipplePathFind, 1, 2 },
|
||||||
{ "sign", &RPCParser::parseSignSubmit, 2, 2 },
|
{ "sign", &RPCParser::parseSignSubmit, 2, 2 },
|
||||||
{ "submit", &RPCParser::parseSignSubmit, 1, 2 },
|
{ "submit", &RPCParser::parseSignSubmit, 1, 2 },
|
||||||
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
||||||
|
|||||||
@@ -885,7 +885,6 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest)
|
|||||||
if (!lpLedger)
|
if (!lpLedger)
|
||||||
return jvResult;
|
return jvResult;
|
||||||
|
|
||||||
|
|
||||||
if (!jvRequest.isMember("account"))
|
if (!jvRequest.isMember("account"))
|
||||||
return rpcError(rpcINVALID_PARAMS);
|
return rpcError(rpcINVALID_PARAMS);
|
||||||
|
|
||||||
@@ -1153,10 +1152,14 @@ Json::Value RPCHandler::doRandom(Json::Value jvRequest)
|
|||||||
// - From a trusted server, allows clients to use path without manipulation.
|
// - From a trusted server, allows clients to use path without manipulation.
|
||||||
Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
Json::Value jvResult(Json::objectValue);
|
|
||||||
RippleAddress raSrc;
|
RippleAddress raSrc;
|
||||||
RippleAddress raDst;
|
RippleAddress raDst;
|
||||||
STAmount saDstAmount;
|
STAmount saDstAmount;
|
||||||
|
Ledger::pointer lpLedger;
|
||||||
|
Json::Value jvResult = lookupLedger(jvRequest, lpLedger);
|
||||||
|
|
||||||
|
if (!lpLedger)
|
||||||
|
return jvResult;
|
||||||
|
|
||||||
if (theApp->getJobQueue().getJobCountGE(jtCLIENT) > 200)
|
if (theApp->getJobQueue().getJobCountGE(jtCLIENT) > 200)
|
||||||
{
|
{
|
||||||
@@ -1201,7 +1204,6 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ledger::pointer lpCurrent = mNetOps->getCurrentLedger();
|
|
||||||
Json::Value jvSrcCurrencies;
|
Json::Value jvSrcCurrencies;
|
||||||
|
|
||||||
if (jvRequest.isMember("source_currencies"))
|
if (jvRequest.isMember("source_currencies"))
|
||||||
@@ -1210,7 +1212,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::unordered_set<uint160> usCurrencies = usAccountSourceCurrencies(raSrc, lpCurrent);
|
boost::unordered_set<uint160> usCurrencies = usAccountSourceCurrencies(raSrc, lpLedger);
|
||||||
|
|
||||||
// Add XRP as a source currency.
|
// Add XRP as a source currency.
|
||||||
// YYY Only bother if they are above reserve.
|
// YYY Only bother if they are above reserve.
|
||||||
@@ -1228,7 +1230,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::pointer lSnapShot = boost::make_shared<Ledger>(boost::ref(*lpCurrent), false);
|
Ledger::pointer lSnapShot = boost::make_shared<Ledger>(boost::ref(*lpLedger), false);
|
||||||
LedgerEntrySet lesSnapshot(lSnapShot);
|
LedgerEntrySet lesSnapshot(lSnapShot);
|
||||||
|
|
||||||
ScopedUnlock su(theApp->getMasterLock()); // As long as we have a locked copy of the ledger, we can unlock.
|
ScopedUnlock su(theApp->getMasterLock()); // As long as we have a locked copy of the ledger, we can unlock.
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ void printHelp(const po::options_description& desc)
|
|||||||
cerr << " peers" << endl;
|
cerr << " peers" << endl;
|
||||||
cerr << " random" << endl;
|
cerr << " random" << endl;
|
||||||
cerr << " ripple ..." << endl;
|
cerr << " ripple ..." << endl;
|
||||||
|
cerr << " ripple_path_find <json> [<ledger>]" << endl;
|
||||||
// cerr << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
|
// cerr << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
|
||||||
cerr << " stop" << endl;
|
cerr << " stop" << endl;
|
||||||
cerr << " tx <id>" << endl;
|
cerr << " tx <id>" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user