rippled
Loading...
Searching...
No Matches
LedgerRequest.cpp
1#include <xrpld/app/ledger/LedgerToJson.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
4
5#include <xrpl/protocol/ErrorCodes.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/resource/Fees.h>
8
9namespace xrpl {
10
11// {
12// ledger_hash : <ledger>
13// ledger_index : <ledger_index>
14// }
17{
19 auto res = RPC::getOrAcquireLedger(context);
20
21 if (!res.has_value())
22 return res.error();
23
24 auto const& ledger = res.value();
25
26 Json::Value jvResult;
27 jvResult[jss::ledger_index] = ledger->header().seq;
28 addJson(jvResult, {*ledger, &context, 0});
29 return jvResult;
30}
31
32} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
Expected< std::shared_ptr< Ledger const >, Json::Value > getOrAcquireLedger(RPC::JsonContext const &context)
Retrieves or acquires a ledger based on the parameters provided in the given JsonContext.
Charge const feeHeavyBurdenRPC
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value doLedgerRequest(RPC::JsonContext &)
void addJson(Json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a Json::Value with a description of the ledger.
Resource::Charge & loadType
Definition Context.h:23