Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Models.hpp
1
#pragma once
2
3
#include "util/Concepts.hpp"
4
5
#include <boost/json/object.hpp>
6
#include <fmt/format.h>
7
#include <xrpl/basics/Blob.h>
8
#include <xrpl/basics/base_uint.h>
9
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
10
#include <xrpl/proto/org/xrpl/rpc/v1/ledger.pb.h>
11
#include <xrpl/protocol/LedgerHeader.h>
12
#include <xrpl/protocol/STTx.h>
13
#include <xrpl/protocol/Serializer.h>
14
#include <xrpl/protocol/TxFormats.h>
15
#include <xrpl/protocol/TxMeta.h>
16
17
#include <cstdint>
18
#include <optional>
19
#include <string>
20
#include <vector>
21
22
namespace
etl::model {
23
31
template
<xrpl::TxType... Types>
32
requires
(
util::hasNoDuplicates
(Types...))
// NOLINT(readability-redundant-parentheses)
33
struct
Spec
{
34
static
constexpr
bool
kSpecTag =
true
;
35
42
[[nodiscard]]
static
constexpr
bool
43
wants
(xrpl::TxType type)
noexcept
44
{
45
return
((Types == type) || ...);
46
}
47
};
48
52
struct
Transaction
{
53
std::string raw;
// raw binary blob
54
std::string metaRaw;
55
56
// unpacked blob and meta
57
xrpl::STTx sttx;
58
xrpl::TxMeta meta;
59
60
// commonly used stuff
61
xrpl::uint256 id;
62
std::string key;
// key is the above id as a string of 32 characters
63
xrpl::TxType type;
64
70
bool
71
operator==
(
Transaction
const
& other)
const
72
{
73
return
raw == other.raw
//
74
and metaRaw == other.metaRaw
//
75
and sttx.getTransactionID() == other.sttx.getTransactionID()
//
76
and meta.getTxID() == other.meta.getTxID()
//
77
and
id
== other.id
//
78
and key == other.key
//
79
and type == other.type;
80
}
81
};
82
86
struct
Object
{
90
enum class
ModType
:
int
{
91
Unspecified = 0,
92
Created = 1,
93
Modified = 2,
94
Deleted = 3,
95
};
96
97
xrpl::uint256 key;
98
std::string keyRaw;
99
xrpl::Blob
data
;
100
std::string dataRaw;
101
std::string successor;
102
std::string predecessor;
103
104
ModType
type;
105
106
bool
107
operator==(
Object
const
&)
const
=
default
;
108
};
109
113
struct
BookSuccessor
{
114
std::string firstBook;
115
std::string bookBase;
116
117
bool
118
operator==(
BookSuccessor
const
&)
const
=
default
;
119
};
120
124
struct
LedgerData
{
125
std::vector<Transaction> transactions;
126
std::vector<Object> objects;
127
std::optional<std::vector<BookSuccessor>> successors;
128
std::optional<std::vector<std::string>> edgeKeys;
129
130
xrpl::LedgerHeader header;
131
std::string rawHeader;
132
uint32_t seq;
133
139
bool
140
operator==
(
LedgerData
const
& other)
const
141
{
142
auto
const
serialized = [](
auto
const
& hdr) {
143
xrpl::Serializer ser;
144
xrpl::addRaw(hdr, ser);
145
return
ser.getString();
146
};
147
148
return
transactions == other.transactions
//
149
and objects == other.objects
//
150
and successors == other.successors
//
151
and edgeKeys == other.edgeKeys
//
152
and serialized(header) == serialized(other.header)
//
153
and rawHeader == other.rawHeader
//
154
and seq == other.seq;
155
}
156
};
157
161
struct
Task
{
165
enum class
Priority
: uint8_t {
166
Lower = 0u,
167
Higher = 1u,
168
};
169
170
Priority
priority;
171
uint32_t seq;
172
};
173
174
}
// namespace etl::model
data
This namespace implements the data access layer and related components.
Definition
AmendmentCenter.cpp:56
util::hasNoDuplicates
static consteval auto hasNoDuplicates(auto &&... values)
Checks that the list of given values contains no duplicates.
Definition
Concepts.hpp:34
etl::model::BookSuccessor
Represents a book successor.
Definition
Models.hpp:113
etl::model::LedgerData
Represents an entire ledger diff worth of transactions and objects.
Definition
Models.hpp:124
etl::model::LedgerData::operator==
bool operator==(LedgerData const &other) const
Compares LedgerData objects to each other without considering the header field.
Definition
Models.hpp:140
etl::model::Object
Represents a single object on the ledger.
Definition
Models.hpp:86
etl::model::Object::ModType
ModType
Modification type for the object.
Definition
Models.hpp:90
etl::model::Spec
A specification for the Registry.
Definition
Models.hpp:33
etl::model::Spec::wants
static constexpr bool wants(xrpl::TxType type) noexcept
Checks if the transaction type was requested.
Definition
Models.hpp:43
etl::model::Task
Represents a task for the extractors.
Definition
Models.hpp:161
etl::model::Task::Priority
Priority
Represents the priority of the task.
Definition
Models.hpp:165
etl::model::Transaction
Represents a single transaction on the ledger.
Definition
Models.hpp:52
etl::model::Transaction::operator==
bool operator==(Transaction const &other) const
Compares Transaction objects to each other without considering sttx and meta fields.
Definition
Models.hpp:71
src
etl
Models.hpp
Generated by
1.17.0