22#include "etl/SystemState.hpp"
23#include "etlng/Models.hpp"
24#include "etlng/RegistryInterface.hpp"
26#include <xrpl/protocol/TxFormats.h>
37namespace etlng::impl {
41 { p.onLedgerData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
46 { p.onInitialData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
51 { p.onTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
56 { p.onObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
61 { p.onInitialTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
67 p.onInitialObjects(uint32_t{}, std::declval<std::vector<etlng::model::Object>>(), std::string{})
68 } -> std::same_as<void>;
73 { p.onInitialObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
94 std::reference_wrapper<etl::SystemState const> state_;
95 std::tuple<Ps...> store_;
99 "Spec must be specified when 'onTransaction' function exists."
104 "Spec must be specified when 'onInitialTransaction' function exists."
109 requires(std::is_same_v<std::decay_t<
decltype(exts)>, std::decay_t<Ps>> and ...)
110 : state_{state}, store_(std::forward<Ps>(exts)...)
118 operator=(
Registry const&) =
delete;
127 auto const expand = [&](
auto& p) {
128 if constexpr (
requires { p.onLedgerData(
data); })
129 executeIfAllowed(p, [&
data](
auto& p) { p.onLedgerData(
data); });
132 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
138 if constexpr (
requires { p.onTransaction(
data.seq, t); }) {
139 if (std::decay_t<P>::spec::wants(t.type))
140 executeIfAllowed(p, [&
data, &t](
auto& p) { p.onTransaction(
data.seq, t); });
144 for (
auto const& t :
data.transactions) {
145 std::apply([&expand, &t](
auto&&... xs) { (expand(xs, t), ...); }, store_);
151 auto const expand = [&]<
typename P>(P&& p,
model::Object const& o) {
152 if constexpr (
requires { p.onObject(
data.seq, o); })
153 executeIfAllowed(p, [&
data, &o](
auto& p) { p.onObject(
data.seq, o); });
156 for (
auto const& obj :
data.objects) {
157 std::apply([&expand, &obj](
auto&&... xs) { (expand(xs, obj), ...); }, store_);
167 auto const expand = [&](
auto&& p) {
168 if constexpr (
requires { p.onInitialObjects(seq,
data, lastKey); })
169 executeIfAllowed(p, [seq, &
data, &lastKey](
auto& p) { p.onInitialObjects(seq,
data, lastKey); });
172 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
177 auto const expand = [&]<
typename P>(P&& p,
model::Object const& o) {
178 if constexpr (
requires { p.onInitialObject(seq, o); })
179 executeIfAllowed(p, [seq, &o](
auto& p) { p.onInitialObject(seq, o); });
182 for (
auto const& obj :
data) {
183 std::apply([&expand, &obj](
auto&&... xs) { (expand(xs, obj), ...); }, store_);
193 auto const expand = [&](
auto&& p) {
194 if constexpr (
requires { p.onInitialData(
data); })
195 executeIfAllowed(p, [&
data](
auto& p) { p.onInitialData(
data); });
198 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
204 if constexpr (
requires { p.onInitialTransaction(
data.seq, tx); }) {
205 if (std::decay_t<P>::spec::wants(tx.type))
206 executeIfAllowed(p, [&
data, &tx](
auto& p) { p.onInitialTransaction(
data.seq, tx); });
210 for (
auto const& tx :
data.transactions) {
211 std::apply([&expand, &tx](
auto&&... xs) { (expand(xs, tx), ...); }, store_);
218 executeIfAllowed(
auto& p,
auto&& fn)
220 if constexpr (
requires { p.allowInReadonly(); }) {
221 if (state_.get().isWriting or p.allowInReadonly())
224 if (state_.get().isWriting)
233 return std::make_unique<Registry<std::decay_t<
decltype(exts)>...>>(state, std::forward<
decltype(exts)>(exts)...);
Definition Registry.hpp:93
constexpr void dispatchInitialData(model::LedgerData const &data) override
Dispatch initial ledger data.
Definition Registry.hpp:189
constexpr void dispatch(model::LedgerData const &data) override
Dispatch an entire ledger diff.
Definition Registry.hpp:123
constexpr void dispatchInitialObjects(uint32_t seq, std::vector< model::Object > const &data, std::string lastKey) override
Dispatch initial objects.
Definition Registry.hpp:163
Definition Registry.hpp:77
Definition Registry.hpp:80
Definition Registry.hpp:45
Definition Registry.hpp:72
Definition Registry.hpp:65
Definition Registry.hpp:60
Definition Registry.hpp:40
Definition Registry.hpp:55
Definition Registry.hpp:50
Definition Registry.hpp:85
Definition Registry.hpp:90
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
Represents the state of the ETL subsystem.
Definition SystemState.hpp:33
The interface for a registry that can dispatch transactions and objects to extensions.
Definition RegistryInterface.hpp:72
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
Represents a single transaction on the ledger.
Definition Models.hpp:71