mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-25 08:00:18 +00:00
* Implement logging abstraction (#371) Fixes #290 * Fix pre-commit to only check staged files * Implement account ownership check and fix paging (#383) Fixes #222 * Remove the github action package signing step This will be done elsewhere. * include searched_all in error response of tx (#407) * helper function for subscribe to ensure cleanup (#402) * Add closed to header for all paths of ledger_data (#416) Fixes #219 * Add custom error for malformed owner and request (#417) Fixes #274 * Use custom malformedAddress error in ledger_entry (#419) Fixes #272 * Return lgrIdxsInvalid error for ledger_max_index less than ledger_min_index (#339) Fixes #263 * Update headers to use #pragma once * Add custom error for malformed request (#414) Fixes #276 * Return srcCurMalformed on invalid taker_pays in book_offers (#413) Fixes #267 * Fix source_location issue on MacOSX and Debug build (#431) Fixes #428 * Implement always adding git ref to version string (#430) Fixes #427 * add connection counting (#433) * Fix malformed output format over ws rpc (#426) Fixes #405 * Remove branch name from version string (#437) Fixes a bug from #430 * Implement cli parsing using boost::po (#436) Fixes #367 * Update documentation and config with ssl_cert_file and ssl_key_file (#443) Fixes #424 * Fix gateway balances to match rippled output (#441) Fixes #271 * Update README and example config to describe start_sequence (#438) Fixes #250 * Add copyright to top of each source file (#444) Fixes #411 * Increase file descriptor limit (#449) * Update readme with more log configurations (#447) Fixes #446 * Document dos_guard in example config. Log when client surpasses rate limit (#451) * Add unit tests for DOSGuard (#453) Fixes #452 * Build macOS and Ubuntu 22.04 (#456) build release/x.y.z branches * Add time measurement profiler (#458) Rebase * Match format to rippled error code (#461) Fixes #263 * Change error message to match rippled (#463) Fixes #263 * Add requests limit to DosGuard (#462) Fixing #448 * Set version to 1.0.4-rc2 Co-authored-by: Alex Kremer <akremer@ripple.com> Co-authored-by: CJ Cobb <46455409+cjcobb23@users.noreply.github.com> Co-authored-by: Francis Mendoza <francissamuelmendoza7@gmail.com> Co-authored-by: cyan317 <120398799+cindyyan317@users.noreply.github.com>
122 lines
4.2 KiB
C++
122 lines
4.2 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of clio: https://github.com/XRPLF/clio
|
|
Copyright (c) 2022, the clio developers.
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#include <backend/BackendInterface.h>
|
|
#include <etl/ETLSource.h>
|
|
#include <etl/ReportingETL.h>
|
|
#include <main/Build.h>
|
|
#include <rpc/RPCHelpers.h>
|
|
|
|
namespace RPC {
|
|
|
|
Result
|
|
doServerInfo(Context const& context)
|
|
{
|
|
boost::json::object response = {};
|
|
|
|
auto range = context.backend->fetchLedgerRange();
|
|
if (!range)
|
|
{
|
|
return Status{
|
|
RippledError::rpcNOT_READY,
|
|
"emptyDatabase",
|
|
"The server has no data in the database"};
|
|
}
|
|
|
|
auto lgrInfo = context.backend->fetchLedgerBySequence(
|
|
range->maxSequence, context.yield);
|
|
|
|
auto fees = context.backend->fetchFees(lgrInfo->seq, context.yield);
|
|
|
|
if (!lgrInfo || !fees)
|
|
return Status{RippledError::rpcINTERNAL};
|
|
|
|
auto age = std::chrono::duration_cast<std::chrono::seconds>(
|
|
std::chrono::system_clock::now().time_since_epoch())
|
|
.count() -
|
|
lgrInfo->closeTime.time_since_epoch().count() - 946684800;
|
|
|
|
if (age < 0)
|
|
age = 0;
|
|
|
|
response[JS(info)] = boost::json::object{};
|
|
boost::json::object& info = response[JS(info)].as_object();
|
|
|
|
info[JS(complete_ledgers)] = std::to_string(range->minSequence) + "-" +
|
|
std::to_string(range->maxSequence);
|
|
|
|
bool admin = context.clientIp == "127.0.0.1";
|
|
|
|
if (admin)
|
|
{
|
|
info[JS(counters)] = context.counters.report();
|
|
info[JS(counters)].as_object()["subscriptions"] =
|
|
context.subscriptions->report();
|
|
}
|
|
|
|
auto serverInfoRippled = context.balancer->forwardToRippled(
|
|
{{"command", "server_info"}}, context.clientIp, context.yield);
|
|
|
|
info[JS(load_factor)] = 1;
|
|
info["clio_version"] = Build::getClioVersionString();
|
|
if (serverInfoRippled && !serverInfoRippled->contains(JS(error)))
|
|
{
|
|
try
|
|
{
|
|
auto& rippledResult = serverInfoRippled->at(JS(result)).as_object();
|
|
auto& rippledInfo = rippledResult.at(JS(info)).as_object();
|
|
info[JS(load_factor)] = rippledInfo[JS(load_factor)];
|
|
info[JS(validation_quorum)] = rippledInfo[JS(validation_quorum)];
|
|
info["rippled_version"] = rippledInfo[JS(build_version)];
|
|
}
|
|
catch (std::exception const&)
|
|
{
|
|
}
|
|
}
|
|
|
|
info[JS(validated_ledger)] = boost::json::object{};
|
|
boost::json::object& validated = info[JS(validated_ledger)].as_object();
|
|
|
|
validated[JS(age)] = age;
|
|
validated[JS(hash)] = ripple::strHex(lgrInfo->hash);
|
|
validated[JS(seq)] = lgrInfo->seq;
|
|
validated[JS(base_fee_xrp)] = fees->base.decimalXRP();
|
|
validated[JS(reserve_base_xrp)] = fees->reserve.decimalXRP();
|
|
validated[JS(reserve_inc_xrp)] = fees->increment.decimalXRP();
|
|
|
|
info["cache"] = boost::json::object{};
|
|
auto& cache = info["cache"].as_object();
|
|
|
|
cache["size"] = context.backend->cache().size();
|
|
cache["is_full"] = context.backend->cache().isFull();
|
|
cache["latest_ledger_seq"] =
|
|
context.backend->cache().latestLedgerSequence();
|
|
cache["object_hit_rate"] = context.backend->cache().getObjectHitRate();
|
|
cache["successor_hit_rate"] =
|
|
context.backend->cache().getSuccessorHitRate();
|
|
|
|
if (admin)
|
|
{
|
|
info["etl"] = context.etl->getInfo();
|
|
}
|
|
|
|
return response;
|
|
}
|
|
} // namespace RPC
|