Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
TransactionsAdapter.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 "migration/cassandra/CassandraMigrationBackend.hpp"
23#include "migration/cassandra/impl/FullTableScannerAdapterBase.hpp"
24
25#include <boost/asio/spawn.hpp>
26#include <xrpl/basics/Blob.h>
27#include <xrpl/basics/base_uint.h>
28#include <xrpl/protocol/STTx.h>
29#include <xrpl/protocol/TxMeta.h>
30
31#include <cstdint>
32#include <functional>
33#include <memory>
34#include <tuple>
35#include <utility>
36
37namespace migration::cassandra::impl {
38
43 // hash, date, ledger_seq, metadata, transaction
44 using Row = std::tuple<ripple::uint256, std::uint64_t, std::uint32_t, ripple::Blob, ripple::Blob>;
45 static constexpr char const* kPARTITION_KEY = "hash";
46 static constexpr char const* kTABLE_NAME = "transactions";
47};
48
53class TransactionsAdapter : public impl::FullTableScannerAdapterBase<TableTransactionsDesc> {
54public:
55 using OnTransactionRead = std::function<void(ripple::STTx, ripple::TxMeta)>;
56
63 explicit TransactionsAdapter(std::shared_ptr<CassandraMigrationBackend> backend, OnTransactionRead onTxRead)
64 : FullTableScannerAdapterBase<TableTransactionsDesc>(backend), onTransactionRead_{std::move(onTxRead)}
65 {
66 }
67
73 void
74 onRowRead(TableTransactionsDesc::Row const& row) override;
75
76private:
77 OnTransactionRead onTransactionRead_;
78};
79
80} // namespace migration::cassandra::impl
The adapter for the transactions table. This class is responsible for reading the transactions from t...
Definition TransactionsAdapter.hpp:53
TransactionsAdapter(std::shared_ptr< CassandraMigrationBackend > backend, OnTransactionRead onTxRead)
Construct a new Transactions Adapter object.
Definition TransactionsAdapter.hpp:63
void onRowRead(TableTransactionsDesc::Row const &row) override
The callback when a row is read.
Definition TransactionsAdapter.cpp:29
The base class for the full table scanner adapter. It is responsible for reading the rows from the fu...
Definition FullTableScannerAdapterBase.hpp:40
The description of the transactions table. It has to be a TableSpec.
Definition TransactionsAdapter.hpp:42