Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Extraction.hpp
1
#pragma once
2
3
#include "etl/AmendmentBlockHandlerInterface.hpp"
4
#include "etl/ExtractorInterface.hpp"
5
#include "
etl/LedgerFetcherInterface.hpp
"
6
#include "etl/Models.hpp"
7
#include "etl/impl/LedgerFetcher.hpp"
8
#include "util/log/Logger.hpp"
9
10
#include <google/protobuf/repeated_ptr_field.h>
11
#include <sys/types.h>
12
#include <xrpl/basics/Slice.h>
13
#include <xrpl/basics/base_uint.h>
14
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
15
#include <xrpl/proto/org/xrpl/rpc/v1/ledger.pb.h>
16
#include <xrpl/protocol/LedgerHeader.h>
17
#include <xrpl/protocol/STTx.h>
18
#include <xrpl/protocol/Serializer.h>
19
#include <xrpl/protocol/TxMeta.h>
20
21
#include <cstddef>
22
#include <cstdint>
23
#include <memory>
24
#include <optional>
25
#include <string>
26
#include <utility>
27
#include <vector>
28
29
namespace
etl::impl {
30
31
using
PBObjType = org::xrpl::rpc::v1::RawLedgerObject;
32
using
PBModType = PBObjType::ModificationType;
33
using
PBTxType = org::xrpl::rpc::v1::TransactionAndMetadata;
34
using
PBTxListType = google::protobuf::RepeatedPtrField<PBTxType>;
35
using
PBObjListType = google::protobuf::RepeatedPtrField<PBObjType>;
36
using
PBBookSuccessorType = org::xrpl::rpc::v1::BookSuccessor;
37
using
PBLedgerResponseType = org::xrpl::rpc::v1::GetLedgerResponse;
38
39
[[nodiscard]]
model::Object::ModType
40
extractModType(PBModType type);
41
42
[[nodiscard]] model::Transaction
43
extractTx(PBTxType tx, uint32_t seq);
44
45
[[nodiscard]] std::vector<model::Transaction>
46
extractTxs(PBTxListType transactions, uint32_t seq);
47
48
[[nodiscard]] model::Object
49
extractObj(PBObjType obj);
50
51
[[nodiscard]] std::vector<model::Object>
52
extractObjs(PBObjListType objects);
53
54
[[nodiscard]] model::BookSuccessor
55
extractSuccessor(PBBookSuccessorType successor);
56
57
[[nodiscard]] std::optional<std::vector<model::BookSuccessor>>
58
maybeExtractSuccessors(PBLedgerResponseType
const
& data);
59
60
// fetches the data in gRPC and transforms to local representation
61
class
Extractor :
public
ExtractorInterface
{
62
std::shared_ptr<LedgerFetcherInterface> fetcher_;
63
std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler_;
64
65
util::Logger
log_{
"ETL"
};
66
67
private
:
68
[[nodiscard]]
static
auto
69
unpack();
70
71
[[nodiscard]] std::optional<model::LedgerData>
72
guardedUnpack(std::optional<PBLedgerResponseType>&& response, uint32_t seq);
73
74
public
:
75
Extractor(
76
std::shared_ptr<LedgerFetcherInterface> fetcher,
77
std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler
78
)
79
: fetcher_(std::move(fetcher)), amendmentBlockHandler_(std::move(amendmentBlockHandler))
80
{
81
}
82
83
Extractor(Extractor
const
&) =
delete
;
84
Extractor(Extractor&&) =
delete
;
85
Extractor&
86
operator=(Extractor
const
&) =
delete
;
87
Extractor&
88
operator=(Extractor&&) =
delete
;
89
90
[[nodiscard]] std::optional<model::LedgerData>
91
extractLedgerWithDiff
(uint32_t seq)
override
;
92
93
[[nodiscard]] std::optional<model::LedgerData>
94
extractLedgerOnly
(uint32_t seq)
override
;
95
};
96
97
}
// namespace etl::impl
LedgerFetcherInterface.hpp
etl::impl::Extractor::extractLedgerWithDiff
std::optional< model::LedgerData > extractLedgerWithDiff(uint32_t seq) override
Extract diff data for a particular ledger.
Definition
Extraction.cpp:198
etl::impl::Extractor::extractLedgerOnly
std::optional< model::LedgerData > extractLedgerOnly(uint32_t seq) override
Extract data for a particular ledger.
Definition
Extraction.cpp:217
util::Logger
A simple thread-safe logger for the channel specified in the constructor.
Definition
Logger.hpp:110
etl::ExtractorInterface
An interface for the Extractor.
Definition
ExtractorInterface.hpp:13
etl::model::Object::ModType
ModType
Modification type for the object.
Definition
Models.hpp:95
src
etl
impl
Extraction.hpp
Generated by
1.17.0