mirror of
https://github.com/XRPLF/clio.git
synced 2026-06-04 09:16:43 +00:00
clang-format (#86)
* clang-format * ignore clang-format commit; run clang-format in github actions
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
#include <rpc/Counters.h>
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
namespace RPC {
|
||||
|
||||
void
|
||||
Counters::initializeCounter(std::string const& method)
|
||||
{
|
||||
std::shared_lock lk(mutex_);
|
||||
if(methodInfo_.count(method) == 0)
|
||||
{
|
||||
if (methodInfo_.count(method) == 0)
|
||||
{
|
||||
lk.unlock();
|
||||
std::unique_lock ulk(mutex_);
|
||||
|
||||
@@ -57,7 +56,7 @@ Counters::report()
|
||||
{
|
||||
std::shared_lock lk(mutex_);
|
||||
boost::json::object obj = {};
|
||||
|
||||
|
||||
for (auto const& [method, info] : methodInfo_)
|
||||
{
|
||||
boost::json::object counters = {};
|
||||
@@ -73,4 +72,4 @@ Counters::report()
|
||||
return obj;
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
} // namespace RPC
|
||||
@@ -1,14 +1,13 @@
|
||||
#ifndef RPC_COUNTERS_H
|
||||
#define RPC_COUNTERS_H
|
||||
|
||||
#include <boost/json.hpp>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <shared_mutex>
|
||||
#include <boost/json.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
namespace RPC {
|
||||
|
||||
class Counters
|
||||
{
|
||||
@@ -23,14 +22,14 @@ private:
|
||||
std::atomic_uint forwarded{0};
|
||||
std::atomic_uint duration{0};
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
initializeCounter(std::string const& method);
|
||||
|
||||
std::shared_mutex mutex_;
|
||||
std::unordered_map<std::string, MethodInfo> methodInfo_;
|
||||
|
||||
public:
|
||||
public:
|
||||
Counters() = default;
|
||||
|
||||
void
|
||||
@@ -48,6 +47,6 @@ public:
|
||||
report();
|
||||
};
|
||||
|
||||
} // namespace RPCs
|
||||
} // namespace RPC
|
||||
|
||||
#endif // RPC_COUNTERS_H
|
||||
#endif // RPC_COUNTERS_H
|
||||
@@ -181,7 +181,7 @@ buildResponse(Context const& ctx)
|
||||
|
||||
return *res;
|
||||
}
|
||||
|
||||
|
||||
if (ctx.method == "ping")
|
||||
return boost::json::object{};
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <rpc/Counters.h>
|
||||
#include <optional>
|
||||
#include <rpc/Counters.h>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -8,13 +8,11 @@
|
||||
#include <boost/json.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
namespace RPC {
|
||||
|
||||
void
|
||||
addLine(
|
||||
@@ -47,13 +45,19 @@ addLine(
|
||||
if (!viewLowest)
|
||||
balance.negate();
|
||||
|
||||
bool lineAuth = flags & (viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineAuthPeer = flags & (!viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineNoRipple = flags & (viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineAuth =
|
||||
flags & (viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineAuthPeer =
|
||||
flags & (!viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineNoRipple =
|
||||
flags & (viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineDefaultRipple = flags & ripple::lsfDefaultRipple;
|
||||
bool lineNoRipplePeer = flags & (!viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineFreeze = flags & (viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineFreezePeer = flags & (!viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineNoRipplePeer = flags &
|
||||
(!viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineFreeze =
|
||||
flags & (viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineFreezePeer =
|
||||
flags & (!viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
|
||||
ripple::STAmount const& saBalance(balance);
|
||||
ripple::STAmount const& saLimit(lineLimit);
|
||||
@@ -83,7 +87,7 @@ addLine(
|
||||
jsonLines.push_back(jPeer);
|
||||
}
|
||||
|
||||
Result
|
||||
Result
|
||||
doAccountLines(Context const& context)
|
||||
{
|
||||
auto request = context.params;
|
||||
@@ -95,13 +99,13 @@ doAccountLines(Context const& context)
|
||||
|
||||
auto lgrInfo = std::get<ripple::LedgerInfo>(v);
|
||||
|
||||
if(!request.contains("account"))
|
||||
if (!request.contains("account"))
|
||||
return Status{Error::rpcINVALID_PARAMS, "missingAccount"};
|
||||
|
||||
if(!request.at("account").is_string())
|
||||
if (!request.at("account").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "accountNotString"};
|
||||
|
||||
auto accountID =
|
||||
|
||||
auto accountID =
|
||||
accountFromStringStrict(request.at("account").as_string().c_str());
|
||||
|
||||
if (!accountID)
|
||||
@@ -113,8 +117,8 @@ doAccountLines(Context const& context)
|
||||
if (!request.at("peer").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "peerNotString"};
|
||||
|
||||
peerAccount = accountFromStringStrict(
|
||||
request.at("peer").as_string().c_str());
|
||||
peerAccount =
|
||||
accountFromStringStrict(request.at("peer").as_string().c_str());
|
||||
|
||||
if (!peerAccount)
|
||||
return Status{Error::rpcINVALID_PARAMS, "peerMalformed"};
|
||||
@@ -123,7 +127,7 @@ doAccountLines(Context const& context)
|
||||
std::uint32_t limit = 200;
|
||||
if (request.contains("limit"))
|
||||
{
|
||||
if(!request.at("limit").is_int64())
|
||||
if (!request.at("limit").is_int64())
|
||||
return Status{Error::rpcINVALID_PARAMS, "limitNotInt"};
|
||||
|
||||
limit = request.at("limit").as_int64();
|
||||
@@ -134,7 +138,7 @@ doAccountLines(Context const& context)
|
||||
ripple::uint256 cursor;
|
||||
if (request.contains("cursor"))
|
||||
{
|
||||
if(!request.at("cursor").is_string())
|
||||
if (!request.at("cursor").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "cursorNotString"};
|
||||
|
||||
if (!cursor.parseHex(request.at("cursor").as_string().c_str()))
|
||||
@@ -154,20 +158,15 @@ doAccountLines(Context const& context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
addLine(jsonLines, sle, *accountID, peerAccount);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
auto nextCursor =
|
||||
traverseOwnedNodes(
|
||||
*context.backend,
|
||||
*accountID,
|
||||
lgrInfo.seq,
|
||||
cursor,
|
||||
addToResponse);
|
||||
auto nextCursor = traverseOwnedNodes(
|
||||
*context.backend, *accountID, lgrInfo.seq, cursor, addToResponse);
|
||||
|
||||
if (nextCursor)
|
||||
response["marker"] = ripple::strHex(*nextCursor);
|
||||
@@ -175,4 +174,4 @@ doAccountLines(Context const& context)
|
||||
return response;
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
} // namespace RPC
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
namespace RPC {
|
||||
|
||||
void
|
||||
addOffer(boost::json::array& offersJson, ripple::SLE const& offer)
|
||||
@@ -24,7 +22,7 @@ addOffer(boost::json::array& offersJson, ripple::SLE const& offer)
|
||||
|
||||
ripple::STAmount takerPays = offer.getFieldAmount(ripple::sfTakerPays);
|
||||
ripple::STAmount takerGets = offer.getFieldAmount(ripple::sfTakerGets);
|
||||
|
||||
|
||||
boost::json::object obj;
|
||||
|
||||
if (!takerPays.native())
|
||||
@@ -60,7 +58,7 @@ addOffer(boost::json::array& offersJson, ripple::SLE const& offer)
|
||||
obj["quality"] = rate.getText();
|
||||
if (offer.isFieldPresent(ripple::sfExpiration))
|
||||
obj["expiration"] = offer.getFieldU32(ripple::sfExpiration);
|
||||
|
||||
|
||||
offersJson.push_back(obj);
|
||||
};
|
||||
|
||||
@@ -76,23 +74,22 @@ doAccountOffers(Context const& context)
|
||||
|
||||
auto lgrInfo = std::get<ripple::LedgerInfo>(v);
|
||||
|
||||
if(!request.contains("account"))
|
||||
if (!request.contains("account"))
|
||||
return Status{Error::rpcINVALID_PARAMS, "missingAccount"};
|
||||
|
||||
if(!request.at("account").is_string())
|
||||
if (!request.at("account").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "accountNotString"};
|
||||
|
||||
auto accountID =
|
||||
|
||||
auto accountID =
|
||||
accountFromStringStrict(request.at("account").as_string().c_str());
|
||||
|
||||
if (!accountID)
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedAccount"};
|
||||
|
||||
|
||||
std::uint32_t limit = 200;
|
||||
if (request.contains("limit"))
|
||||
{
|
||||
if(!request.at("limit").is_int64())
|
||||
if (!request.at("limit").is_int64())
|
||||
return Status{Error::rpcINVALID_PARAMS, "limitNotInt"};
|
||||
|
||||
limit = request.at("limit").as_int64();
|
||||
@@ -103,13 +100,13 @@ doAccountOffers(Context const& context)
|
||||
ripple::uint256 cursor;
|
||||
if (request.contains("cursor"))
|
||||
{
|
||||
if(!request.at("cursor").is_string())
|
||||
if (!request.at("cursor").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "cursorNotString"};
|
||||
|
||||
if (!cursor.parseHex(request.at("cursor").as_string().c_str()))
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedCursor"};
|
||||
}
|
||||
|
||||
|
||||
response["account"] = ripple::to_string(*accountID);
|
||||
response["ledger_hash"] = ripple::strHex(lgrInfo.hash);
|
||||
response["ledger_index"] = lgrInfo.seq;
|
||||
@@ -123,20 +120,15 @@ doAccountOffers(Context const& context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
addOffer(jsonLines, sle);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
auto nextCursor =
|
||||
traverseOwnedNodes(
|
||||
*context.backend,
|
||||
*accountID,
|
||||
lgrInfo.seq,
|
||||
cursor,
|
||||
addToResponse);
|
||||
|
||||
auto nextCursor = traverseOwnedNodes(
|
||||
*context.backend, *accountID, lgrInfo.seq, cursor, addToResponse);
|
||||
|
||||
if (nextCursor)
|
||||
response["marker"] = ripple::strHex(*nextCursor);
|
||||
@@ -144,4 +136,4 @@ doAccountOffers(Context const& context)
|
||||
return response;
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
} // namespace RPC
|
||||
@@ -84,7 +84,8 @@ doAccountTx(Context const& context)
|
||||
{
|
||||
if (context.range.maxSequence < min.as_int64() ||
|
||||
context.range.minSequence > min.as_int64())
|
||||
return Status{Error::rpcINVALID_PARAMS, "ledgerSeqMaxOutOfRange"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, "ledgerSeqMaxOutOfRange"};
|
||||
else
|
||||
minIndex = value_to<std::uint32_t>(min);
|
||||
}
|
||||
@@ -105,7 +106,8 @@ doAccountTx(Context const& context)
|
||||
{
|
||||
if (context.range.maxSequence < max.as_int64() ||
|
||||
context.range.minSequence > max.as_int64())
|
||||
return Status{Error::rpcINVALID_PARAMS, "ledgerSeqMaxOutOfRange"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, "ledgerSeqMaxOutOfRange"};
|
||||
else
|
||||
maxIndex = value_to<std::uint32_t>(max);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
namespace RPC {
|
||||
|
||||
|
||||
Result
|
||||
doBookOffers(Context const& context)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
|
||||
|
||||
namespace RPC {
|
||||
|
||||
Result
|
||||
@@ -97,7 +96,7 @@ doLedger(Context const& context)
|
||||
entry["tx_blob"] = ripple::strHex(obj.transaction);
|
||||
entry["meta"] = ripple::strHex(obj.metadata);
|
||||
}
|
||||
//entry["ledger_index"] = obj.ledgerSequence;
|
||||
// entry["ledger_index"] = obj.ledgerSequence;
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <boost/json.hpp>
|
||||
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
// {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
// ...
|
||||
// }
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
namespace RPC {
|
||||
|
||||
using boost::json::value_to;
|
||||
|
||||
@@ -33,7 +32,7 @@ doLedgerEntry(Context const& context)
|
||||
ripple::uint256 key;
|
||||
if (request.contains("index"))
|
||||
{
|
||||
if(!request.at("index").is_string())
|
||||
if (!request.at("index").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "indexNotString"};
|
||||
|
||||
if (!key.parseHex(request.at("index").as_string().c_str()))
|
||||
@@ -41,7 +40,7 @@ doLedgerEntry(Context const& context)
|
||||
}
|
||||
else if (request.contains("account_root"))
|
||||
{
|
||||
if(!request.at("account_root").is_string())
|
||||
if (!request.at("account_root").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "account_rootNotString"};
|
||||
|
||||
auto const account = ripple::parseBase58<ripple::AccountID>(
|
||||
@@ -53,7 +52,7 @@ doLedgerEntry(Context const& context)
|
||||
}
|
||||
else if (request.contains("check"))
|
||||
{
|
||||
if(!request.at("check").is_string())
|
||||
if (!request.at("check").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "checkNotString"};
|
||||
|
||||
if (!key.parseHex(request.at("check").as_string().c_str()))
|
||||
@@ -69,7 +68,8 @@ doLedgerEntry(Context const& context)
|
||||
!key.parseHex(
|
||||
request.at("deposit_preauth").as_string().c_str()))
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "deposit_preauthMalformed"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, "deposit_preauthMalformed"};
|
||||
}
|
||||
}
|
||||
else if (
|
||||
@@ -78,9 +78,12 @@ doLedgerEntry(Context const& context)
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "ownerNotString"};
|
||||
}
|
||||
else if(
|
||||
else if (
|
||||
!request.at("deposit_preauth").as_object().contains("authorized") ||
|
||||
!request.at("deposit_preauth").as_object().at("authorized").is_string())
|
||||
!request.at("deposit_preauth")
|
||||
.as_object()
|
||||
.at("authorized")
|
||||
.is_string())
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "authorizedNotString"};
|
||||
}
|
||||
@@ -107,7 +110,7 @@ doLedgerEntry(Context const& context)
|
||||
{
|
||||
if (!request.at("directory").is_object())
|
||||
{
|
||||
if(!request.at("directory").is_string())
|
||||
if (!request.at("directory").is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "directoryNotString"};
|
||||
|
||||
if (!key.parseHex(request.at("directory").as_string().c_str()))
|
||||
@@ -135,10 +138,12 @@ doLedgerEntry(Context const& context)
|
||||
if (directory.contains("owner"))
|
||||
{
|
||||
// May not specify both dir_root and owner.
|
||||
return Status{Error::rpcINVALID_PARAMS, "mayNotSpecifyBothDirRootAndOwner"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS,
|
||||
"mayNotSpecifyBothDirRootAndOwner"};
|
||||
}
|
||||
else if (!uDirRoot.parseHex(
|
||||
directory.at("dir_root").as_string().c_str()))
|
||||
directory.at("dir_root").as_string().c_str()))
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedDirRoot"};
|
||||
}
|
||||
@@ -158,14 +163,15 @@ doLedgerEntry(Context const& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
key =
|
||||
ripple::keylet::page(
|
||||
ripple::keylet::ownerDir(*ownerID), subIndex).key;
|
||||
key = ripple::keylet::page(
|
||||
ripple::keylet::ownerDir(*ownerID), subIndex)
|
||||
.key;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "missingOwnerOrDirRoot"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, "missingOwnerOrDirRoot"};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,13 +182,13 @@ doLedgerEntry(Context const& context)
|
||||
if (!key.parseHex(request.at("escrow").as_string().c_str()))
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedEscrow"};
|
||||
}
|
||||
else if (
|
||||
else if (
|
||||
!request.at("escrow").as_object().contains("owner") ||
|
||||
!request.at("escrow").as_object().at("owner").is_string())
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedOwner"};
|
||||
}
|
||||
else if(
|
||||
else if (
|
||||
!request.at("escrow").as_object().contains("seq") ||
|
||||
!request.at("escrow").as_object().at("seq").is_int64())
|
||||
{
|
||||
@@ -190,14 +196,18 @@ doLedgerEntry(Context const& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const id = ripple::parseBase58<ripple::AccountID>(
|
||||
request.at("escrow").as_object().at("owner").as_string().c_str());
|
||||
auto const id =
|
||||
ripple::parseBase58<ripple::AccountID>(request.at("escrow")
|
||||
.as_object()
|
||||
.at("owner")
|
||||
.as_string()
|
||||
.c_str());
|
||||
|
||||
if (!id)
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedOwner"};
|
||||
else
|
||||
{
|
||||
std::uint32_t seq =
|
||||
std::uint32_t seq =
|
||||
request.at("escrow").as_object().at("seq").as_int64();
|
||||
key = ripple::keylet::escrow(*id, seq).key;
|
||||
}
|
||||
@@ -251,18 +261,15 @@ doLedgerEntry(Context const& context)
|
||||
return Status{Error::rpcINVALID_PARAMS, "rippleStateNotObject"};
|
||||
|
||||
ripple::Currency currency;
|
||||
boost::json::object const& state = request.at("ripple_state").as_object();
|
||||
boost::json::object const& state =
|
||||
request.at("ripple_state").as_object();
|
||||
|
||||
if (
|
||||
!state.contains("currency") ||
|
||||
!state.at("currency").is_string())
|
||||
if (!state.contains("currency") || !state.at("currency").is_string())
|
||||
{
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedCurrency"};
|
||||
}
|
||||
|
||||
if (
|
||||
!state.contains("accounts") ||
|
||||
!state.at("accounts").is_array() ||
|
||||
if (!state.contains("accounts") || !state.at("accounts").is_array() ||
|
||||
2 != state.at("accounts").as_array().size() ||
|
||||
!state.at("accounts").as_array().at(0).is_string() ||
|
||||
!state.at("accounts").as_array().at(1).is_string() ||
|
||||
@@ -281,11 +288,10 @@ doLedgerEntry(Context const& context)
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedAccounts"};
|
||||
|
||||
else if (!ripple::to_currency(
|
||||
currency, state.at("currency").as_string().c_str()))
|
||||
currency, state.at("currency").as_string().c_str()))
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedCurrency"};
|
||||
|
||||
key = ripple::keylet::line(*id1, *id2, currency).key;
|
||||
|
||||
}
|
||||
else if (request.contains("ticket"))
|
||||
{
|
||||
@@ -296,7 +302,6 @@ doLedgerEntry(Context const& context)
|
||||
|
||||
if (!key.parseHex(request.at("ticket").as_string().c_str()))
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedTicket"};
|
||||
|
||||
}
|
||||
else if (
|
||||
!request.at("ticket").as_object().contains("account") ||
|
||||
@@ -312,14 +317,19 @@ doLedgerEntry(Context const& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const id = ripple::parseBase58<ripple::AccountID>(
|
||||
request.at("ticket").as_object().at("account").as_string().c_str());
|
||||
auto const id =
|
||||
ripple::parseBase58<ripple::AccountID>(request.at("ticket")
|
||||
.as_object()
|
||||
.at("account")
|
||||
.as_string()
|
||||
.c_str());
|
||||
|
||||
if (!id)
|
||||
return Status{Error::rpcINVALID_PARAMS, "malformedTicketAccount"};
|
||||
return Status{
|
||||
Error::rpcINVALID_PARAMS, "malformedTicketAccount"};
|
||||
else
|
||||
{
|
||||
std::uint32_t seq =
|
||||
std::uint32_t seq =
|
||||
request.at("offer").as_object().at("ticket_seq").as_int64();
|
||||
|
||||
key = ripple::getTicketIndex(*id, seq);
|
||||
@@ -340,7 +350,7 @@ doLedgerEntry(Context const& context)
|
||||
|
||||
if (!dbResponse or dbResponse->size() == 0)
|
||||
return Status{Error::rpcLGR_NOT_FOUND};
|
||||
|
||||
|
||||
response["index"] = ripple::strHex(key);
|
||||
response["ledger_hash"] = ripple::strHex(lgrInfo.hash);
|
||||
response["ledger_index"] = lgrInfo.seq;
|
||||
@@ -359,4 +369,4 @@ doLedgerEntry(Context const& context)
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace RPC
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
|
||||
namespace RPC {
|
||||
|
||||
namespace RPC
|
||||
{
|
||||
|
||||
Result
|
||||
doLedgerRange(Context const& context)
|
||||
{
|
||||
@@ -24,4 +23,4 @@ doLedgerRange(Context const& context)
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace RPC
|
||||
@@ -23,15 +23,15 @@ doServerInfo(Context const& context)
|
||||
response["info"] = boost::json::object{};
|
||||
boost::json::object& info = response["info"].as_object();
|
||||
|
||||
info["complete_ledgers"] =
|
||||
std::to_string(range->minSequence) + "-" +
|
||||
info["complete_ledgers"] = std::to_string(range->minSequence) + "-" +
|
||||
std::to_string(range->maxSequence);
|
||||
|
||||
info["counters"] = boost::json::object{};
|
||||
info["counters"].as_object()["rpc"] = context.counters.report();
|
||||
}
|
||||
|
||||
auto serverInfoRippled = context.balancer->forwardToRippled(context.params, context.clientIp);
|
||||
auto serverInfoRippled =
|
||||
context.balancer->forwardToRippled(context.params, context.clientIp);
|
||||
if (serverInfoRippled && !serverInfoRippled->contains("error"))
|
||||
response["info"].as_object()["load_factor"] = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user