mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-05 16:58:00 +00:00
merge master
This commit is contained in:
@@ -73,8 +73,12 @@ doAccountInfo(
|
||||
|
||||
if (!accountID)
|
||||
{
|
||||
response["error"] = "couldnt decode account";
|
||||
return response;
|
||||
accountID = ripple::AccountID();
|
||||
if (!accountID->parseHex(request.at("account").as_string().c_str()))
|
||||
{
|
||||
response["error"] = "account malformed";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
auto key = ripple::keylet::account(accountID.value());
|
||||
|
||||
|
||||
@@ -137,12 +137,16 @@ doAccountTx(boost::json::object const& request, BackendInterface const& backend)
|
||||
return response;
|
||||
}
|
||||
|
||||
auto const account = ripple::parseBase58<ripple::AccountID>(
|
||||
auto account = ripple::parseBase58<ripple::AccountID>(
|
||||
request.at("account").as_string().c_str());
|
||||
if (!account)
|
||||
{
|
||||
response["error"] = "account malformed";
|
||||
return response;
|
||||
account = ripple::AccountID();
|
||||
if (!account->parseHex(request.at("account").as_string().c_str()))
|
||||
{
|
||||
response["error"] = "account malformed";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
auto ledgerSequence = ledgerSequenceFromRequest(request, backend);
|
||||
if (!ledgerSequence)
|
||||
@@ -182,8 +186,11 @@ doAccountTx(boost::json::object const& request, BackendInterface const& backend)
|
||||
request.at("limit").kind() == boost::json::kind::int64)
|
||||
limit = request.at("limit").as_int64();
|
||||
boost::json::array txns;
|
||||
auto start = std::chrono::system_clock::now();
|
||||
auto [blobs, retCursor] =
|
||||
backend.fetchAccountTransactions(*account, limit, cursor);
|
||||
auto end = std::chrono::system_clock::now();
|
||||
BOOST_LOG_TRIVIAL(info) << __func__ << " db fetch took " << ((end - start).count() / 1000000000.0) << " num blobs = " << blobs.size();
|
||||
for (auto const& txnPlusMeta : blobs)
|
||||
{
|
||||
if (txnPlusMeta.ledgerSequence > ledgerSequence)
|
||||
@@ -216,6 +223,8 @@ doAccountTx(boost::json::object const& request, BackendInterface const& backend)
|
||||
cursorJson["transaction_index"] = retCursor->transactionIndex;
|
||||
response["cursor"] = cursorJson;
|
||||
}
|
||||
auto end2 = std::chrono::system_clock::now();
|
||||
BOOST_LOG_TRIVIAL(info) << __func__ << " serialization took " << ((end2 - end).count() / 1000000000.0);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,196 +57,214 @@ doBookOffers(
|
||||
response["error"] = "Empty database";
|
||||
return response;
|
||||
}
|
||||
if (!request.contains("taker_pays"))
|
||||
ripple::uint256 bookBase;
|
||||
if (request.contains("book"))
|
||||
{
|
||||
response["error"] = "Missing field taker_pays";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!request.contains("taker_gets"))
|
||||
{
|
||||
response["error"] = "Missing field taker_gets";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::json::object taker_pays;
|
||||
if (request.at("taker_pays").kind() == boost::json::kind::object)
|
||||
{
|
||||
taker_pays = request.at("taker_pays").as_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
response["error"] = "Invalid field taker_pays";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::json::object taker_gets;
|
||||
if (request.at("taker_gets").kind() == boost::json::kind::object)
|
||||
{
|
||||
taker_gets = request.at("taker_gets").as_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
response["error"] = "Invalid field taker_gets";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_pays.contains("currency"))
|
||||
{
|
||||
response["error"] = "Missing field taker_pays.currency";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_pays.at("currency").is_string())
|
||||
{
|
||||
response["error"] = "taker_pays.currency should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_gets.contains("currency"))
|
||||
{
|
||||
response["error"] = "Missing field taker_gets.currency";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_gets.at("currency").is_string())
|
||||
{
|
||||
response["error"] = "taker_gets.currency should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::Currency pay_currency;
|
||||
|
||||
if (!ripple::to_currency(
|
||||
pay_currency, taker_pays.at("currency").as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.currency', bad currency.";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::Currency get_currency;
|
||||
|
||||
if (!ripple::to_currency(
|
||||
get_currency, taker_gets["currency"].as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.currency', bad currency.";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::AccountID pay_issuer;
|
||||
|
||||
if (taker_pays.contains("issuer"))
|
||||
{
|
||||
if (!taker_pays.at("issuer").is_string())
|
||||
if (!bookBase.parseHex(request.at("book").as_string().c_str()))
|
||||
{
|
||||
response["error"] = "taker_pays.issuer should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!ripple::to_issuer(
|
||||
pay_issuer, taker_pays.at("issuer").as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', bad issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (pay_issuer == ripple::noAccount())
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', bad issuer account one.";
|
||||
response["error"] = "Error parsing book";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pay_issuer = ripple::xrpAccount();
|
||||
}
|
||||
|
||||
if (isXRP(pay_currency) && !isXRP(pay_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Unneeded field 'taker_pays.issuer' for XRP currency "
|
||||
"specification.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!isXRP(pay_currency) && isXRP(pay_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', expected non-XRP issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::AccountID get_issuer;
|
||||
|
||||
if (taker_gets.contains("issuer"))
|
||||
{
|
||||
if (!taker_gets["issuer"].is_string())
|
||||
if (!request.contains("taker_pays"))
|
||||
{
|
||||
response["error"] = "taker_gets.issuer should be string";
|
||||
response["error"] = "Missing field taker_pays";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!ripple::to_issuer(
|
||||
get_issuer, taker_gets.at("issuer").as_string().c_str()))
|
||||
if (!request.contains("taker_gets"))
|
||||
{
|
||||
response["error"] = "Missing field taker_gets";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::json::object taker_pays;
|
||||
if (request.at("taker_pays").kind() == boost::json::kind::object)
|
||||
{
|
||||
taker_pays = request.at("taker_pays").as_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
response["error"] = "Invalid field taker_pays";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::json::object taker_gets;
|
||||
if (request.at("taker_gets").kind() == boost::json::kind::object)
|
||||
{
|
||||
taker_gets = request.at("taker_gets").as_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
response["error"] = "Invalid field taker_gets";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_pays.contains("currency"))
|
||||
{
|
||||
response["error"] = "Missing field taker_pays.currency";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_pays.at("currency").is_string())
|
||||
{
|
||||
response["error"] = "taker_pays.currency should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_gets.contains("currency"))
|
||||
{
|
||||
response["error"] = "Missing field taker_gets.currency";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!taker_gets.at("currency").is_string())
|
||||
{
|
||||
response["error"] = "taker_gets.currency should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::Currency pay_currency;
|
||||
|
||||
if (!ripple::to_currency(
|
||||
pay_currency, taker_pays.at("currency").as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', bad issuer.";
|
||||
"Invalid field 'taker_pays.currency', bad currency.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (get_issuer == ripple::noAccount())
|
||||
ripple::Currency get_currency;
|
||||
|
||||
if (!ripple::to_currency(
|
||||
get_currency, taker_gets["currency"].as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', bad issuer account one.";
|
||||
"Invalid field 'taker_gets.currency', bad currency.";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
get_issuer = ripple::xrpAccount();
|
||||
}
|
||||
|
||||
if (ripple::isXRP(get_currency) && !ripple::isXRP(get_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Unneeded field 'taker_gets.issuer' for XRP currency "
|
||||
"specification.";
|
||||
return response;
|
||||
}
|
||||
ripple::AccountID pay_issuer;
|
||||
|
||||
if (!ripple::isXRP(get_currency) && ripple::isXRP(get_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', expected non-XRP issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::optional<ripple::AccountID> takerID;
|
||||
if (request.contains("taker"))
|
||||
{
|
||||
if (!request.at("taker").is_string())
|
||||
if (taker_pays.contains("issuer"))
|
||||
{
|
||||
response["error"] = "taker should be string";
|
||||
return response;
|
||||
}
|
||||
if (!taker_pays.at("issuer").is_string())
|
||||
{
|
||||
response["error"] = "taker_pays.issuer should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
takerID = ripple::parseBase58<ripple::AccountID>(
|
||||
request.at("taker").as_string().c_str());
|
||||
if (!takerID)
|
||||
if (!ripple::to_issuer(
|
||||
pay_issuer, taker_pays.at("issuer").as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', bad issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (pay_issuer == ripple::noAccount())
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', bad issuer account "
|
||||
"one.";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response["error"] = "Invalid taker";
|
||||
pay_issuer = ripple::xrpAccount();
|
||||
}
|
||||
|
||||
if (isXRP(pay_currency) && !isXRP(pay_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Unneeded field 'taker_pays.issuer' for XRP currency "
|
||||
"specification.";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
if (pay_currency == get_currency && pay_issuer == get_issuer)
|
||||
{
|
||||
response["error"] = "Bad market";
|
||||
return response;
|
||||
if (!isXRP(pay_currency) && isXRP(pay_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_pays.issuer', expected non-XRP issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
ripple::AccountID get_issuer;
|
||||
|
||||
if (taker_gets.contains("issuer"))
|
||||
{
|
||||
if (!taker_gets["issuer"].is_string())
|
||||
{
|
||||
response["error"] = "taker_gets.issuer should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!ripple::to_issuer(
|
||||
get_issuer, taker_gets.at("issuer").as_string().c_str()))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', bad issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (get_issuer == ripple::noAccount())
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', bad issuer account "
|
||||
"one.";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
get_issuer = ripple::xrpAccount();
|
||||
}
|
||||
|
||||
if (ripple::isXRP(get_currency) && !ripple::isXRP(get_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Unneeded field 'taker_gets.issuer' for XRP currency "
|
||||
"specification.";
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!ripple::isXRP(get_currency) && ripple::isXRP(get_issuer))
|
||||
{
|
||||
response["error"] =
|
||||
"Invalid field 'taker_gets.issuer', expected non-XRP issuer.";
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::optional<ripple::AccountID> takerID;
|
||||
if (request.contains("taker"))
|
||||
{
|
||||
if (!request.at("taker").is_string())
|
||||
{
|
||||
response["error"] = "taker should be string";
|
||||
return response;
|
||||
}
|
||||
|
||||
takerID = ripple::parseBase58<ripple::AccountID>(
|
||||
request.at("taker").as_string().c_str());
|
||||
if (!takerID)
|
||||
{
|
||||
response["error"] = "Invalid taker";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
if (pay_currency == get_currency && pay_issuer == get_issuer)
|
||||
{
|
||||
response["error"] = "Bad market";
|
||||
return response;
|
||||
}
|
||||
ripple::Book book = {
|
||||
{pay_currency, pay_issuer}, {get_currency, get_issuer}};
|
||||
|
||||
bookBase = getBookBase(book);
|
||||
}
|
||||
|
||||
std::uint32_t limit = 200;
|
||||
@@ -261,10 +279,6 @@ doBookOffers(
|
||||
cursor->parseHex(request.at("cursor").as_string().c_str());
|
||||
}
|
||||
|
||||
ripple::Book book = {
|
||||
{pay_currency, pay_issuer}, {get_currency, get_issuer}};
|
||||
|
||||
ripple::uint256 bookBase = getBookBase(book);
|
||||
auto start = std::chrono::system_clock::now();
|
||||
std::cout << "getting Book Offers" << std::endl;
|
||||
auto [offers, retCursor] =
|
||||
|
||||
Reference in New Issue
Block a user