rippled
Loading...
Searching...
No Matches
SQLiteDatabase.cpp
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#include <xrpld/app/ledger/LedgerMaster.h>
21#include <xrpld/app/ledger/TransactionMaster.h>
22#include <xrpld/app/misc/detail/AccountTxPaging.h>
23#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
24#include <xrpld/app/rdb/backend/detail/Node.h>
25#include <xrpld/core/DatabaseCon.h>
26#include <xrpld/core/SociDB.h>
27#include <xrpl/basics/StringUtilities.h>
28
29namespace ripple {
30
32{
33public:
35 Application& app,
36 Config const& config,
37 JobQueue& jobQueue)
38 : app_(app)
39 , useTxTables_(config.useTxTables())
40 , j_(app_.journal("SQLiteDatabaseImp"))
41 {
42 DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_);
43 if (!makeLedgerDBs(
44 config,
45 setup,
47 {
48 std::string_view constexpr error =
49 "Failed to create ledger databases";
50
51 JLOG(j_.fatal()) << error;
52 Throw<std::runtime_error>(error.data());
53 }
54 }
55
57 getMinLedgerSeq() override;
58
61
64
66 getMaxLedgerSeq() override;
67
68 void
69 deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override;
70
71 void
72 deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override;
73
74 void
76
77 void
79
81 getTransactionCount() override;
82
85
87 getLedgerCountMinMax() override;
88
89 bool
92 bool current) override;
93
95 getLedgerInfoByIndex(LedgerIndex ledgerSeq) override;
96
98 getNewestLedgerInfo() override;
99
101 getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
102
104 getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
105
107 getLedgerInfoByHash(uint256 const& ledgerHash) override;
108
109 uint256
110 getHashByIndex(LedgerIndex ledgerIndex) override;
111
113 getHashesByIndex(LedgerIndex ledgerIndex) override;
114
116 getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override;
117
119 getTxHistory(LedgerIndex startIndex) override;
120
122 getOldestAccountTxs(AccountTxOptions const& options) override;
123
125 getNewestAccountTxs(AccountTxOptions const& options) override;
126
128 getOldestAccountTxsB(AccountTxOptions const& options) override;
129
131 getNewestAccountTxsB(AccountTxOptions const& options) override;
132
134 oldestAccountTxPage(AccountTxPageOptions const& options) override;
135
137 newestAccountTxPage(AccountTxPageOptions const& options) override;
138
140 oldestAccountTxPageB(AccountTxPageOptions const& options) override;
141
143 newestAccountTxPageB(AccountTxPageOptions const& options) override;
144
147 uint256 const& id,
149 error_code_i& ec) override;
150
151 bool
152 ledgerDbHasSpace(Config const& config) override;
153
154 bool
155 transactionDbHasSpace(Config const& config) override;
156
158 getKBUsedAll() override;
159
161 getKBUsedLedger() override;
162
164 getKBUsedTransaction() override;
165
166 void
167 closeLedgerDB() override;
168
169 void
170 closeTransactionDB() override;
171
172private:
174 bool const useTxTables_;
177
186 bool
188 Config const& config,
189 DatabaseCon::Setup const& setup,
190 DatabaseCon::CheckpointerSetup const& checkpointerSetup);
191
196 bool
198 {
199 return static_cast<bool>(lgrdb_);
200 }
201
207 bool
209 {
210 return static_cast<bool>(txdb_);
211 }
212
218 auto
220 {
221 return lgrdb_->checkoutDb();
222 }
223
229 auto
231 {
232 return txdb_->checkoutDb();
233 }
234};
235
236bool
238 Config const& config,
239 DatabaseCon::Setup const& setup,
240 DatabaseCon::CheckpointerSetup const& checkpointerSetup)
241{
242 auto [lgr, tx, res] =
243 detail::makeLedgerDBs(config, setup, checkpointerSetup, j_);
244 txdb_ = std::move(tx);
245 lgrdb_ = std::move(lgr);
246 return res;
247}
248
251{
252 /* if databases exists, use it */
253 if (existsLedger())
254 {
255 auto db = checkoutLedger();
257 }
258
259 /* else return empty value */
260 return {};
261}
262
265{
266 if (!useTxTables_)
267 return {};
268
269 if (existsTransaction())
270 {
271 auto db = checkoutTransaction();
273 }
274
275 return {};
276}
277
280{
281 if (!useTxTables_)
282 return {};
283
284 if (existsTransaction())
285 {
286 auto db = checkoutTransaction();
289 }
290
291 return {};
292}
293
296{
297 if (existsLedger())
298 {
299 auto db = checkoutLedger();
301 }
302
303 return {};
304}
305
306void
308{
309 if (!useTxTables_)
310 return;
311
312 if (existsTransaction())
313 {
314 auto db = checkoutTransaction();
316 *db, detail::TableType::Transactions, ledgerSeq);
317 return;
318 }
319}
320
321void
323{
324 if (existsLedger())
325 {
326 auto db = checkoutLedger();
328 *db, detail::TableType::Ledgers, ledgerSeq);
329 return;
330 }
331}
332
333void
335{
336 if (!useTxTables_)
337 return;
338
339 if (existsTransaction())
340 {
341 auto db = checkoutTransaction();
343 *db, detail::TableType::Transactions, ledgerSeq);
344 return;
345 }
346}
347
348void
350 LedgerIndex ledgerSeq)
351{
352 if (!useTxTables_)
353 return;
354
355 if (existsTransaction())
356 {
357 auto db = checkoutTransaction();
360 return;
361 }
362}
363
366{
367 if (!useTxTables_)
368 return 0;
369
370 if (existsTransaction())
371 {
372 auto db = checkoutTransaction();
374 }
375
376 return 0;
377}
378
381{
382 if (!useTxTables_)
383 return 0;
384
385 if (existsTransaction())
386 {
387 auto db = checkoutTransaction();
389 }
390
391 return 0;
392}
393
396{
397 if (existsLedger())
398 {
399 auto db = checkoutLedger();
401 }
402
403 return {0, 0, 0};
404}
405
406bool
408 std::shared_ptr<Ledger const> const& ledger,
409 bool current)
410{
411 if (existsLedger())
412 {
414 *lgrdb_, *txdb_, app_, ledger, current))
415 return false;
416 }
417
418 return true;
419}
420
423{
424 if (existsLedger())
425 {
426 auto db = checkoutLedger();
427 auto const res = detail::getLedgerInfoByIndex(*db, ledgerSeq, j_);
428
429 if (res.has_value())
430 return res;
431 }
432
433 return {};
434}
435
438{
439 if (existsLedger())
440 {
441 auto db = checkoutLedger();
442 auto const res = detail::getNewestLedgerInfo(*db, j_);
443
444 if (res.has_value())
445 return res;
446 }
447
448 return {};
449}
450
453{
454 if (existsLedger())
455 {
456 auto db = checkoutLedger();
457 auto const res =
458 detail::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
459
460 if (res.has_value())
461 return res;
462 }
463
464 return {};
465}
466
469{
470 if (existsLedger())
471 {
472 auto db = checkoutLedger();
473 auto const res =
474 detail::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
475
476 if (res.has_value())
477 return res;
478 }
479
480 return {};
481}
482
485{
486 if (existsLedger())
487 {
488 auto db = checkoutLedger();
489 auto const res = detail::getLedgerInfoByHash(*db, ledgerHash, j_);
490
491 if (res.has_value())
492 return res;
493 }
494
495 return {};
496}
497
500{
501 if (existsLedger())
502 {
503 auto db = checkoutLedger();
504 auto const res = detail::getHashByIndex(*db, ledgerIndex);
505
506 if (res.isNonZero())
507 return res;
508 }
509
510 return uint256();
511}
512
515{
516 if (existsLedger())
517 {
518 auto db = checkoutLedger();
519 auto const res = detail::getHashesByIndex(*db, ledgerIndex, j_);
520
521 if (res.has_value())
522 return res;
523 }
524
525 return {};
526}
527
530{
531 if (existsLedger())
532 {
533 auto db = checkoutLedger();
534 auto const res = detail::getHashesByIndex(*db, minSeq, maxSeq, j_);
535
536 if (!res.empty())
537 return res;
538 }
539
540 return {};
541}
542
545{
546 if (!useTxTables_)
547 return {};
548
549 if (existsTransaction())
550 {
551 auto db = checkoutTransaction();
552 auto const res = detail::getTxHistory(*db, app_, startIndex, 20).first;
553
554 if (!res.empty())
555 return res;
556 }
557
558 return {};
559}
560
563{
564 if (!useTxTables_)
565 return {};
566
568
569 if (existsTransaction())
570 {
571 auto db = checkoutTransaction();
572 return detail::getOldestAccountTxs(*db, app_, ledgerMaster, options, j_)
573 .first;
574 }
575
576 return {};
577}
578
581{
582 if (!useTxTables_)
583 return {};
584
586
587 if (existsTransaction())
588 {
589 auto db = checkoutTransaction();
590 return detail::getNewestAccountTxs(*db, app_, ledgerMaster, options, j_)
591 .first;
592 }
593
594 return {};
595}
596
599{
600 if (!useTxTables_)
601 return {};
602
603 if (existsTransaction())
604 {
605 auto db = checkoutTransaction();
606 return detail::getOldestAccountTxsB(*db, app_, options, j_).first;
607 }
608
609 return {};
610}
611
614{
615 if (!useTxTables_)
616 return {};
617
618 if (existsTransaction())
619 {
620 auto db = checkoutTransaction();
621 return detail::getNewestAccountTxsB(*db, app_, options, j_).first;
622 }
623
624 return {};
625}
626
631{
632 if (!useTxTables_)
633 return {};
634
635 static std::uint32_t const page_length(200);
636 auto onUnsavedLedger =
637 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
638 AccountTxs ret;
639 Application& app = app_;
640 auto onTransaction = [&ret, &app](
641 std::uint32_t ledger_index,
642 std::string const& status,
643 Blob&& rawTxn,
644 Blob&& rawMeta) {
645 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
646 };
647
648 if (existsTransaction())
649 {
650 auto db = checkoutTransaction();
651 auto newmarker =
653 *db, onUnsavedLedger, onTransaction, options, page_length)
654 .first;
655 return {ret, newmarker};
656 }
657
658 return {};
659}
660
665{
666 if (!useTxTables_)
667 return {};
668
669 static std::uint32_t const page_length(200);
670 auto onUnsavedLedger =
671 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
672 AccountTxs ret;
673 Application& app = app_;
674 auto onTransaction = [&ret, &app](
675 std::uint32_t ledger_index,
676 std::string const& status,
677 Blob&& rawTxn,
678 Blob&& rawMeta) {
679 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
680 };
681
682 if (existsTransaction())
683 {
684 auto db = checkoutTransaction();
685 auto newmarker =
687 *db, onUnsavedLedger, onTransaction, options, page_length)
688 .first;
689 return {ret, newmarker};
690 }
691
692 return {};
693}
694
699{
700 if (!useTxTables_)
701 return {};
702
703 static std::uint32_t const page_length(500);
704 auto onUnsavedLedger =
705 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
706 MetaTxsList ret;
707 auto onTransaction = [&ret](
708 std::uint32_t ledgerIndex,
709 std::string const& status,
710 Blob&& rawTxn,
711 Blob&& rawMeta) {
712 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
713 };
714
715 if (existsTransaction())
716 {
717 auto db = checkoutTransaction();
718 auto newmarker =
720 *db, onUnsavedLedger, onTransaction, options, page_length)
721 .first;
722 return {ret, newmarker};
723 }
724
725 return {};
726}
727
732{
733 if (!useTxTables_)
734 return {};
735
736 static std::uint32_t const page_length(500);
737 auto onUnsavedLedger =
738 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
739 MetaTxsList ret;
740 auto onTransaction = [&ret](
741 std::uint32_t ledgerIndex,
742 std::string const& status,
743 Blob&& rawTxn,
744 Blob&& rawMeta) {
745 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
746 };
747
748 if (existsTransaction())
749 {
750 auto db = checkoutTransaction();
751 auto newmarker =
753 *db, onUnsavedLedger, onTransaction, options, page_length)
754 .first;
755 return {ret, newmarker};
756 }
757
758 return {};
759}
760
763 uint256 const& id,
765 error_code_i& ec)
766{
767 if (!useTxTables_)
768 return TxSearched::unknown;
769
770 if (existsTransaction())
771 {
772 auto db = checkoutTransaction();
773 return detail::getTransaction(*db, app_, id, range, ec);
774 }
775
776 return TxSearched::unknown;
777}
778
779bool
781{
782 if (existsLedger())
783 {
784 auto db = checkoutLedger();
785 return detail::dbHasSpace(*db, config, j_);
786 }
787
788 return true;
789}
790
791bool
793{
794 if (!useTxTables_)
795 return true;
796
797 if (existsTransaction())
798 {
799 auto db = checkoutTransaction();
800 return detail::dbHasSpace(*db, config, j_);
801 }
802
803 return true;
804}
805
808{
809 if (existsLedger())
810 {
811 return ripple::getKBUsedAll(lgrdb_->getSession());
812 }
813
814 return 0;
815}
816
819{
820 if (existsLedger())
821 {
822 return ripple::getKBUsedDB(lgrdb_->getSession());
823 }
824
825 return 0;
826}
827
830{
831 if (!useTxTables_)
832 return 0;
833
834 if (existsTransaction())
835 {
836 return ripple::getKBUsedDB(txdb_->getSession());
837 }
838
839 return 0;
840}
841
842void
844{
845 lgrdb_.reset();
846}
847
848void
850{
851 txdb_.reset();
852}
853
855getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue)
856{
857 return std::make_unique<SQLiteDatabaseImp>(app, config, jobQueue);
858}
859
860} // namespace ripple
T bind(T... args)
A generic endpoint for log messages.
Definition: Journal.h:60
Stream fatal() const
Definition: Journal.h:352
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & logs()=0
A pool of threads to perform work.
Definition: JobQueue.h:55
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)
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:172
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition: Node.cpp:513
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:490
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:1169
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition: Node.cpp:470
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:1155
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:66
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:143
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition: Node.cpp:160
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:150
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:187
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:862
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:619
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:478
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:962
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition: Node.cpp:459
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition: Node.cpp:1264
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition: Node.cpp:502
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition: Node.cpp:123
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:873
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:972
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:543
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition: Node.cpp:133
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:1183
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
std::uint32_t getKBUsedAll(soci::session &s)
Definition: SociDB.cpp:131
error_code_i
Definition: ErrorCodes.h:40
base_uint< 256 > uint256
Definition: base_uint.h:558
void saveLedgerAsync(Application &app, std::uint32_t seq)
std::uint32_t getKBUsedDB(soci::session &s)
Definition: SociDB.cpp:140
@ 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:45
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:54
@ ledgerMaster
ledger master data for signing
T ref(T... args)