rippled
Loading...
Searching...
No Matches
xrpld
rpc
handlers
LedgerRequest.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012-2014 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#include <xrpld/app/ledger/LedgerToJson.h>
21
#include <xrpld/rpc/Context.h>
22
#include <xrpld/rpc/detail/RPCHelpers.h>
23
24
#include <xrpl/protocol/ErrorCodes.h>
25
#include <xrpl/protocol/jss.h>
26
27
#include <
variant
>
28
29
namespace
ripple
{
30
31
// {
32
// ledger_hash : <ledger>
33
// ledger_index : <ledger_index>
34
// }
35
Json::Value
36
doLedgerRequest
(
RPC::JsonContext
& context)
37
{
38
auto
res = getLedgerByContext(context);
39
40
if
(
std::holds_alternative<Json::Value>
(res))
41
return
std::get<Json::Value>
(res);
42
43
auto
const
& ledger =
std::get<std::shared_ptr<Ledger const>
>(res);
44
45
Json::Value
jvResult;
46
jvResult[jss::ledger_index] = ledger->info().seq;
47
addJson
(jvResult, {*ledger, &context, 0});
48
return
jvResult;
49
}
50
51
}
// namespace ripple
Json::Value
Represents a JSON value.
Definition
json_value.h:149
std::is_same_v
T is_same_v
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:25
ripple::doLedgerRequest
Json::Value doLedgerRequest(RPC::JsonContext &)
Definition
LedgerRequest.cpp:36
ripple::addJson
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.
Definition
LedgerToJson.cpp:347
ripple::RPC::JsonContext
Definition
Context.h:53
variant
Generated by
1.9.8