rippled
RelationalDBInterface_nodes.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_CORE_RELATIONALDBINTERFACE_NODES_H_INCLUDED
21 #define RIPPLE_CORE_RELATIONALDBINTERFACE_NODES_H_INCLUDED
22 
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/app/misc/Manifest.h>
25 #include <ripple/app/rdb/RelationalDBInterface.h>
26 #include <ripple/core/Config.h>
27 #include <ripple/overlay/PeerReservationTable.h>
28 #include <ripple/peerfinder/impl/Store.h>
29 #include <boost/filesystem.hpp>
30 
31 namespace ripple {
32 
33 /* Need to change TableTypeCount if TableType is modified. */
35 constexpr int TableTypeCount = 3;
36 
38 {
41  bool valid;
42 };
43 
54  Config const& config,
55  DatabaseCon::Setup const& setup,
56  DatabaseCon::CheckpointerSetup const& checkpointerSetup);
57 
65 getMinLedgerSeq(soci::session& session, TableType type);
66 
74 getMaxLedgerSeq(soci::session& session, TableType type);
75 
83 void
85  soci::session& session,
86  TableType type,
87  LedgerIndex ledgerSeq);
88 
96 void
98  soci::session& session,
99  TableType type,
100  LedgerIndex ledgerSeq);
101 
109 getRows(soci::session& session, TableType type);
110 
120 getRowsMinMax(soci::session& session, TableType type);
121 
131 bool
133  DatabaseCon& ldgDB,
134  DatabaseCon& txnDB,
135  Application& app,
136  std::shared_ptr<Ledger const> const& ledger,
137  bool current);
138 
148  soci::session& session,
149  LedgerIndex ledgerSeq,
150  beast::Journal j);
151 
159 getNewestLedgerInfo(soci::session& session, beast::Journal j);
160 
171  soci::session& session,
172  LedgerIndex ledgerFirstIndex,
173  beast::Journal j);
174 
185  soci::session& session,
186  LedgerIndex ledgerFirstIndex,
187  beast::Journal j);
188 
198  soci::session& session,
199  uint256 const& ledgerHash,
200  beast::Journal j);
201 
208 uint256
209 getHashByIndex(soci::session& session, LedgerIndex ledgerIndex);
210 
222  soci::session& session,
223  LedgerIndex ledgerIndex,
224  beast::Journal j);
225 
239  soci::session& session,
240  LedgerIndex minSeq,
241  LedgerIndex maxSeq,
242  beast::Journal j);
243 
258  soci::session& session,
259  Application& app,
260  LedgerIndex startIndex,
261  int quantity,
262  bool count);
263 
288  soci::session& session,
289  Application& app,
290  LedgerMaster& ledgerMaster,
292  std::optional<int> const& limit_used,
293  beast::Journal j);
294 
319  soci::session& session,
320  Application& app,
321  LedgerMaster& ledgerMaster,
323  std::optional<int> const& limit_used,
324  beast::Journal j);
325 
350  soci::session& session,
351  Application& app,
353  std::optional<int> const& limit_used,
354  beast::Journal j);
355 
380  soci::session& session,
381  Application& app,
383  std::optional<int> const& limit_used,
384  beast::Journal j);
385 
409  soci::session& session,
410  AccountIDCache const& idCache,
411  std::function<void(std::uint32_t)> const& onUnsavedLedger,
413  void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
414  onTransaction,
416  int limit_used,
417  std::uint32_t page_length);
418 
442  soci::session& session,
443  AccountIDCache const& idCache,
444  std::function<void(std::uint32_t)> const& onUnsavedLedger,
446  void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
447  onTransaction,
449  int limit_used,
450  std::uint32_t page_length);
451 
470  soci::session& session,
471  Application& app,
472  uint256 const& id,
474  error_code_i& ec);
475 
483 bool
484 dbHasSpace(soci::session& session, Config const& config, beast::Journal j);
485 
486 } // namespace ripple
487 
488 #endif
ripple::getLedgerInfoByIndex
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition: RelationalDBInterface_nodes.cpp:455
ripple::Application
Definition: Application.h:115
ripple::deleteBeforeLedgerSeq
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: RelationalDBInterface_nodes.cpp:148
std::string
STL class.
std::shared_ptr
STL class.
ripple::getTxHistory
std::pair< std::vector< std::shared_ptr< Transaction > >, int > getTxHistory(soci::session &session, Application &app, LedgerIndex startIndex, int quantity, bool count)
getTxHistory Returns given number of most recent transactions starting from given number of entry.
Definition: RelationalDBInterface_nodes.cpp:615
ripple::getHashByIndex
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition: RelationalDBInterface_nodes.cpp:509
ripple::getOldestAccountTxs
std::pair< RelationalDBInterface::AccountTxs, int > getOldestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getOldestAccountTxs Returns oldest transactions for given account which match given criteria starting...
Definition: RelationalDBInterface_nodes.cpp:897
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:84
ripple::getOldestAccountTxsB
std::pair< std::vector< RelationalDBInterface::txnMetaLedgerType >, int > getOldestAccountTxsB(soci::session &session, Application &app, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getOldestAccountTxsB Returns oldest transactions in binary form for given account which match given c...
Definition: RelationalDBInterface_nodes.cpp:1018
std::pair
ripple::LedgerMaster
Definition: LedgerMaster.h:70
ripple::DatabasePairValid
Definition: RelationalDBInterface_nodes.h:37
std::vector< unsigned char >
ripple::getRowsMinMax
RelationalDBInterface::CountMinMax getRowsMinMax(soci::session &session, TableType type)
getRowsMinMax Returns minumum ledger sequence, maximum ledger sequence and total number of rows in gi...
Definition: RelationalDBInterface_nodes.cpp:170
ripple::DatabaseCon::CheckpointerSetup
Definition: DatabaseCon.h:107
ripple::newestAccountTxPage
std::pair< std::optional< RelationalDBInterface::AccountTxMarker >, int > newestAccountTxPage(soci::session &session, AccountIDCache const &idCache, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDBInterface::AccountTxPageOptions const &options, int limit_used, std::uint32_t page_length)
newestAccountTxPage Searches newest transactions for given account which match given criteria startin...
Definition: RelationalDBInterface_nodes.cpp:1247
ripple::getLedgerInfoByHash
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition: RelationalDBInterface_nodes.cpp:498
ripple::DatabasePairValid::transactionDb
std::unique_ptr< DatabaseCon > transactionDb
Definition: RelationalDBInterface_nodes.h:40
std::function
ripple::getLimitedNewestLedgerInfo
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: RelationalDBInterface_nodes.cpp:486
ripple::AccountIDCache
Caches the base58 representations of AccountIDs.
Definition: AccountID.h:118
ripple::error_code_i
error_code_i
Definition: ErrorCodes.h:40
ripple::getLimitedOldestLedgerInfo
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: RelationalDBInterface_nodes.cpp:474
ripple::DatabasePairValid::valid
bool valid
Definition: RelationalDBInterface_nodes.h:41
ripple::getNewestAccountTxs
std::pair< RelationalDBInterface::AccountTxs, int > getNewestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getNewestAccountTxs Returns newest transactions for given account which match given criteria starting...
Definition: RelationalDBInterface_nodes.cpp:910
ripple::RelationalDBInterface::CountMinMax
Definition: RelationalDBInterface.h:51
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:75
ripple::saveValidatedLedger
static bool saveValidatedLedger(Application &app, std::shared_ptr< Ledger const > const &ledger, bool current)
Definition: Ledger.cpp:919
ripple::Config
Definition: Config.h:68
ripple::deleteByLedgerSeq
void deleteByLedgerSeq(soci::session &session, TableType type, LedgerIndex ledgerSeq)
deleteByLedgerSeq Deletes all entries in given table for the ledger with given sequence.
Definition: RelationalDBInterface_nodes.cpp:141
ripple::TableType::Transactions
@ Transactions
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
std::map
STL class.
ripple::range
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition: RangeSet.h:53
ripple::TableType::Ledgers
@ Ledgers
ripple::TableType::AccountTransactions
@ AccountTransactions
ripple::getNewestAccountTxsB
std::pair< std::vector< RelationalDBInterface::txnMetaLedgerType >, int > getNewestAccountTxsB(soci::session &session, Application &app, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getNewestAccountTxsB Returns newest transactions in binary form for given account which match given c...
Definition: RelationalDBInterface_nodes.cpp:1029
ripple::TableTypeCount
constexpr int TableTypeCount
Definition: RelationalDBInterface_nodes.h:35
ripple::getTransaction
std::variant< RelationalDBInterface::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: RelationalDBInterface_nodes.cpp:1270
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::getRows
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition: RelationalDBInterface_nodes.cpp:158
ripple::getHashesByIndex
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: RelationalDBInterface_nodes.cpp:539
ripple::DatabaseCon
Definition: DatabaseCon.h:81
ripple::makeLedgerDBs
DatabasePairValid makeLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeLedgerDBs Opens ledger and transactions databases.
Definition: RelationalDBInterface_nodes.cpp:65
ripple::oldestAccountTxPage
std::pair< std::optional< RelationalDBInterface::AccountTxMarker >, int > oldestAccountTxPage(soci::session &session, AccountIDCache const &idCache, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDBInterface::AccountTxPageOptions const &options, int limit_used, std::uint32_t page_length)
oldestAccountTxPage Searches oldest transactions for given account which match given criteria startin...
Definition: RelationalDBInterface_nodes.cpp:1224
std::optional
std::size_t
ripple::RelationalDBInterface::AccountTxPageOptions
Definition: RelationalDBInterface.h:74
ripple::ClosedInterval
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
Definition: RangeSet.h:44
ripple::TableType
TableType
Definition: RelationalDBInterface_nodes.h:34
ripple::dbHasSpace
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition: RelationalDBInterface_nodes.cpp:1351
ripple::getMinLedgerSeq
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition: RelationalDBInterface_nodes.cpp:121
ripple::DatabasePairValid::ledgerDb
std::unique_ptr< DatabaseCon > ledgerDb
Definition: RelationalDBInterface_nodes.h:39
std::unique_ptr
STL class.
ripple::RelationalDBInterface::AccountTxOptions
Definition: RelationalDBInterface.h:64
ripple::getNewestLedgerInfo
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition: RelationalDBInterface_nodes.cpp:466
ripple::getMaxLedgerSeq
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition: RelationalDBInterface_nodes.cpp:131
std::variant