xrpld
Loading...
Searching...
No Matches
Node.h
1#pragma once
2
3#include <xrpld/core/Config.h>
4
5#include <xrpl/basics/Blob.h>
6#include <xrpl/basics/RangeSet.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/core/PerfLog.h>
10#include <xrpl/core/ServiceRegistry.h>
11#include <xrpl/ledger/Ledger.h>
12#include <xrpl/protocol/ErrorCodes.h>
13#include <xrpl/protocol/LedgerHeader.h>
14#include <xrpl/protocol/Protocol.h>
15#include <xrpl/protocol/TxSearched.h>
16#include <xrpl/rdb/DatabaseCon.h>
17#include <xrpl/rdb/RelationalDatabase.h>
18
19#include <soci/session.h>
20
21#include <cstddef>
22#include <cstdint>
23#include <functional>
24#include <map>
25#include <memory>
26#include <optional>
27#include <string>
28#include <utility>
29#include <variant>
30#include <vector>
31
32namespace xrpl::detail {
33
34/* Need to change TableTypeCount if TableType is modified. */
36constexpr int kTableTypeCount = 3;
37
44
56 Config const& config,
57 DatabaseCon::Setup const& setup,
58 DatabaseCon::CheckpointerSetup const& checkpointerSetup,
60
68getMinLedgerSeq(soci::session& session, TableType type);
69
77getMaxLedgerSeq(soci::session& session, TableType type);
78
86void
87deleteByLedgerSeq(soci::session& session, TableType type, LedgerIndex ledgerSeq);
88
96void
97deleteBeforeLedgerSeq(soci::session& session, TableType type, LedgerIndex ledgerSeq);
98
106getRows(soci::session& session, TableType type);
107
117getRowsMinMax(soci::session& session, TableType type);
118
128bool
130 DatabaseCon& ldgDB,
131 std::unique_ptr<DatabaseCon> const& txnDB,
132 Application& app,
133 std::shared_ptr<Ledger const> const& ledger,
134 bool current);
135
144getLedgerInfoByIndex(soci::session& session, LedgerIndex ledgerSeq, beast::Journal j);
145
153getNewestLedgerInfo(soci::session& session, beast::Journal j);
154
164getLimitedOldestLedgerInfo(soci::session& session, LedgerIndex ledgerFirstIndex, beast::Journal j);
165
175getLimitedNewestLedgerInfo(soci::session& session, LedgerIndex ledgerFirstIndex, beast::Journal j);
176
185getLedgerInfoByHash(soci::session& session, uint256 const& ledgerHash, beast::Journal j);
186
194getHashByIndex(soci::session& session, LedgerIndex ledgerIndex);
195
206getHashesByIndex(soci::session& session, LedgerIndex ledgerIndex, beast::Journal j);
207
220getHashesByIndex(soci::session& session, LedgerIndex minSeq, LedgerIndex maxSeq, beast::Journal j);
221
234getTxHistory(soci::session& session, Application& app, LedgerIndex startIndex, int quantity);
235
257 soci::session& session,
258 Application& app,
259 LedgerMaster& ledgerMaster,
262
284 soci::session& session,
285 Application& app,
286 LedgerMaster& ledgerMaster,
289
311 soci::session& session,
312 Application& app,
315
337 soci::session& session,
338 Application& app,
341
362 soci::session& session,
363 std::function<void(std::uint32_t)> const& onUnsavedLedger,
364 std::function<void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const& onTransaction,
366 std::uint32_t pageLength);
367
388 soci::session& session,
389 std::function<void(std::uint32_t)> const& onUnsavedLedger,
390 std::function<void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const& onTransaction,
392 std::uint32_t pageLength);
393
412 soci::session& session,
413 Application& app,
414 uint256 const& id,
416 ErrorCodeI& ec);
417
425bool
426dbHasSpace(soci::session& session, Config const& config, beast::Journal j);
427
428} // namespace xrpl::detail
A generic endpoint for log messages.
Definition Journal.h:44
std::optional< LedgerHeader > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition Node.cpp:524
std::pair< std::optional< RelationalDatabase::AccountTxMarker >, int > newestAccountTxPage(soci::session &session, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDatabase::AccountTxPageOptions const &options, std::uint32_t pageLength)
newestAccountTxPage Searches newest transactions for given account which match given criteria startin...
Definition Node.cpp:1296
constexpr int kTableTypeCount
Definition Node.h:36
bool saveValidatedLedger(DatabaseCon &ldgDB, std::unique_ptr< DatabaseCon > const &txnDB, Application &app, std::shared_ptr< Ledger const > const &ledger, bool current)
saveValidatedLedger Saves ledger into database.
Definition Node.cpp:216
std::pair< std::optional< RelationalDatabase::AccountTxMarker >, int > oldestAccountTxPage(soci::session &session, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDatabase::AccountTxPageOptions const &options, std::uint32_t pageLength)
oldestAccountTxPage Searches oldest transactions for given account which match given criteria startin...
Definition Node.cpp:1285
void deleteBeforeLedgerSeq(soci::session &session, TableType type, LedgerIndex ledgerSeq)
deleteBeforeLedgerSeq Deletes all entries in given table for the ledgers with given sequence and all ...
Definition Node.cpp:183
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition Node.cpp:157
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition Node.cpp:167
std::pair< RelationalDatabase::AccountTxs, int > getNewestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDatabase::AccountTxOptions const &options, beast::Journal j)
getNewestAccountTxs Returns newest transactions for given account which match given criteria starting...
Definition Node.cpp:893
std::pair< std::vector< std::shared_ptr< Transaction > >, int > getTxHistory(soci::session &session, Application &app, LedgerIndex startIndex, int quantity)
getTxHistory Returns given number of most recent transactions starting from given number of entry.
Definition Node.cpp:625
std::pair< std::vector< RelationalDatabase::txnMetaLedgerType >, int > getOldestAccountTxsB(soci::session &session, Application &app, RelationalDatabase::AccountTxOptions const &options, beast::Journal j)
getOldestAccountTxsB Returns oldest transactions in binary form for given account which match given c...
Definition Node.cpp:981
std::optional< LedgerHeader > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition Node.cpp:498
std::optional< LedgerHeader > getLimitedOldestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedOldestLedgerInfo Returns info of oldest ledger from ledgers with sequences greater or equal...
Definition Node.cpp:506
DatabasePairValid makeLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup, beast::Journal j)
makeLedgerDBs Opens ledger and transactions databases.
Definition Node.cpp:103
RelationalDatabase::CountMinMax getRowsMinMax(soci::session &session, TableType type)
getRowsMinMax Returns minimum ledger sequence, maximum ledger sequence and total number of rows in gi...
Definition Node.cpp:201
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition Node.cpp:189
std::optional< LedgerHeader > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition Node.cpp:490
std::pair< std::vector< RelationalDatabase::txnMetaLedgerType >, int > getNewestAccountTxsB(soci::session &session, Application &app, RelationalDatabase::AccountTxOptions const &options, beast::Journal j)
getNewestAccountTxsB Returns newest transactions in binary form for given account which match given c...
Definition Node.cpp:991
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition Node.cpp:532
void deleteByLedgerSeq(soci::session &session, TableType type, LedgerIndex ledgerSeq)
deleteByLedgerSeq Deletes all entries in given table for the ledger with given sequence.
Definition Node.cpp:177
std::pair< RelationalDatabase::AccountTxs, int > getOldestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDatabase::AccountTxOptions const &options, beast::Journal j)
getOldestAccountTxs Returns oldest transactions for given account which match given criteria starting...
Definition Node.cpp:882
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition Node.cpp:1383
std::optional< LedgerHeader > getLimitedNewestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedNewestLedgerInfo Returns info of newest ledger from ledgers with sequences greater or equal...
Definition Node.cpp:515
std::variant< RelationalDatabase::AccountTx, TxSearched > getTransaction(soci::session &session, Application &app, uint256 const &id, std::optional< ClosedInterval< uint32_t > > const &range, ErrorCodeI &ec)
getTransaction Returns transaction with given hash.
Definition Node.cpp:1307
std::optional< LedgerHashPair > getHashesByIndex(soci::session &session, LedgerIndex ledgerIndex, beast::Journal j)
getHashesByIndex Returns hash of the ledger and hash of parent ledger for the ledger of given sequenc...
Definition Node.cpp:561
ErrorCodeI
Definition ErrorCodes.h:23
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:370
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition RangeSet.h:37
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
Definition RangeSet.h:27
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:11
BaseUInt< 256 > uint256
Definition base_uint.h:580
std::unique_ptr< DatabaseCon > transactionDb
Definition Node.h:41
std::unique_ptr< DatabaseCon > ledgerDb
Definition Node.h:40