rippled
Loading...
Searching...
No Matches
SQLiteDatabase.cpp
1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/ledger/TransactionMaster.h>
3#include <xrpld/app/misc/detail/AccountTxPaging.h>
4#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
5#include <xrpld/app/rdb/backend/detail/Node.h>
6#include <xrpld/core/DatabaseCon.h>
7#include <xrpld/core/SociDB.h>
8
9#include <xrpl/basics/StringUtilities.h>
10
11namespace ripple {
12
14{
15public:
17 Application& app,
18 Config const& config,
19 JobQueue& jobQueue)
20 : app_(app)
21 , useTxTables_(config.useTxTables())
22 , j_(app_.journal("SQLiteDatabaseImp"))
23 {
24 DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_);
25 if (!makeLedgerDBs(
26 config,
27 setup,
29 {
30 std::string_view constexpr error =
31 "Failed to create ledger databases";
32
33 JLOG(j_.fatal()) << error;
34 Throw<std::runtime_error>(error.data());
35 }
36 }
37
39 getMinLedgerSeq() override;
40
43
46
48 getMaxLedgerSeq() override;
49
50 void
51 deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override;
52
53 void
54 deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override;
55
56 void
58
59 void
61
63 getTransactionCount() override;
64
67
69 getLedgerCountMinMax() override;
70
71 bool
74 bool current) override;
75
77 getLedgerInfoByIndex(LedgerIndex ledgerSeq) override;
78
80 getNewestLedgerInfo() override;
81
83 getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
84
86 getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
87
89 getLedgerInfoByHash(uint256 const& ledgerHash) override;
90
92 getHashByIndex(LedgerIndex ledgerIndex) override;
93
95 getHashesByIndex(LedgerIndex ledgerIndex) override;
96
98 getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override;
99
101 getTxHistory(LedgerIndex startIndex) override;
102
104 getOldestAccountTxs(AccountTxOptions const& options) override;
105
107 getNewestAccountTxs(AccountTxOptions const& options) override;
108
110 getOldestAccountTxsB(AccountTxOptions const& options) override;
111
113 getNewestAccountTxsB(AccountTxOptions const& options) override;
114
116 oldestAccountTxPage(AccountTxPageOptions const& options) override;
117
119 newestAccountTxPage(AccountTxPageOptions const& options) override;
120
122 oldestAccountTxPageB(AccountTxPageOptions const& options) override;
123
125 newestAccountTxPageB(AccountTxPageOptions const& options) override;
126
129 uint256 const& id,
131 error_code_i& ec) override;
132
133 bool
134 ledgerDbHasSpace(Config const& config) override;
135
136 bool
137 transactionDbHasSpace(Config const& config) override;
138
140 getKBUsedAll() override;
141
143 getKBUsedLedger() override;
144
146 getKBUsedTransaction() override;
147
148 void
149 closeLedgerDB() override;
150
151 void
152 closeTransactionDB() override;
153
154private:
156 bool const useTxTables_;
159
168 bool
170 Config const& config,
171 DatabaseCon::Setup const& setup,
172 DatabaseCon::CheckpointerSetup const& checkpointerSetup);
173
178 bool
180 {
181 return static_cast<bool>(lgrdb_);
182 }
183
189 bool
191 {
192 return static_cast<bool>(txdb_);
193 }
194
200 auto
202 {
203 return lgrdb_->checkoutDb();
204 }
205
211 auto
213 {
214 return txdb_->checkoutDb();
215 }
216};
217
218bool
220 Config const& config,
221 DatabaseCon::Setup const& setup,
222 DatabaseCon::CheckpointerSetup const& checkpointerSetup)
223{
224 auto [lgr, tx, res] =
225 detail::makeLedgerDBs(config, setup, checkpointerSetup, j_);
226 txdb_ = std::move(tx);
227 lgrdb_ = std::move(lgr);
228 return res;
229}
230
233{
234 /* if databases exists, use it */
235 if (existsLedger())
236 {
237 auto db = checkoutLedger();
239 }
240
241 /* else return empty value */
242 return {};
243}
244
247{
248 if (!useTxTables_)
249 return {};
250
251 if (existsTransaction())
252 {
253 auto db = checkoutTransaction();
255 }
256
257 return {};
258}
259
262{
263 if (!useTxTables_)
264 return {};
265
266 if (existsTransaction())
267 {
268 auto db = checkoutTransaction();
271 }
272
273 return {};
274}
275
278{
279 if (existsLedger())
280 {
281 auto db = checkoutLedger();
283 }
284
285 return {};
286}
287
288void
290{
291 if (!useTxTables_)
292 return;
293
294 if (existsTransaction())
295 {
296 auto db = checkoutTransaction();
298 *db, detail::TableType::Transactions, ledgerSeq);
299 return;
300 }
301}
302
303void
305{
306 if (existsLedger())
307 {
308 auto db = checkoutLedger();
310 *db, detail::TableType::Ledgers, ledgerSeq);
311 return;
312 }
313}
314
315void
317{
318 if (!useTxTables_)
319 return;
320
321 if (existsTransaction())
322 {
323 auto db = checkoutTransaction();
325 *db, detail::TableType::Transactions, ledgerSeq);
326 return;
327 }
328}
329
330void
332 LedgerIndex ledgerSeq)
333{
334 if (!useTxTables_)
335 return;
336
337 if (existsTransaction())
338 {
339 auto db = checkoutTransaction();
342 return;
343 }
344}
345
348{
349 if (!useTxTables_)
350 return 0;
351
352 if (existsTransaction())
353 {
354 auto db = checkoutTransaction();
356 }
357
358 return 0;
359}
360
363{
364 if (!useTxTables_)
365 return 0;
366
367 if (existsTransaction())
368 {
369 auto db = checkoutTransaction();
371 }
372
373 return 0;
374}
375
378{
379 if (existsLedger())
380 {
381 auto db = checkoutLedger();
383 }
384
385 return {0, 0, 0};
386}
387
388bool
390 std::shared_ptr<Ledger const> const& ledger,
391 bool current)
392{
393 if (existsLedger())
394 {
396 return false;
397 }
398
399 return true;
400}
401
404{
405 if (existsLedger())
406 {
407 auto db = checkoutLedger();
408 auto const res = detail::getLedgerInfoByIndex(*db, ledgerSeq, j_);
409
410 if (res.has_value())
411 return res;
412 }
413
414 return {};
415}
416
419{
420 if (existsLedger())
421 {
422 auto db = checkoutLedger();
423 auto const res = detail::getNewestLedgerInfo(*db, j_);
424
425 if (res.has_value())
426 return res;
427 }
428
429 return {};
430}
431
434{
435 if (existsLedger())
436 {
437 auto db = checkoutLedger();
438 auto const res =
439 detail::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
440
441 if (res.has_value())
442 return res;
443 }
444
445 return {};
446}
447
450{
451 if (existsLedger())
452 {
453 auto db = checkoutLedger();
454 auto const res =
455 detail::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
456
457 if (res.has_value())
458 return res;
459 }
460
461 return {};
462}
463
466{
467 if (existsLedger())
468 {
469 auto db = checkoutLedger();
470 auto const res = detail::getLedgerInfoByHash(*db, ledgerHash, j_);
471
472 if (res.has_value())
473 return res;
474 }
475
476 return {};
477}
478
481{
482 if (existsLedger())
483 {
484 auto db = checkoutLedger();
485 auto const res = detail::getHashByIndex(*db, ledgerIndex);
486
487 if (res.isNonZero())
488 return res;
489 }
490
491 return uint256();
492}
493
496{
497 if (existsLedger())
498 {
499 auto db = checkoutLedger();
500 auto const res = detail::getHashesByIndex(*db, ledgerIndex, j_);
501
502 if (res.has_value())
503 return res;
504 }
505
506 return {};
507}
508
511{
512 if (existsLedger())
513 {
514 auto db = checkoutLedger();
515 auto const res = detail::getHashesByIndex(*db, minSeq, maxSeq, j_);
516
517 if (!res.empty())
518 return res;
519 }
520
521 return {};
522}
523
526{
527 if (!useTxTables_)
528 return {};
529
530 if (existsTransaction())
531 {
532 auto db = checkoutTransaction();
533 auto const res = detail::getTxHistory(*db, app_, startIndex, 20).first;
534
535 if (!res.empty())
536 return res;
537 }
538
539 return {};
540}
541
544{
545 if (!useTxTables_)
546 return {};
547
549
550 if (existsTransaction())
551 {
552 auto db = checkoutTransaction();
553 return detail::getOldestAccountTxs(*db, app_, ledgerMaster, options, j_)
554 .first;
555 }
556
557 return {};
558}
559
562{
563 if (!useTxTables_)
564 return {};
565
567
568 if (existsTransaction())
569 {
570 auto db = checkoutTransaction();
571 return detail::getNewestAccountTxs(*db, app_, ledgerMaster, options, j_)
572 .first;
573 }
574
575 return {};
576}
577
580{
581 if (!useTxTables_)
582 return {};
583
584 if (existsTransaction())
585 {
586 auto db = checkoutTransaction();
587 return detail::getOldestAccountTxsB(*db, app_, options, j_).first;
588 }
589
590 return {};
591}
592
595{
596 if (!useTxTables_)
597 return {};
598
599 if (existsTransaction())
600 {
601 auto db = checkoutTransaction();
602 return detail::getNewestAccountTxsB(*db, app_, options, j_).first;
603 }
604
605 return {};
606}
607
612{
613 if (!useTxTables_)
614 return {};
615
616 static std::uint32_t const page_length(200);
617 auto onUnsavedLedger =
618 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
619 AccountTxs ret;
620 Application& app = app_;
621 auto onTransaction = [&ret, &app](
622 std::uint32_t ledger_index,
623 std::string const& status,
624 Blob&& rawTxn,
625 Blob&& rawMeta) {
626 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
627 };
628
629 if (existsTransaction())
630 {
631 auto db = checkoutTransaction();
632 auto newmarker =
634 *db, onUnsavedLedger, onTransaction, options, page_length)
635 .first;
636 return {ret, newmarker};
637 }
638
639 return {};
640}
641
646{
647 if (!useTxTables_)
648 return {};
649
650 static std::uint32_t const page_length(200);
651 auto onUnsavedLedger =
652 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
653 AccountTxs ret;
654 Application& app = app_;
655 auto onTransaction = [&ret, &app](
656 std::uint32_t ledger_index,
657 std::string const& status,
658 Blob&& rawTxn,
659 Blob&& rawMeta) {
660 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
661 };
662
663 if (existsTransaction())
664 {
665 auto db = checkoutTransaction();
666 auto newmarker =
668 *db, onUnsavedLedger, onTransaction, options, page_length)
669 .first;
670 return {ret, newmarker};
671 }
672
673 return {};
674}
675
680{
681 if (!useTxTables_)
682 return {};
683
684 static std::uint32_t const page_length(500);
685 auto onUnsavedLedger =
686 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
687 MetaTxsList ret;
688 auto onTransaction = [&ret](
689 std::uint32_t ledgerIndex,
690 std::string const& status,
691 Blob&& rawTxn,
692 Blob&& rawMeta) {
693 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
694 };
695
696 if (existsTransaction())
697 {
698 auto db = checkoutTransaction();
699 auto newmarker =
701 *db, onUnsavedLedger, onTransaction, options, page_length)
702 .first;
703 return {ret, newmarker};
704 }
705
706 return {};
707}
708
713{
714 if (!useTxTables_)
715 return {};
716
717 static std::uint32_t const page_length(500);
718 auto onUnsavedLedger =
719 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
720 MetaTxsList ret;
721 auto onTransaction = [&ret](
722 std::uint32_t ledgerIndex,
723 std::string const& status,
724 Blob&& rawTxn,
725 Blob&& rawMeta) {
726 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
727 };
728
729 if (existsTransaction())
730 {
731 auto db = checkoutTransaction();
732 auto newmarker =
734 *db, onUnsavedLedger, onTransaction, options, page_length)
735 .first;
736 return {ret, newmarker};
737 }
738
739 return {};
740}
741
744 uint256 const& id,
746 error_code_i& ec)
747{
748 if (!useTxTables_)
749 return TxSearched::unknown;
750
751 if (existsTransaction())
752 {
753 auto db = checkoutTransaction();
754 return detail::getTransaction(*db, app_, id, range, ec);
755 }
756
757 return TxSearched::unknown;
758}
759
760bool
762{
763 if (existsLedger())
764 {
765 auto db = checkoutLedger();
766 return detail::dbHasSpace(*db, config, j_);
767 }
768
769 return true;
770}
771
772bool
774{
775 if (!useTxTables_)
776 return true;
777
778 if (existsTransaction())
779 {
780 auto db = checkoutTransaction();
781 return detail::dbHasSpace(*db, config, j_);
782 }
783
784 return true;
785}
786
789{
790 if (existsLedger())
791 {
792 return ripple::getKBUsedAll(lgrdb_->getSession());
793 }
794
795 return 0;
796}
797
800{
801 if (existsLedger())
802 {
803 return ripple::getKBUsedDB(lgrdb_->getSession());
804 }
805
806 return 0;
807}
808
811{
812 if (!useTxTables_)
813 return 0;
814
815 if (existsTransaction())
816 {
817 return ripple::getKBUsedDB(txdb_->getSession());
818 }
819
820 return 0;
821}
822
823void
828
829void
834
836getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue)
837{
838 return std::make_unique<SQLiteDatabaseImp>(app, config, jobQueue);
839}
840
841} // namespace ripple
T bind(T... args)
A generic endpoint for log messages.
Definition Journal.h:41
Stream fatal() const
Definition Journal.h:333
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & logs()=0
A pool of threads to perform work.
Definition JobQueue.h:39
std::vector< txnMetaLedgerType > MetaTxsList
std::vector< AccountTx > AccountTxs
bool transactionDbHasSpace(Config const &config) override
transactionDbHasSpace Checks if the transaction database has available space.
AccountTxs getOldestAccountTxs(AccountTxOptions const &options) override
getOldestAccountTxs Returns the oldest transactions for the account that matches the given criteria s...
std::optional< LedgerInfo > getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedOldestLedgerInfo Returns the info of the oldest ledger whose sequence number is greater tha...
std::unique_ptr< DatabaseCon > txdb_
std::uint32_t getKBUsedLedger() override
getKBUsedLedger Returns the amount of space space used by the ledger database.
void deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionByLedgerSeq Deletes transactions from the ledger with the given sequence.
std::optional< LedgerInfo > getNewestLedgerInfo() override
getNewestLedgerInfo Returns the info of the newest saved ledger.
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...
std::optional< LedgerIndex > getMaxLedgerSeq() override
getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.
std::unique_ptr< DatabaseCon > lgrdb_
std::uint32_t getKBUsedTransaction() override
getKBUsedTransaction Returns the amount of space used by the transaction database.
auto checkoutLedger()
checkoutTransaction Checks out and returns node store ledger database.
bool saveValidatedLedger(std::shared_ptr< Ledger const > const &ledger, bool current) override
saveValidatedLedger Saves a ledger into the database.
bool ledgerDbHasSpace(Config const &config) override
ledgerDbHasSpace Checks if the ledger database has available space.
std::size_t getTransactionCount() override
getTransactionCount Returns the number of transactions.
MetaTxsList getOldestAccountTxsB(AccountTxOptions const &options) override
getOldestAccountTxsB Returns the oldest transactions in binary form for the account that matches the ...
auto checkoutTransaction()
checkoutTransaction Checks out and returns the node store transaction database.
std::optional< LedgerIndex > getAccountTransactionsMinLedgerSeq() override
getAccountTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the AccountTransacti...
std::optional< LedgerInfo > getLedgerInfoByHash(uint256 const &ledgerHash) override
getLedgerInfoByHash Returns the info of the ledger with given hash.
void deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteBeforeLedgerSeq Deletes all ledgers with a sequence number less than or equal to the given ledg...
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::optional< LedgerIndex > getMinLedgerSeq() override
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
std::optional< LedgerInfo > getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedNewestLedgerInfo Returns the info of the newest ledger whose sequence number is greater tha...
std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex) override
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex) override
getTxHistory Returns the 20 most recent transactions starting from the given number.
void deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteAccountTransactionsBeforeLedgerSeq Deletes all account transactions with a sequence number less...
void closeTransactionDB() override
Closes the transaction database.
RelationalDatabase::CountMinMax getLedgerCountMinMax() override
getLedgerCountMinMax Returns the minimum ledger sequence, maximum ledger sequence and total number of...
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 ...
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::variant< AccountTx, TxSearched > getTransaction(uint256 const &id, std::optional< ClosedInterval< std::uint32_t > > const &range, error_code_i &ec) override
uint256 getHashByIndex(LedgerIndex ledgerIndex) override
getHashByIndex Returns the hash of the ledger with the given sequence.
void closeLedgerDB() override
Closes the ledger database.
void deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionsBeforeLedgerSeq Deletes all transactions with a sequence number less than or equal ...
MetaTxsList getNewestAccountTxsB(AccountTxOptions const &options) override
getNewestAccountTxsB Returns the newest transactions in binary form for the account that matches the ...
bool existsLedger()
existsLedger Checks if the node store ledger database exists.
std::optional< LedgerIndex > getTransactionsMinLedgerSeq() override
getTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the Transactions table.
std::uint32_t getKBUsedAll() override
getKBUsedAll Returns the amount of space used by all databases.
AccountTxs getNewestAccountTxs(AccountTxOptions const &options) override
getNewestAccountTxs Returns the newest transactions for the account that matches the given criteria s...
std::optional< LedgerInfo > getLedgerInfoByIndex(LedgerIndex ledgerSeq) override
getLedgerInfoByIndex Returns a ledger by its sequence.
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 ...
SQLiteDatabaseImp(Application &app, Config const &config, JobQueue &jobQueue)
T emplace_back(T... args)
T is_same_v
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:157
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:51
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:128
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition Node.cpp:145
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:135
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
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:172
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:108
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:118
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:6
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
std::uint32_t getKBUsedAll(soci::session &s)
Definition SociDB.cpp:114
base_uint< 256 > uint256
Definition base_uint.h:539
void saveLedgerAsync(Application &app, std::uint32_t seq)
std::uint32_t getKBUsedDB(soci::session &s)
Definition SociDB.cpp:123
@ current
This was a new validation and was added.
std::unique_ptr< RelationalDatabase > getSQLiteDatabase(Application &app, Config const &config, JobQueue &jobQueue)
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
Definition RangeSet.h:26
void convertBlobsToTxResult(RelationalDatabase::AccountTxs &to, std::uint32_t ledger_index, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition RangeSet.h:35
@ ledgerMaster
ledger master data for signing
T ref(T... args)