Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Successor.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, 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"
23#include "data/LedgerCacheInterface.hpp"
24#include "data/Types.hpp"
25#include "etlng/Models.hpp"
26#include "util/log/Logger.hpp"
27
28#include <xrpl/basics/base_uint.h>
29#include <xrpl/basics/strHex.h>
30
31#include <cstdint>
32#include <functional>
33#include <memory>
34#include <optional>
35#include <string>
36#include <vector>
37
38namespace etlng::impl {
39
41 std::shared_ptr<BackendInterface> backend_;
42 std::reference_wrapper<data::LedgerCacheInterface> cache_;
43
44 util::Logger log_{"ETL"};
45
46public:
47 SuccessorExt(std::shared_ptr<BackendInterface> backend, data::LedgerCacheInterface& cache);
48
49 void
50 onInitialData(model::LedgerData const& data) const;
51
52 void
53 onInitialObjects(uint32_t seq, [[maybe_unused]] std::vector<model::Object> const& objs, std::string lastKey) const;
54
55 void
56 onLedgerData(model::LedgerData const& data) const;
57
58private:
59 void
60 writeIncludedSuccessor(uint32_t seq, model::BookSuccessor const& succ) const;
61
62 void
63 writeIncludedSuccessor(uint32_t seq, model::Object const& obj) const;
64
65 void
66 updateSuccessorFromCache(uint32_t seq, model::Object const& obj) const;
67
68 void
69 updateBookSuccessor(
70 std::optional<data::LedgerObject> const& maybeSuccessor,
71 auto seq,
72 ripple::uint256 const& bookBase
73 ) const;
74
75 void
76 writeSuccessors(uint32_t seq) const;
77
78 void
79 writeEdgeKeys(std::uint32_t seq, auto const& edgeKeys) const;
80};
81
82} // namespace etlng::impl
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:38
Definition Successor.hpp:40
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:111
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
Represents a book successor.
Definition Models.hpp:132
Represents an entire ledger diff worth of transactions and objects.
Definition Models.hpp:143
Represents a single object on the ledger.
Definition Models.hpp:105