rippled
Loading...
Searching...
No Matches
xrpld
app
ledger
LedgerToJson.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 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
#ifndef RIPPLE_APP_LEDGER_LEDGERTOJSON_H_INCLUDED
21
#define RIPPLE_APP_LEDGER_LEDGERTOJSON_H_INCLUDED
22
23
#include <xrpld/app/ledger/Ledger.h>
24
#include <xrpld/app/ledger/LedgerMaster.h>
25
#include <xrpld/app/misc/TxQ.h>
26
#include <xrpld/rpc/Context.h>
27
28
#include <xrpl/basics/chrono.h>
29
#include <xrpl/json/Object.h>
30
#include <xrpl/protocol/serialize.h>
31
32
namespace
ripple
{
33
34
struct
LedgerFill
35
{
36
LedgerFill
(
37
ReadView
const
& l,
38
RPC::Context
* ctx,
39
int
o = 0,
40
std::vector<TxQ::TxDetails>
q = {},
41
LedgerEntryType
t =
ltANY
)
42
:
ledger
(l),
options
(o),
txQueue
(std::move(q)),
type
(t),
context
(ctx)
43
{
44
if
(
context
)
45
closeTime
=
context
->
ledgerMaster
.
getCloseTimeBySeq
(
ledger
.
seq
());
46
}
47
48
enum
Options
{
49
dumpTxrp
= 1,
50
dumpState
= 2,
51
expand
= 4,
52
full
= 8,
53
binary
= 16,
54
ownerFunds
= 32,
55
dumpQueue
= 64
56
};
57
58
ReadView
const
&
ledger
;
59
int
options
;
60
std::vector<TxQ::TxDetails>
txQueue
;
61
LedgerEntryType
type
;
62
RPC::Context
*
context
;
63
std::optional<NetClock::time_point>
closeTime
;
64
};
65
70
void
71
addJson
(
Json::Value
&,
LedgerFill
const
&);
72
74
Json::Value
75
getJson
(
LedgerFill
const
&);
76
77
}
// namespace ripple
78
79
#endif
Json::Value
Represents a JSON value.
Definition:
json_value.h:148
ripple::LedgerMaster::getCloseTimeBySeq
std::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
Definition:
LedgerMaster.cpp:1598
ripple::ReadView
A view into a ledger.
Definition:
ReadView.h:52
ripple::ReadView::seq
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Definition:
ReadView.h:119
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
algorithm.h:26
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:350
ripple::LedgerEntryType
LedgerEntryType
Identifiers for on-ledger objects.
Definition:
LedgerFormats.h:54
ripple::ltANY
@ ltANY
A special type, matching any ledger entry type.
Definition:
LedgerFormats.h:78
ripple::getJson
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Definition:
LedgerToJson.cpp:360
std::optional
ripple::LedgerFill
Definition:
LedgerToJson.h:35
ripple::LedgerFill::ledger
ReadView const & ledger
Definition:
LedgerToJson.h:58
ripple::LedgerFill::type
LedgerEntryType type
Definition:
LedgerToJson.h:61
ripple::LedgerFill::LedgerFill
LedgerFill(ReadView const &l, RPC::Context *ctx, int o=0, std::vector< TxQ::TxDetails > q={}, LedgerEntryType t=ltANY)
Definition:
LedgerToJson.h:36
ripple::LedgerFill::txQueue
std::vector< TxQ::TxDetails > txQueue
Definition:
LedgerToJson.h:60
ripple::LedgerFill::options
int options
Definition:
LedgerToJson.h:59
ripple::LedgerFill::Options
Options
Definition:
LedgerToJson.h:48
ripple::LedgerFill::full
@ full
Definition:
LedgerToJson.h:52
ripple::LedgerFill::dumpState
@ dumpState
Definition:
LedgerToJson.h:50
ripple::LedgerFill::binary
@ binary
Definition:
LedgerToJson.h:53
ripple::LedgerFill::ownerFunds
@ ownerFunds
Definition:
LedgerToJson.h:54
ripple::LedgerFill::expand
@ expand
Definition:
LedgerToJson.h:51
ripple::LedgerFill::dumpQueue
@ dumpQueue
Definition:
LedgerToJson.h:55
ripple::LedgerFill::dumpTxrp
@ dumpTxrp
Definition:
LedgerToJson.h:49
ripple::LedgerFill::context
RPC::Context * context
Definition:
LedgerToJson.h:62
ripple::LedgerFill::closeTime
std::optional< NetClock::time_point > closeTime
Definition:
LedgerToJson.h:63
ripple::RPC::Context
The context of information needed to call an RPC.
Definition:
Context.h:39
ripple::RPC::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition:
Context.h:44
std::vector
Generated by
1.9.5