rippled
Loading...
Searching...
No Matches
RelationalDatabase.h
1#pragma once
2
3#include <xrpld/app/ledger/Ledger.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/app/misc/Transaction.h>
6#include <xrpld/core/Config.h>
7#include <xrpld/core/DatabaseCon.h>
8#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
9
10#include <xrpl/beast/utility/instrumentation.h>
11
12#include <boost/filesystem.hpp>
13#include <boost/variant.hpp>
14
15namespace xrpl {
16
22
24{
25 uint32_t min;
26 uint32_t max;
27};
28
30{
31public:
38
44
54
64
69
70 using LedgerSequence = uint32_t;
74
84
92
102 init(Application& app, Config const& config, JobQueue& jobQueue);
103
104 virtual ~RelationalDatabase() = default;
105
113
121
129
136
144 getLedgerInfoByHash(uint256 const& ledgerHash) = 0;
145
152 virtual uint256
153 getHashByIndex(LedgerIndex ledgerIndex) = 0;
154
164
176
185 getTxHistory(LedgerIndex startIndex) = 0;
186
193 virtual bool
194 ledgerDbHasSpace(Config const& config) = 0;
195
202 virtual bool
203 transactionDbHasSpace(Config const& config) = 0;
204};
205
206template <class T, class C>
207T
209{
213 {
214 // This should never happen
215 // LCOV_EXCL_START
216 UNREACHABLE("xrpl::rangeCheckedCast : domain error");
217 JLOG(debugLog().error()) << "rangeCheckedCast domain error:"
218 << " value = " << c << " min = " << std::numeric_limits<T>::lowest()
219 << " max: " << std::numeric_limits<T>::max();
220 // LCOV_EXCL_STOP
221 }
222
223 return static_cast<T>(c);
224}
225
226} // namespace xrpl
A pool of threads to perform work.
Definition JobQueue.h:37
virtual bool transactionDbHasSpace(Config const &config)=0
transactionDbHasSpace Checks if the transaction 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 ~RelationalDatabase()=default
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< LedgerHeader > getNewestLedgerInfo()=0
getNewestLedgerInfo Returns the info of the newest saved ledger.
virtual std::optional< LedgerHeader > 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.
virtual std::optional< LedgerHeader > getLedgerInfoByIndex(LedgerIndex ledgerSeq)=0
getLedgerInfoByIndex Returns a ledger by its sequence.
virtual std::optional< LedgerIndex > getMinLedgerSeq()=0
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
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.
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex)=0
getTxHistory Returns the 20 most recent transactions starting from the given number.
virtual std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex)=0
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
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:5
beast::Journal debugLog()
Returns a debug journal.
Definition Log.cpp:445
base_uint< 256 > uint256
Definition base_uint.h:526
T rangeCheckedCast(C c)
std::optional< AccountTxMarker > marker
std::optional< LedgerSpecifier > ledger
std::variant< AccountTxs, MetaTxsList > transactions
std::optional< AccountTxMarker > marker