xrpld
Loading...
Searching...
No Matches
SQLiteDatabase.cpp
1#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
2
3#include <xrpld/app/ledger/LedgerMaster.h>
4#include <xrpld/app/misc/detail/AccountTxPaging.h>
5#include <xrpld/app/rdb/backend/detail/Node.h>
6#include <xrpld/core/Config.h>
7
8#include <xrpl/basics/Blob.h>
9#include <xrpl/basics/Log.h>
10#include <xrpl/basics/RangeSet.h>
11#include <xrpl/basics/base_uint.h>
12#include <xrpl/basics/contract.h>
13#include <xrpl/ledger/Ledger.h>
14#include <xrpl/protocol/ErrorCodes.h>
15#include <xrpl/protocol/LedgerHeader.h>
16#include <xrpl/protocol/Protocol.h>
17#include <xrpl/protocol/TxSearched.h>
18#include <xrpl/rdb/DatabaseCon.h>
19#include <xrpl/rdb/RelationalDatabase.h>
20#include <xrpl/rdb/SociDB.h>
21
22#include <cstddef>
23#include <cstdint>
24#include <functional>
25#include <map>
26#include <memory>
27#include <optional>
28#include <stdexcept>
29#include <string>
30#include <string_view>
31#include <utility>
32#include <variant>
33#include <vector>
34
35namespace xrpl {
36
37bool
39 Config const& config,
40 DatabaseCon::Setup const& setup,
41 DatabaseCon::CheckpointerSetup const& checkpointerSetup)
42{
43 auto [lgr, tx, res] = detail::makeLedgerDBs(config, setup, checkpointerSetup, j_);
44 txdb_ = std::move(tx);
45 ledgerDb_ = std::move(lgr);
46 return res;
47}
48
51{
52 /* if databases exists, use it */
53 if (existsLedger())
54 {
55 auto db = checkoutLedger();
57 }
58
59 /* else return empty value */
60 return {};
61}
62
65{
66 if (!useTxTables_)
67 return {};
68
70 {
71 auto db = checkoutTransaction();
73 }
74
75 return {};
76}
77
80{
81 if (!useTxTables_)
82 return {};
83
85 {
86 auto db = checkoutTransaction();
88 }
89
90 return {};
91}
92
95{
96 if (existsLedger())
97 {
98 auto db = checkoutLedger();
100 }
101
102 return {};
103}
104
105void
107{
108 if (!useTxTables_)
109 return;
110
111 if (existsTransaction())
112 {
113 auto db = checkoutTransaction();
115 return;
116 }
117}
118
119void
121{
122 if (existsLedger())
123 {
124 auto db = checkoutLedger();
126 return;
127 }
128}
129
130void
132{
133 if (!useTxTables_)
134 return;
135
136 if (existsTransaction())
137 {
138 auto db = checkoutTransaction();
140 return;
141 }
142}
143
144void
146{
147 if (!useTxTables_)
148 return;
149
150 if (existsTransaction())
151 {
152 auto db = checkoutTransaction();
154 return;
155 }
156}
157
160{
161 if (!useTxTables_)
162 return 0;
163
164 if (existsTransaction())
165 {
166 auto db = checkoutTransaction();
168 }
169
170 return 0;
171}
172
175{
176 if (!useTxTables_)
177 return 0;
178
179 if (existsTransaction())
180 {
181 auto db = checkoutTransaction();
183 }
184
185 return 0;
186}
187
190{
191 if (existsLedger())
192 {
193 auto db = checkoutLedger();
195 }
196
197 return {.numberOfRows = 0, .minLedgerSequence = 0, .maxLedgerSequence = 0};
198}
199
200bool
202{
203 if (existsLedger())
204 {
206 *ledgerDb_, txdb_, registry_.get().getApp(), ledger, current))
207 return false;
208 }
209
210 return true;
211}
212
215{
216 if (existsLedger())
217 {
218 auto db = checkoutLedger();
219 auto const res = detail::getLedgerInfoByIndex(*db, ledgerSeq, j_);
220
221 if (res.has_value())
222 return res;
223 }
224
225 return {};
226}
227
230{
231 if (existsLedger())
232 {
233 auto db = checkoutLedger();
234 auto const res = detail::getNewestLedgerInfo(*db, j_);
235
236 if (res.has_value())
237 return res;
238 }
239
240 return {};
241}
242
245{
246 if (existsLedger())
247 {
248 auto db = checkoutLedger();
249 auto const res = detail::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
250
251 if (res.has_value())
252 return res;
253 }
254
255 return {};
256}
257
260{
261 if (existsLedger())
262 {
263 auto db = checkoutLedger();
264 auto const res = detail::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
265
266 if (res.has_value())
267 return res;
268 }
269
270 return {};
271}
272
275{
276 if (existsLedger())
277 {
278 auto db = checkoutLedger();
279 auto const res = detail::getLedgerInfoByHash(*db, ledgerHash, j_);
280
281 if (res.has_value())
282 return res;
283 }
284
285 return {};
286}
287
290{
291 if (existsLedger())
292 {
293 auto db = checkoutLedger();
294 auto const res = detail::getHashByIndex(*db, ledgerIndex);
295
296 if (res.isNonZero())
297 return res;
298 }
299
300 return uint256();
301}
302
305{
306 if (existsLedger())
307 {
308 auto db = checkoutLedger();
309 auto const res = detail::getHashesByIndex(*db, ledgerIndex, j_);
310
311 if (res.has_value())
312 return res;
313 }
314
315 return {};
316}
317
320{
321 if (existsLedger())
322 {
323 auto db = checkoutLedger();
324 auto const res = detail::getHashesByIndex(*db, minSeq, maxSeq, j_);
325
326 if (!res.empty())
327 return res;
328 }
329
330 return {};
331}
332
335{
336 if (!useTxTables_)
337 return {};
338
339 if (existsTransaction())
340 {
341 auto db = checkoutTransaction();
342 auto const res = detail::getTxHistory(*db, registry_.get().getApp(), startIndex, 20).first;
343
344 if (!res.empty())
345 return res;
346 }
347
348 return {};
349}
350
353{
354 if (!useTxTables_)
355 return {};
356
357 LedgerMaster& ledgerMaster = registry_.get().getLedgerMaster();
358
359 if (existsTransaction())
360 {
361 auto db = checkoutTransaction();
362 return detail::getOldestAccountTxs(*db, registry_.get().getApp(), ledgerMaster, options, j_)
363 .first;
364 }
365
366 return {};
367}
368
371{
372 if (!useTxTables_)
373 return {};
374
375 LedgerMaster& ledgerMaster = registry_.get().getLedgerMaster();
376
377 if (existsTransaction())
378 {
379 auto db = checkoutTransaction();
380 return detail::getNewestAccountTxs(*db, registry_.get().getApp(), ledgerMaster, options, j_)
381 .first;
382 }
383
384 return {};
385}
386
389{
390 if (!useTxTables_)
391 return {};
392
393 if (existsTransaction())
394 {
395 auto db = checkoutTransaction();
396 return detail::getOldestAccountTxsB(*db, registry_.get().getApp(), options, j_).first;
397 }
398
399 return {};
400}
401
404{
405 if (!useTxTables_)
406 return {};
407
408 if (existsTransaction())
409 {
410 auto db = checkoutTransaction();
411 return detail::getNewestAccountTxsB(*db, registry_.get().getApp(), options, j_).first;
412 }
413
414 return {};
415}
416
419{
420 if (!useTxTables_)
421 return {};
422
423 static std::uint32_t const kPageLength(200);
424 auto onUnsavedLedger =
425 std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
426 AccountTxs ret;
427 auto onTransaction = [&ret, &app = registry_.get().getApp()](
428 std::uint32_t ledgerIndex,
429 std::string const& status,
430 Blob const& rawTxn,
431 Blob const& rawMeta) {
432 convertBlobsToTxResult(ret, ledgerIndex, status, rawTxn, rawMeta, app);
433 };
434
435 if (existsTransaction())
436 {
437 auto db = checkoutTransaction();
438 auto newmarker =
439 detail::oldestAccountTxPage(*db, onUnsavedLedger, onTransaction, options, kPageLength)
440 .first;
441 return {ret, newmarker};
442 }
443
444 return {};
445}
446
449{
450 if (!useTxTables_)
451 return {};
452
453 static std::uint32_t const kPageLength(200);
454 auto onUnsavedLedger =
455 std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
456 AccountTxs ret;
457 auto onTransaction = [&ret, &app = registry_.get().getApp()](
458 std::uint32_t ledgerIndex,
459 std::string const& status,
460 Blob const& rawTxn,
461 Blob const& rawMeta) {
462 convertBlobsToTxResult(ret, ledgerIndex, status, rawTxn, rawMeta, app);
463 };
464
465 if (existsTransaction())
466 {
467 auto db = checkoutTransaction();
468 auto newmarker =
469 detail::newestAccountTxPage(*db, onUnsavedLedger, onTransaction, options, kPageLength)
470 .first;
471 return {ret, newmarker};
472 }
473
474 return {};
475}
476
479{
480 if (!useTxTables_)
481 return {};
482
483 static std::uint32_t const kPageLength(500);
484 auto onUnsavedLedger =
485 std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
486 MetaTxsList ret;
487 auto onTransaction =
488 [&ret](
489 std::uint32_t ledgerIndex, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
490 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
491 };
492
493 if (existsTransaction())
494 {
495 auto db = checkoutTransaction();
496 auto newmarker =
497 detail::oldestAccountTxPage(*db, onUnsavedLedger, onTransaction, options, kPageLength)
498 .first;
499 return {ret, newmarker};
500 }
501
502 return {};
503}
504
507{
508 if (!useTxTables_)
509 return {};
510
511 static std::uint32_t const kPageLength(500);
512 auto onUnsavedLedger =
513 std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
514 MetaTxsList ret;
515 auto onTransaction =
516 [&ret](
517 std::uint32_t ledgerIndex, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
518 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
519 };
520
521 if (existsTransaction())
522 {
523 auto db = checkoutTransaction();
524 auto newmarker =
525 detail::newestAccountTxPage(*db, onUnsavedLedger, onTransaction, options, kPageLength)
526 .first;
527 return {ret, newmarker};
528 }
529
530 return {};
531}
532
535 uint256 const& id,
537 ErrorCodeI& ec)
538{
539 if (!useTxTables_)
540 return TxSearched::Unknown;
541
542 if (existsTransaction())
543 {
544 auto db = checkoutTransaction();
545 return detail::getTransaction(*db, registry_.get().getApp(), id, range, ec);
546 }
547
548 return TxSearched::Unknown;
549}
550
552 : registry_(rhs.registry_), useTxTables_(rhs.useTxTables_), j_(rhs.j_)
553{
554 std::exchange(ledgerDb_, std::move(rhs.ledgerDb_));
555 std::exchange(txdb_, std::move(rhs.txdb_));
556}
557
558bool
560{
561 if (existsLedger())
562 {
563 auto db = checkoutLedger();
564 return detail::dbHasSpace(*db, config, j_);
565 }
566
567 return true;
568}
569
570bool
572{
573 if (!useTxTables_)
574 return true;
575
576 if (existsTransaction())
577 {
578 auto db = checkoutTransaction();
579 return detail::dbHasSpace(*db, config, j_);
580 }
581
582 return true;
583}
584
587{
588 if (existsLedger())
589 {
590 return xrpl::getKBUsedAll(ledgerDb_->getSession());
591 }
592
593 return 0;
594}
595
598{
599 if (existsLedger())
600 {
601 return xrpl::getKBUsedDB(ledgerDb_->getSession());
602 }
603
604 return 0;
605}
606
609{
610 if (!useTxTables_)
611 return 0;
612
613 if (existsTransaction())
614 {
615 return xrpl::getKBUsedDB(txdb_->getSession());
616 }
617
618 return 0;
619}
620
621void
626
627void
632
634 : registry_(registry)
635 , useTxTables_(config.useTxTables())
636 , j_(registry.getJournal("SQLiteDatabase"))
637{
638 DatabaseCon::Setup const setup = setupDatabaseCon(config, j_);
639 if (!makeLedgerDBs(
640 config,
641 setup,
642 DatabaseCon::CheckpointerSetup{.jobQueue = &jobQueue, .registry = registry_}))
643 {
644 static constexpr std::string_view kError = "Failed to create ledger databases";
645
646 JLOG(j_.fatal()) << kError;
648 }
649}
650
652setupRelationalDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue)
653{
654 return {registry, config, jobQueue};
655}
656
657} // namespace xrpl
T bind(T... args)
A pool of threads to perform work.
Definition JobQueue.h:43
std::vector< AccountTx > AccountTxs
std::vector< txnMetaLedgerType > MetaTxsList
bool existsLedger()
existsLedger Checks if the node store ledger database exists.
uint256 getHashByIndex(LedgerIndex ledgerIndex) override
getHashByIndex Returns the hash of the ledger with the given sequence.
MetaTxsList getNewestAccountTxsB(AccountTxOptions const &options) override
getNewestAccountTxsB Returns the newest transactions in binary form for the account that matches the ...
bool ledgerDbHasSpace(Config const &config)
ledgerDbHasSpace Checks if the ledger database has available space.
auto checkoutTransaction()
checkoutTransaction Checks out and returns the node store transaction database.
void deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionByLedgerSeq Deletes transactions from the ledger with the given sequence.
std::optional< LedgerHeader > getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedOldestLedgerInfo Returns the info of the oldest ledger whose sequence number is greater tha...
SQLiteDatabase(ServiceRegistry &registry, Config const &config, JobQueue &jobQueue)
bool makeLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeLedgerDBs Opens ledger and transaction databases for the node store, and stores their descriptors...
std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex) override
getTxHistory Returns the 20 most recent transactions starting from the given number.
AccountTxs getOldestAccountTxs(AccountTxOptions const &options) override
getOldestAccountTxs Returns the oldest transactions for the account that matches the given criteria s...
void closeTransactionDB() override
Closes the transaction database.
auto checkoutLedger()
checkoutTransaction Checks out and returns node store ledger database.
void closeLedgerDB() override
Closes the ledger database.
std::reference_wrapper< ServiceRegistry > registry_
std::optional< LedgerHeader > getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedNewestLedgerInfo Returns the info of the newest ledger whose sequence number is greater tha...
CountMinMax getLedgerCountMinMax() override
getLedgerCountMinMax Returns the minimum ledger sequence, maximum ledger sequence and total number of...
std::unique_ptr< DatabaseCon > txdb_
MetaTxsList getOldestAccountTxsB(AccountTxOptions const &options) override
getOldestAccountTxsB Returns the oldest transactions in binary form for the account that matches the ...
bool saveValidatedLedger(std::shared_ptr< Ledger const > const &ledger, bool current) override
saveValidatedLedger Saves a ledger into the database.
std::optional< LedgerIndex > getMaxLedgerSeq() override
getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.
std::optional< LedgerIndex > getMinLedgerSeq() override
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
std::uint32_t getKBUsedTransaction() override
getKBUsedTransaction Returns the amount of space used by the transaction database.
std::uint32_t getKBUsedLedger() override
getKBUsedLedger Returns the amount of space space used by the ledger database.
AccountTxs getNewestAccountTxs(AccountTxOptions const &options) override
getNewestAccountTxs Returns the newest transactions for the account that matches the given criteria s...
void deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteAccountTransactionsBeforeLedgerSeq Deletes all account transactions with a sequence number less...
std::optional< LedgerIndex > getAccountTransactionsMinLedgerSeq() override
getAccountTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the AccountTransacti...
std::size_t getAccountTransactionCount() override
getAccountTransactionCount Returns the number of account transactions.
bool existsTransaction()
existsTransaction Checks if the node store transaction database exists.
std::pair< AccountTxs, std::optional< AccountTxMarker > > newestAccountTxPage(AccountTxPageOptions const &options) override
newestAccountTxPage Returns the newest transactions for the account that matches the given criteria s...
std::pair< MetaTxsList, std::optional< AccountTxMarker > > oldestAccountTxPageB(AccountTxPageOptions const &options) override
oldestAccountTxPageB Returns the oldest transactions in binary form for the account that matches the ...
void deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionsBeforeLedgerSeq Deletes all transactions with a sequence number less than or equal ...
std::unique_ptr< DatabaseCon > ledgerDb_
std::optional< LedgerHeader > getLedgerInfoByHash(uint256 const &ledgerHash) override
getLedgerInfoByHash Returns the info of the ledger with given hash.
std::optional< LedgerHeader > getNewestLedgerInfo() override
getNewestLedgerInfo Returns the info of the newest saved ledger.
void deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteBeforeLedgerSeq Deletes all ledgers with a sequence number less than or equal to the given ledg...
std::uint32_t getKBUsedAll() override
getKBUsedAll Returns the amount of space used by all databases.
std::size_t getTransactionCount() override
getTransactionCount Returns the number of transactions.
std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex) override
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
std::optional< LedgerIndex > getTransactionsMinLedgerSeq() override
getTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the Transactions table.
std::pair< AccountTxs, std::optional< AccountTxMarker > > oldestAccountTxPage(AccountTxPageOptions const &options) override
oldestAccountTxPage Returns the oldest transactions for the account that matches the given criteria s...
bool transactionDbHasSpace(Config const &config)
transactionDbHasSpace Checks if the transaction database has available space.
std::pair< MetaTxsList, std::optional< AccountTxMarker > > newestAccountTxPageB(AccountTxPageOptions const &options) override
newestAccountTxPageB Returns the newest transactions in binary form for the account that matches the ...
std::optional< LedgerHeader > getLedgerInfoByIndex(LedgerIndex ledgerSeq) override
getLedgerInfoByIndex Returns a ledger by its sequence.
std::variant< AccountTx, TxSearched > getTransaction(uint256 const &id, std::optional< ClosedInterval< std::uint32_t > > const &range, ErrorCodeI &ec) override
getTransaction Returns the transaction with the given hash.
Service registry for dependency injection.
T data(T... args)
T emplace_back(T... args)
T exchange(T... args)
std::optional< LedgerHeader > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition Node.cpp:519
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 pageLength)
newestAccountTxPage Searches newest transactions for given account which match given criteria startin...
Definition Node.cpp:1176
bool saveValidatedLedger(DatabaseCon &ldgDB, std::unique_ptr< DatabaseCon > const &txnDB, Application &app, std::shared_ptr< Ledger const > const &ledger, bool current)
saveValidatedLedger Saves ledger into database.
Definition Node.cpp:213
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 pageLength)
oldestAccountTxPage Searches oldest transactions for given account which match given criteria startin...
Definition Node.cpp:1165
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:180
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition Node.cpp:154
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition Node.cpp:164
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< 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
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:967
std::optional< LedgerHeader > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition Node.cpp:493
std::optional< LedgerHeader > getLimitedOldestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedOldestLedgerInfo Returns info of oldest ledger from ledgers with sequences greater or equal...
Definition Node.cpp:501
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:98
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:198
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition Node.cpp:186
std::optional< LedgerHeader > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition Node.cpp:485
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:977
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition Node.cpp:527
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:174
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
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition Node.cpp:1263
std::optional< LedgerHeader > getLimitedNewestLedgerInfo(soci::session &session, LedgerIndex ledgerFirstIndex, beast::Journal j)
getLimitedNewestLedgerInfo Returns info of newest ledger from ledgers with sequences greater or equal...
Definition Node.cpp:510
std::variant< RelationalDatabase::AccountTx, TxSearched > getTransaction(soci::session &session, Application &app, uint256 const &id, std::optional< ClosedInterval< uint32_t > > const &range, ErrorCodeI &ec)
getTransaction Returns transaction with given hash.
Definition Node.cpp:1187
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:556
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
void convertBlobsToTxResult(RelationalDatabase::AccountTxs &to, std::uint32_t ledgerIndex, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
void saveLedgerAsync(Application &app, std::uint32_t seq)
ErrorCodeI
Definition ErrorCodes.h:22
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:259
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition RangeSet.h:34
std::uint32_t getKBUsedDB(soci::session &s)
Definition SociDB.cpp:133
std::uint32_t getKBUsedAll(soci::session &s)
Definition SociDB.cpp:125
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
Definition RangeSet.h:25
DatabaseCon::Setup setupDatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
Definition Config.cpp:1219
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:10
SQLiteDatabase setupRelationalDatabase(ServiceRegistry &registry, Config const &config, JobQueue &jobQueue)
setupRelationalDatabase Creates and returns a SQLiteDatabase instance based on configuration.
BaseUInt< 256 > uint256
Definition base_uint.h:562
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:49
T ref(T... args)