Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Loading.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "etl/AmendmentBlockHandlerInterface.hpp"
5#include "etl/InitialLoadObserverInterface.hpp"
6#include "etl/LoaderInterface.hpp"
7#include "etl/Models.hpp"
8#include "etl/RegistryInterface.hpp"
9#include "etl/SystemState.hpp"
10#include "util/log/Logger.hpp"
11
12#include <org/xrpl/rpc/v1/ledger.pb.h>
13#include <xrpl/basics/Slice.h>
14#include <xrpl/basics/base_uint.h>
15#include <xrpl/basics/strHex.h>
16#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
17#include <xrpl/protocol/LedgerHeader.h>
18#include <xrpl/protocol/STTx.h>
19#include <xrpl/protocol/Serializer.h>
20#include <xrpl/protocol/TxMeta.h>
21
22#include <cstddef>
23#include <cstdint>
24#include <memory>
25#include <optional>
26#include <string>
27#include <vector>
28
29namespace etl::impl {
30
31class Loader : public LoaderInterface, public InitialLoadObserverInterface {
32 std::shared_ptr<BackendInterface> backend_;
33 std::shared_ptr<RegistryInterface> registry_;
34 std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler_;
35 std::shared_ptr<SystemState> state_;
36
37 std::size_t initialLoadWrittenObjects_{0u};
38 std::size_t initialLoadWrites_{0u};
39 util::Logger log_{"ETL"};
40
41public:
42 using RawLedgerObjectType = org::xrpl::rpc::v1::RawLedgerObject;
43 using GetLedgerResponseType = org::xrpl::rpc::v1::GetLedgerResponse;
44 using OptionalGetLedgerResponseType = std::optional<GetLedgerResponseType>;
45
46 Loader(
47 std::shared_ptr<BackendInterface> backend,
48 std::shared_ptr<RegistryInterface> registry,
49 std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler,
50 std::shared_ptr<SystemState> state
51 );
52
53 Loader(Loader const&) = delete;
54 Loader(Loader&&) = delete;
55 Loader&
56 operator=(Loader const&) = delete;
57 Loader&
58 operator=(Loader&&) = delete;
59
60 std::expected<void, LoaderError>
61 load(model::LedgerData const& data) override;
62
63 void
65 uint32_t seq,
66 std::vector<model::Object> const& data,
67 std::optional<std::string> lastKey
68 ) override;
69
70 std::optional<ripple::LedgerHeader>
72};
73
74} // namespace etl::impl
std::expected< void, LoaderError > load(model::LedgerData const &data) override
Load ledger data.
Definition Loading.cpp:43
void onInitialLoadGotMoreObjects(uint32_t seq, std::vector< model::Object > const &data, std::optional< std::string > lastKey) override
Callback for each incoming batch of objects during initial ledger load.
Definition Loading.cpp:80
std::optional< ripple::LedgerHeader > loadInitialLedger(model::LedgerData const &data) override
Load the initial ledger.
Definition Loading.cpp:124
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:77
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56
The interface for observing the initial ledger load.
Definition InitialLoadObserverInterface.hpp:17
An interface for a ETL Loader.
Definition LoaderInterface.hpp:23
Represents an entire ledger diff worth of transactions and objects.
Definition Models.hpp:124