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/misc/Manifest.h>
25#include <xrpld/app/rdb/RelationalDatabase.h>
26#include <xrpld/core/Config.h>
27#include <xrpld/overlay/PeerReservationTable.h>
28#include <xrpld/peerfinder/detail/Store.h>
29#include <boost/filesystem.hpp>
30
31namespace ripple {
32namespace detail {
33
34/* Need to change TableTypeCount if TableType is modified. */
36constexpr int TableTypeCount = 3;
37
39{
42 bool valid;
43};
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
88 soci::session& session,
89 TableType type,
90 LedgerIndex ledgerSeq);
91
99void
101 soci::session& session,
102 TableType type,
103 LedgerIndex ledgerSeq);
104
112getRows(soci::session& session, TableType type);
113
123getRowsMinMax(soci::session& session, TableType type);
124
134bool
136 DatabaseCon& ldgDB,
137 DatabaseCon& txnDB,
138 Application& app,
139 std::shared_ptr<Ledger const> const& ledger,
140 bool current);
141
151 soci::session& session,
152 LedgerIndex ledgerSeq,
154
162getNewestLedgerInfo(soci::session& session, beast::Journal j);
163
174 soci::session& session,
175 LedgerIndex ledgerFirstIndex,
177
188 soci::session& session,
189 LedgerIndex ledgerFirstIndex,
191
201 soci::session& session,
202 uint256 const& ledgerHash,
204
212getHashByIndex(soci::session& session, LedgerIndex ledgerIndex);
213
225 soci::session& session,
226 LedgerIndex ledgerIndex,
228
242 soci::session& session,
243 LedgerIndex minSeq,
244 LedgerIndex maxSeq,
246
260 soci::session& session,
261 Application& app,
262 LedgerIndex startIndex,
263 int quantity);
264
286 soci::session& session,
287 Application& app,
291
313 soci::session& session,
314 Application& app,
318
340 soci::session& session,
341 Application& app,
344
366 soci::session& session,
367 Application& app,
370
391 soci::session& session,
392 std::function<void(std::uint32_t)> const& onUnsavedLedger,
394 void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
395 onTransaction,
397 std::uint32_t page_length);
398
419 soci::session& session,
420 std::function<void(std::uint32_t)> const& onUnsavedLedger,
422 void(std::uint32_t, std::string const&, Blob&&, Blob&&)> const&
423 onTransaction,
425 std::uint32_t page_length);
426
445 soci::session& session,
446 Application& app,
447 uint256 const& id,
449 error_code_i& ec);
450
458bool
459dbHasSpace(soci::session& session, Config const& config, beast::Journal j);
460
461} // namespace detail
462} // namespace ripple
463
464#endif
A generic endpoint for log messages.
Definition: Journal.h:59
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:173
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition: Node.cpp:514
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:491
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:1170
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition: Node.cpp:471
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:1156
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:67
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:144
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition: Node.cpp:161
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:151
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:188
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:863
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:620
constexpr int TableTypeCount
Definition: Node.h:36
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:479
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:963
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition: Node.cpp:460
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition: Node.cpp:1265
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition: Node.cpp:503
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition: Node.cpp:124
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:874
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:973
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:544
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition: Node.cpp:134
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:1184
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
error_code_i
Definition: ErrorCodes.h:40
@ 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:40
std::unique_ptr< DatabaseCon > transactionDb
Definition: Node.h:41