22#include "etlng/Models.hpp"
23#include "etlng/RegistryInterface.hpp"
25#include <xrpl/protocol/TxFormats.h>
34namespace etlng::impl {
38 { p.onLedgerData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
43 { p.onInitialData(std::declval<etlng::model::LedgerData>()) } -> std::same_as<void>;
48 { p.onTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
53 { p.onObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
58 { p.onInitialTransaction(uint32_t{}, std::declval<etlng::model::Transaction>()) } -> std::same_as<void>;
64 p.onInitialObjects(uint32_t{}, std::declval<std::vector<etlng::model::Object>>(), std::string{})
65 } -> std::same_as<void>;
70 { p.onInitialObject(uint32_t{}, std::declval<etlng::model::Object>()) } -> std::same_as<void>;
91 std::tuple<Ps...> store_;
95 "Spec must be specified when 'onTransaction' function exists."
100 "Spec must be specified when 'onInitialTransaction' function exists."
105 requires(std::is_same_v<std::decay_t<
decltype(exts)>, std::decay_t<Ps>> and ...)
106 : store_(std::forward<Ps>(exts)...)
114 operator=(
Registry const&) =
delete;
123 auto const expand = [&](
auto& p) {
124 if constexpr (
requires { p.onLedgerData(
data); }) {
125 p.onLedgerData(
data);
129 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
135 if constexpr (
requires { p.onTransaction(
data.seq, t); }) {
136 if (std::decay_t<P>::spec::wants(t.type))
137 p.onTransaction(
data.seq, t);
141 for (
auto const& t :
data.transactions) {
142 std::apply([&expand, &t](
auto&&... xs) { (expand(xs, t), ...); }, store_);
148 auto const expand = [&]<
typename P>(P&& p,
model::Object const& o) {
149 if constexpr (
requires { p.onObject(
data.seq, o); }) {
150 p.onObject(
data.seq, o);
154 for (
auto const& obj :
data.objects) {
155 std::apply([&expand, &obj](
auto&&... xs) { (expand(xs, obj), ...); }, store_);
165 auto const expand = [&](
auto&& p) {
166 if constexpr (
requires { p.onInitialObjects(seq,
data, lastKey); }) {
167 p.onInitialObjects(seq,
data, lastKey);
171 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
176 auto const expand = [&]<
typename P>(P&& p,
model::Object const& o) {
177 if constexpr (
requires { p.onInitialObject(seq, o); }) {
178 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 p.onInitialData(
data);
199 std::apply([&expand](
auto&&... xs) { (expand(xs), ...); }, store_);
205 if constexpr (
requires { p.onInitialTransaction(
data.seq, tx); }) {
206 if (std::decay_t<P>::spec::wants(tx.type))
207 p.onInitialTransaction(
data.seq, tx);
211 for (
auto const& tx :
data.transactions) {
212 std::apply([&expand, &tx](
auto&&... xs) { (expand(xs, tx), ...); }, store_);
219makeRegistry(
auto&&... exts)
221 return std::make_unique<Registry<std::decay_t<
decltype(exts)>...>>(std::forward<
decltype(exts)>(exts)...);
Definition Registry.hpp:90
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:119
constexpr void dispatchInitialObjects(uint32_t seq, std::vector< model::Object > const &data, std::string lastKey) override
Dispatch initial objects.
Definition Registry.hpp:161
Definition Registry.hpp:74
Definition Registry.hpp:77
Definition Registry.hpp:42
Definition Registry.hpp:69
Definition Registry.hpp:62
Definition Registry.hpp:57
Definition Registry.hpp:37
Definition Registry.hpp:52
Definition Registry.hpp:47
Definition Registry.hpp:82
Definition Registry.hpp:87
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