xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
handlers
ledger
xrpld/rpc/handlers/ledger/LedgerHeader.cpp
1
#include <xrpl/protocol/LedgerHeader.h>
2
3
#include <xrpld/app/ledger/LedgerToJson.h>
4
#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
5
6
#include <xrpl/basics/strHex.h>
7
#include <xrpl/json/json_value.h>
8
#include <xrpl/ledger/ReadView.h>
9
#include <xrpl/protocol/Serializer.h>
10
#include <xrpl/protocol/jss.h>
11
12
#include <
memory
>
13
14
namespace
xrpl
{
15
16
// {
17
// ledger_hash : <ledger>
18
// ledger_index : <ledger_index>
19
// }
20
json::Value
21
doLedgerHeader
(
rpc::JsonContext
& context)
22
{
23
std::shared_ptr<ReadView const>
lpLedger;
24
auto
jvResult =
rpc::lookupLedger
(lpLedger, context);
25
26
if
(!lpLedger)
27
return
jvResult;
28
29
Serializer
s;
30
addRaw
(lpLedger->header(), s);
31
jvResult[jss::ledger_data] =
strHex
(s.
peekData
());
32
33
// This information isn't verified: they should only use it if they trust
34
// us.
35
addJson
(jvResult, {*lpLedger, &context, 0});
36
37
return
jvResult;
38
}
39
40
}
// namespace xrpl
xrpl::Serializer
Definition
Serializer.h:23
xrpl::Serializer::peekData
Blob const & peekData() const
Definition
Serializer.h:273
memory
xrpl::rpc::lookupLedger
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, json::Value &result)
Looks up a ledger from a request and fills a json::Value with ledger data.
Definition
RPCLedgerHelpers.cpp:390
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition
strHex.h:13
xrpl::addJson
void addJson(json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a json::Value with a description of the ledger.
Definition
LedgerToJson.cpp:356
xrpl::addRaw
void addRaw(LedgerHeader const &, Serializer &, bool includeHash=false)
Definition
libxrpl/protocol/LedgerHeader.cpp:14
xrpl::doLedgerHeader
json::Value doLedgerHeader(rpc::JsonContext &)
Definition
xrpld/rpc/handlers/ledger/LedgerHeader.cpp:21
std::shared_ptr
xrpl::rpc::JsonContext
Definition
Context.h:41
Generated by
1.17.0