rippled
Loading...
Searching...
No Matches
Node.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2020 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or 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#ifndef RIPPLE_APP_RDB_BACKEND_DETAIL_NODE_H_INCLUDED
21#define RIPPLE_APP_RDB_BACKEND_DETAIL_NODE_H_INCLUDED
22
23#include <xrpld/app/ledger/Ledger.h>
24#include <xrpld/app/rdb/RelationalDatabase.h>
25#include <xrpld/core/Config.h>
26
27namespace ripple {
28namespace detail {
29
30/* Need to change TableTypeCount if TableType is modified. */
32constexpr int TableTypeCount = 3;
33
40
52 Config const& config,
53 DatabaseCon::Setup const& setup,
54 DatabaseCon::CheckpointerSetup const& checkpointerSetup,
56
64getMinLedgerSeq(soci::session& session, TableType type);
65
73getMaxLedgerSeq(soci::session& session, TableType type);
74
82void
84 soci::session& session,
85 TableType type,
86 LedgerIndex ledgerSeq);
87
95void
97 soci::session& session,
98 TableType type,
99 LedgerIndex ledgerSeq);
100
108getRows(soci::session& session, TableType type);
109
119getRowsMinMax(soci::session& session, TableType type);
120
130bool
132 DatabaseCon& ldgDB,
133 DatabaseCon& txnDB,
134 Application& app,
135 std::shared_ptr<Ledger const> const& ledger,
136 bool current);
137
147 soci::session& session,
148 LedgerIndex ledgerSeq,
150
158getNewestLedgerInfo(soci::session& session, beast::Journal j);
159
170 soci::session& session,
171 LedgerIndex ledgerFirstIndex,
173
184 soci::session& session,
185 LedgerIndex ledgerFirstIndex,
187
197 soci::session& session,
198 uint256 const& ledgerHash,
200
208getHashByIndex(soci::session& session, LedgerIndex ledgerIndex);
209
221 soci::session& session,
222 LedgerIndex ledgerIndex,
224
238 soci::session& session,
239 LedgerIndex minSeq,
240 LedgerIndex maxSeq,
242
256 soci::session& session,
257 Application& app,
258 LedgerIndex startIndex,
259 int quantity);
260
282 soci::session& session,
283 Application& app,
287
309 soci::session& session,
310 Application& app,
314
336 soci::session& session,
337 Application& app,
340
362 soci::session& session,
363 Application& app,
366
387 soci::session& session,
388 std::function<void(std::uint32_t)> const& onUnsavedLedger,
390 void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
391 onTransaction,
393 std::uint32_t page_length);
394
415 soci::session& session,
416 std::function<void(std::uint32_t)> const& onUnsavedLedger,
418 void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
419 onTransaction,
421 std::uint32_t page_length);
422
441 soci::session& session,
442 Application& app,
443 uint256 const& id,
445 error_code_i& ec);
446
454bool
455dbHasSpace(soci::session& session, Config const& config, beast::Journal j);
456
457} // namespace detail
458} // namespace ripple
459
460#endif
A generic endpoint for log messages.
Definition Journal.h:60
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:174
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition Node.cpp:519
std::optional< LedgerInfo > getLimitedNewestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedNewestLedgerInfo Returns info of newest ledger from ledgers with sequences greather or equa...
Definition Node.cpp:496
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 page_length)
newestAccountTxPage Searches newest transactions for given account which match given criteria startin...
Definition Node.cpp:1175
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition Node.cpp:476
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 page_length)
oldestAccountTxPage Searches oldest transactions for given account which match given criteria startin...
Definition Node.cpp:1161
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:68
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:145
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition Node.cpp:162
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:152
bool saveValidatedLedger(DatabaseCon &ldgDB, DatabaseCon &txnDB, Application &app, std::shared_ptr< Ledger const > const &ledger, bool current)
saveValidatedLedger Saves ledger into database.
Definition Node.cpp:189
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:868
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
constexpr int TableTypeCount
Definition Node.h:32
std::optional< LedgerInfo > getLimitedOldestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedOldestLedgerInfo Returns info of oldest ledger from ledgers with sequences greather or equa...
Definition Node.cpp:484
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:968
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition Node.cpp:465
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition Node.cpp:1270
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition Node.cpp:508
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition Node.cpp:125
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:879
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:978
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:549
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition Node.cpp:135
std::variant< RelationalDatabase::AccountTx, TxSearched > getTransaction(soci::session &session, Application &app, uint256 const &id, std::optional< ClosedInterval< uint32_t > > const &range, error_code_i &ec)
getTransaction Returns transaction with given hash.
Definition Node.cpp:1189
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ current
This was a new validation and was added.
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
Definition RangeSet.h:45
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition RangeSet.h:54
@ ledgerMaster
ledger master data for signing
std::unique_ptr< DatabaseCon > ledgerDb
Definition Node.h:36
std::unique_ptr< DatabaseCon > transactionDb
Definition Node.h:37