rippled
Loading...
Searching...
No Matches
RelationalDatabase.h
1#ifndef XRPL_APP_RDB_RELATIONALDATABASE_H_INCLUDED
2#define XRPL_APP_RDB_RELATIONALDATABASE_H_INCLUDED
3
4#include <xrpld/app/ledger/Ledger.h>
5#include <xrpld/app/main/Application.h>
6#include <xrpld/app/misc/Transaction.h>
7#include <xrpld/core/Config.h>
8#include <xrpld/core/DatabaseCon.h>
9#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
10
11#include <xrpl/beast/utility/instrumentation.h>
12
13#include <boost/filesystem.hpp>
14#include <boost/variant.hpp>
15
16namespace ripple {
17
23
25{
26 uint32_t min;
27 uint32_t max;
28};
29
31{
32public:
39
45
55
65
66 using AccountTx =
71
72 using LedgerSequence = uint32_t;
77
87
95
105 init(Application& app, Config const& config, JobQueue& jobQueue);
106
107 virtual ~RelationalDatabase() = default;
108
116
124
132
139
147 getLedgerInfoByHash(uint256 const& ledgerHash) = 0;
148
155 virtual uint256
156 getHashByIndex(LedgerIndex ledgerIndex) = 0;
157
167
179
188 getTxHistory(LedgerIndex startIndex) = 0;
189
196 virtual bool
197 ledgerDbHasSpace(Config const& config) = 0;
198
205 virtual bool
206 transactionDbHasSpace(Config const& config) = 0;
207};
208
209template <class T, class C>
210T
212{
213 if ((c > std::numeric_limits<T>::max()) ||
218 {
219 // This should never happen
220 // LCOV_EXCL_START
221 UNREACHABLE("ripple::rangeCheckedCast : domain error");
222 JLOG(debugLog().error())
223 << "rangeCheckedCast domain error:"
224 << " value = " << c << " min = " << std::numeric_limits<T>::lowest()
225 << " max: " << std::numeric_limits<T>::max();
226 // LCOV_EXCL_STOP
227 }
228
229 return static_cast<T>(c);
230}
231
232} // namespace ripple
233
234#endif
A pool of threads to perform work.
Definition JobQueue.h:39
virtual std::optional< LedgerInfo > getNewestLedgerInfo()=0
getNewestLedgerInfo Returns the info of the newest saved ledger.
virtual ~RelationalDatabase()=default
virtual std::optional< LedgerInfo > getLedgerInfoByIndex(LedgerIndex ledgerSeq)=0
getLedgerInfoByIndex Returns a ledger by its sequence.
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex)=0
getTxHistory Returns the 20 most recent transactions starting from the given number.
virtual bool transactionDbHasSpace(Config const &config)=0
transactionDbHasSpace Checks if the transaction database has available space.
virtual std::optional< LedgerIndex > getMaxLedgerSeq()=0
getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.
virtual bool ledgerDbHasSpace(Config const &config)=0
ledgerDbHasSpace Checks if the ledger database has available space.
static std::unique_ptr< RelationalDatabase > init(Application &app, Config const &config, JobQueue &jobQueue)
init Creates and returns an appropriate RelationalDatabase instance based on configuration.
virtual std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex)=0
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
virtual std::optional< LedgerIndex > getMinLedgerSeq()=0
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
virtual std::map< LedgerIndex, LedgerHashPair > getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq)=0
getHashesByIndex Returns hashes of each ledger and its parent for all ledgers within the provided ran...
virtual std::optional< LedgerInfo > getLedgerInfoByHash(uint256 const &ledgerHash)=0
getLedgerInfoByHash Returns the info of the ledger with given hash.
virtual uint256 getHashByIndex(LedgerIndex ledgerIndex)=0
getHashByIndex Returns the hash of the ledger with the given sequence.
T lowest(T... args)
T max(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 256 > uint256
Definition base_uint.h:539
T rangeCheckedCast(C c)
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:457
std::optional< AccountTxMarker > marker
std::optional< LedgerSpecifier > ledger
std::optional< AccountTxMarker > marker
std::variant< AccountTxs, MetaTxsList > transactions