Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Loading.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and 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#pragma once
21
22#include "data/BackendInterface.hpp"
24#include "etl/impl/LedgerLoader.hpp"
25#include "etlng/AmendmentBlockHandlerInterface.hpp"
26#include "etlng/InitialLoadObserverInterface.hpp"
27#include "etlng/LoaderInterface.hpp"
28#include "etlng/Models.hpp"
29#include "etlng/RegistryInterface.hpp"
30#include "util/log/Logger.hpp"
31
32#include <org/xrpl/rpc/v1/ledger.pb.h>
33#include <xrpl/basics/Slice.h>
34#include <xrpl/basics/base_uint.h>
35#include <xrpl/basics/strHex.h>
36#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
37#include <xrpl/protocol/LedgerHeader.h>
38#include <xrpl/protocol/STTx.h>
39#include <xrpl/protocol/Serializer.h>
40#include <xrpl/protocol/TxMeta.h>
41
42#include <cstddef>
43#include <cstdint>
44#include <memory>
45#include <optional>
46#include <string>
47#include <vector>
48
49namespace etlng::impl {
50
52 std::shared_ptr<BackendInterface> backend_;
53 std::shared_ptr<etl::LedgerFetcherInterface> fetcher_;
54 std::shared_ptr<RegistryInterface> registry_;
55 std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler_;
56
57 util::Logger log_{"ETL"};
58
59public:
60 using RawLedgerObjectType = org::xrpl::rpc::v1::RawLedgerObject;
61 using GetLedgerResponseType = org::xrpl::rpc::v1::GetLedgerResponse;
62 using OptionalGetLedgerResponseType = std::optional<GetLedgerResponseType>;
63
64 Loader(
65 std::shared_ptr<BackendInterface> backend,
66 std::shared_ptr<etl::LedgerFetcherInterface> fetcher,
67 std::shared_ptr<RegistryInterface> registry,
68 std::shared_ptr<AmendmentBlockHandlerInterface> amendmentBlockHandler
69 );
70
71 void
72 load(model::LedgerData const& data) override;
73
74 void
76 uint32_t seq,
77 std::vector<model::Object> const& data,
78 std::optional<std::string> lastKey
79 ) override;
80
81 std::optional<ripple::LedgerHeader>
83};
84
85} // namespace etlng::impl
Definition Loading.hpp:51
void load(model::LedgerData const &data) override
Load ledger data.
Definition Loading.cpp:61
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:78
std::optional< ripple::LedgerHeader > loadInitialLedger(model::LedgerData const &data) override
Load the initial ledger.
Definition Loading.cpp:91
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:110
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
The interface for observing the initial ledger load.
Definition InitialLoadObserverInterface.hpp:36
An interface for a ETL Loader.
Definition LoaderInterface.hpp:33
Represents an entire ledger diff worth of transactions and objects.
Definition Models.hpp:143