rippled
Loading...
Searching...
No Matches
xrpld/rpc/handlers/LedgerHeader.cpp
1#include <xrpld/app/ledger/LedgerToJson.h>
2#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
3
4#include <xrpl/basics/strHex.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/jss.h>
7
8namespace ripple {
9
10// {
11// ledger_hash : <ledger>
12// ledger_index : <ledger_index>
13// }
16{
18 auto jvResult = RPC::lookupLedger(lpLedger, context);
19
20 if (!lpLedger)
21 return jvResult;
22
23 Serializer s;
24 addRaw(lpLedger->info(), s);
25 jvResult[jss::ledger_data] = strHex(s.peekData());
26
27 // This information isn't verified: they should only use it if they trust
28 // us.
29 addJson(jvResult, {*lpLedger, &context, 0});
30
31 return jvResult;
32}
33
34} // namespace ripple
Represents a JSON value.
Definition json_value.h:131
Blob const & peekData() const
Definition Serializer.h:183
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
void addJson(Json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a Json::Object or Json::Value with a description of the ledger.
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:11
Json::Value doLedgerHeader(RPC::JsonContext &)
void addRaw(LedgerHeader const &, Serializer &, bool includeHash=false)