22#include "etlng/Models.hpp"
23#include "etlng/RegistryInterface.hpp"
25#include <xrpl/protocol/TxFormats.h>
35namespace etlng::impl {
39 { p.onLedgerData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
44 { p.onInitialData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
49 { p.onTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
54 { p.onObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
59 { p.onInitialTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
65 p.onInitialObjects(uint32_t{}, std::declval<std::vector<etlng::model::Object>>(), std::string{})
66 } -> std::same_as<void>;
71 { p.onInitialObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
92 std::tuple<Ps...> store_;
96 "Spec must be specified when 'onTransaction' function exists."
101 "Spec must be specified when 'onInitialTransaction' function exists."
106 requires(std::is_same_v<std::decay_t<
decltype(exts)>, std::decay_t<Ps>> and ...)
107 : store_(std::forward<Ps>(exts)...)
115 operator=(
Registry const&) =
delete;
124 auto const expand = [&](
auto& p) {
125 if constexpr (
requires { p.onLedgerData(
data); }) {
126 p.onLedgerData(
data);
130 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
136 if constexpr (
requires { p.onTransaction(
data.seq, t); }) {
137 if (std::decay_t<P>::spec::wants(t.type))
138 p.onTransaction(
data.seq, t);
142 for (
auto const& t :
data.transactions) {
143 std::apply([&expand, &t](
auto&&... xs) { (expand(xs, t), ...); }, store_);
149 auto const expand = [&]<
typename P>(P&& p,
model::Object const& o) {
150 if constexpr (
requires { p.onObject(
data.seq, o); }) {
151 p.onObject(
data.seq, o);
155 for (
auto const& obj :
data.objects) {
156 std::apply([&expand, &obj](
auto&&... xs) { (expand(xs, obj), ...); }, store_);
166 auto const expand = [&](
auto&& p) {
167 if constexpr (
requires { p.onInitialObjects(seq,
data, lastKey); }) {
168 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 p.onInitialObject(seq, o);
183 for (
auto const& obj :
data) {
184 std::apply([&expand, &obj](
auto&&... xs) { (expand(xs, obj), ...); }, store_);
194 auto const expand = [&](
auto&& p) {
195 if constexpr (
requires { p.onInitialData(
data); }) {
196 p.onInitialData(
data);
200 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
206 if constexpr (
requires { p.onInitialTransaction(
data.seq, tx); }) {
207 if (std::decay_t<P>::spec::wants(tx.type))
208 p.onInitialTransaction(
data.seq, tx);
212 for (
auto const& tx :
data.transactions) {
213 std::apply([&expand, &tx](
auto&&... xs) { (expand(xs, tx), ...); }, store_);
Definition Registry.hpp:91
constexpr void dispatchInitialData(model::LedgerData const &data) override
Dispatch initial ledger data.
Definition Registry.hpp:190
constexpr void dispatch(model::LedgerData const &data) override
Dispatch an entire ledger diff.
Definition Registry.hpp:120
constexpr void dispatchInitialObjects(uint32_t seq, std::vector< model::Object > const &data, std::string lastKey) override
Dispatch initial objects.
Definition Registry.hpp:162
Definition Registry.hpp:75
Definition Registry.hpp:78
Definition Registry.hpp:43
Definition Registry.hpp:70
Definition Registry.hpp:63
Definition Registry.hpp:58
Definition Registry.hpp:38
Definition Registry.hpp:53
Definition Registry.hpp:48
Definition Registry.hpp:83
Definition Registry.hpp:88
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
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