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
28#include <xrpl/basics/StringUtilities.h>
29
30namespace ripple {
31
33{
34public:
36 Application& app,
37 Config const& config,
38 JobQueue& jobQueue)
39 : app_(app)
40 , useTxTables_(config.useTxTables())
41 , j_(app_.journal("SQLiteDatabaseImp"))
42 {
43 DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_);
44 if (!makeLedgerDBs(
45 config,
46 setup,
48 {
49 std::string_view constexpr error =
50 "Failed to create ledger databases";
51
52 JLOG(j_.fatal()) << error;
53 Throw<std::runtime_error>(error.data());
54 }
55 }
56
58 getMinLedgerSeq() override;
59
62
65
67 getMaxLedgerSeq() override;
68
69 void
70 deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override;
71
72 void
73 deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override;
74
75 void
77
78 void
80
82 getTransactionCount() override;
83
86
88 getLedgerCountMinMax() override;
89
90 bool
93 bool current) override;
94
96 getLedgerInfoByIndex(LedgerIndex ledgerSeq) override;
97
99 getNewestLedgerInfo() override;
100
102 getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
103
105 getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
106
108 getLedgerInfoByHash(uint256 const& ledgerHash) override;
109
110 uint256
111 getHashByIndex(LedgerIndex ledgerIndex) override;
112
114 getHashesByIndex(LedgerIndex ledgerIndex) override;
115
117 getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override;
118
120 getTxHistory(LedgerIndex startIndex) override;
121
123 getOldestAccountTxs(AccountTxOptions const& options) override;
124
126 getNewestAccountTxs(AccountTxOptions const& options) override;
127
129 getOldestAccountTxsB(AccountTxOptions const& options) override;
130
132 getNewestAccountTxsB(AccountTxOptions const& options) override;
133
135 oldestAccountTxPage(AccountTxPageOptions const& options) override;
136
138 newestAccountTxPage(AccountTxPageOptions const& options) override;
139
141 oldestAccountTxPageB(AccountTxPageOptions const& options) override;
142
144 newestAccountTxPageB(AccountTxPageOptions const& options) override;
145
148 uint256 const& id,
150 error_code_i& ec) override;
151
152 bool
153 ledgerDbHasSpace(Config const& config) override;
154
155 bool
156 transactionDbHasSpace(Config const& config) override;
157
159 getKBUsedAll() override;
160
162 getKBUsedLedger() override;
163
165 getKBUsedTransaction() override;
166
167 void
168 closeLedgerDB() override;
169
170 void
171 closeTransactionDB() override;
172
173private:
175 bool const useTxTables_;
178
187 bool
189 Config const& config,
190 DatabaseCon::Setup const& setup,
191 DatabaseCon::CheckpointerSetup const& checkpointerSetup);
192
197 bool
199 {
200 return static_cast<bool>(lgrdb_);
201 }
202
208 bool
210 {
211 return static_cast<bool>(txdb_);
212 }
213
219 auto
221 {
222 return lgrdb_->checkoutDb();
223 }
224
230 auto
232 {
233 return txdb_->checkoutDb();
234 }
235};
236
237bool
239 Config const& config,
240 DatabaseCon::Setup const& setup,
241 DatabaseCon::CheckpointerSetup const& checkpointerSetup)
242{
243 auto [lgr, tx, res] =
244 detail::makeLedgerDBs(config, setup, checkpointerSetup, j_);
245 txdb_ = std::move(tx);
246 lgrdb_ = std::move(lgr);
247 return res;
248}
249
252{
253 /* if databases exists, use it */
254 if (existsLedger())
255 {
256 auto db = checkoutLedger();
258 }
259
260 /* else return empty value */
261 return {};
262}
263
266{
267 if (!useTxTables_)
268 return {};
269
270 if (existsTransaction())
271 {
272 auto db = checkoutTransaction();
274 }
275
276 return {};
277}
278
281{
282 if (!useTxTables_)
283 return {};
284
285 if (existsTransaction())
286 {
287 auto db = checkoutTransaction();
290 }
291
292 return {};
293}
294
297{
298 if (existsLedger())
299 {
300 auto db = checkoutLedger();
302 }
303
304 return {};
305}
306
307void
309{
310 if (!useTxTables_)
311 return;
312
313 if (existsTransaction())
314 {
315 auto db = checkoutTransaction();
317 *db, detail::TableType::Transactions, ledgerSeq);
318 return;
319 }
320}
321
322void
324{
325 if (existsLedger())
326 {
327 auto db = checkoutLedger();
329 *db, detail::TableType::Ledgers, ledgerSeq);
330 return;
331 }
332}
333
334void
336{
337 if (!useTxTables_)
338 return;
339
340 if (existsTransaction())
341 {
342 auto db = checkoutTransaction();
344 *db, detail::TableType::Transactions, ledgerSeq);
345 return;
346 }
347}
348
349void
351 LedgerIndex ledgerSeq)
352{
353 if (!useTxTables_)
354 return;
355
356 if (existsTransaction())
357 {
358 auto db = checkoutTransaction();
361 return;
362 }
363}
364
367{
368 if (!useTxTables_)
369 return 0;
370
371 if (existsTransaction())
372 {
373 auto db = checkoutTransaction();
375 }
376
377 return 0;
378}
379
382{
383 if (!useTxTables_)
384 return 0;
385
386 if (existsTransaction())
387 {
388 auto db = checkoutTransaction();
390 }
391
392 return 0;
393}
394
397{
398 if (existsLedger())
399 {
400 auto db = checkoutLedger();
402 }
403
404 return {0, 0, 0};
405}
406
407bool
409 std::shared_ptr<Ledger const> const& ledger,
410 bool current)
411{
412 if (existsLedger())
413 {
415 *lgrdb_, *txdb_, app_, ledger, current))
416 return false;
417 }
418
419 return true;
420}
421
424{
425 if (existsLedger())
426 {
427 auto db = checkoutLedger();
428 auto const res = detail::getLedgerInfoByIndex(*db, ledgerSeq, j_);
429
430 if (res.has_value())
431 return res;
432 }
433
434 return {};
435}
436
439{
440 if (existsLedger())
441 {
442 auto db = checkoutLedger();
443 auto const res = detail::getNewestLedgerInfo(*db, j_);
444
445 if (res.has_value())
446 return res;
447 }
448
449 return {};
450}
451
454{
455 if (existsLedger())
456 {
457 auto db = checkoutLedger();
458 auto const res =
459 detail::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
460
461 if (res.has_value())
462 return res;
463 }
464
465 return {};
466}
467
470{
471 if (existsLedger())
472 {
473 auto db = checkoutLedger();
474 auto const res =
475 detail::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
476
477 if (res.has_value())
478 return res;
479 }
480
481 return {};
482}
483
486{
487 if (existsLedger())
488 {
489 auto db = checkoutLedger();
490 auto const res = detail::getLedgerInfoByHash(*db, ledgerHash, j_);
491
492 if (res.has_value())
493 return res;
494 }
495
496 return {};
497}
498
501{
502 if (existsLedger())
503 {
504 auto db = checkoutLedger();
505 auto const res = detail::getHashByIndex(*db, ledgerIndex);
506
507 if (res.isNonZero())
508 return res;
509 }
510
511 return uint256();
512}
513
516{
517 if (existsLedger())
518 {
519 auto db = checkoutLedger();
520 auto const res = detail::getHashesByIndex(*db, ledgerIndex, j_);
521
522 if (res.has_value())
523 return res;
524 }
525
526 return {};
527}
528
531{
532 if (existsLedger())
533 {
534 auto db = checkoutLedger();
535 auto const res = detail::getHashesByIndex(*db, minSeq, maxSeq, j_);
536
537 if (!res.empty())
538 return res;
539 }
540
541 return {};
542}
543
546{
547 if (!useTxTables_)
548 return {};
549
550 if (existsTransaction())
551 {
552 auto db = checkoutTransaction();
553 auto const res = detail::getTxHistory(*db, app_, startIndex, 20).first;
554
555 if (!res.empty())
556 return res;
557 }
558
559 return {};
560}
561
564{
565 if (!useTxTables_)
566 return {};
567
569
570 if (existsTransaction())
571 {
572 auto db = checkoutTransaction();
573 return detail::getOldestAccountTxs(*db, app_, ledgerMaster, options, j_)
574 .first;
575 }
576
577 return {};
578}
579
582{
583 if (!useTxTables_)
584 return {};
585
587
588 if (existsTransaction())
589 {
590 auto db = checkoutTransaction();
591 return detail::getNewestAccountTxs(*db, app_, ledgerMaster, options, j_)
592 .first;
593 }
594
595 return {};
596}
597
600{
601 if (!useTxTables_)
602 return {};
603
604 if (existsTransaction())
605 {
606 auto db = checkoutTransaction();
607 return detail::getOldestAccountTxsB(*db, app_, options, j_).first;
608 }
609
610 return {};
611}
612
615{
616 if (!useTxTables_)
617 return {};
618
619 if (existsTransaction())
620 {
621 auto db = checkoutTransaction();
622 return detail::getNewestAccountTxsB(*db, app_, options, j_).first;
623 }
624
625 return {};
626}
627
632{
633 if (!useTxTables_)
634 return {};
635
636 static std::uint32_t const page_length(200);
637 auto onUnsavedLedger =
638 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
639 AccountTxs ret;
640 Application& app = app_;
641 auto onTransaction = [&ret, &app](
642 std::uint32_t ledger_index,
643 std::string const& status,
644 Blob&& rawTxn,
645 Blob&& rawMeta) {
646 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
647 };
648
649 if (existsTransaction())
650 {
651 auto db = checkoutTransaction();
652 auto newmarker =
654 *db, onUnsavedLedger, onTransaction, options, page_length)
655 .first;
656 return {ret, newmarker};
657 }
658
659 return {};
660}
661
666{
667 if (!useTxTables_)
668 return {};
669
670 static std::uint32_t const page_length(200);
671 auto onUnsavedLedger =
672 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
673 AccountTxs ret;
674 Application& app = app_;
675 auto onTransaction = [&ret, &app](
676 std::uint32_t ledger_index,
677 std::string const& status,
678 Blob&& rawTxn,
679 Blob&& rawMeta) {
680 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
681 };
682
683 if (existsTransaction())
684 {
685 auto db = checkoutTransaction();
686 auto newmarker =
688 *db, onUnsavedLedger, onTransaction, options, page_length)
689 .first;
690 return {ret, newmarker};
691 }
692
693 return {};
694}
695
700{
701 if (!useTxTables_)
702 return {};
703
704 static std::uint32_t const page_length(500);
705 auto onUnsavedLedger =
706 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
707 MetaTxsList ret;
708 auto onTransaction = [&ret](
709 std::uint32_t ledgerIndex,
710 std::string const& status,
711 Blob&& rawTxn,
712 Blob&& rawMeta) {
713 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
714 };
715
716 if (existsTransaction())
717 {
718 auto db = checkoutTransaction();
719 auto newmarker =
721 *db, onUnsavedLedger, onTransaction, options, page_length)
722 .first;
723 return {ret, newmarker};
724 }
725
726 return {};
727}
728
733{
734 if (!useTxTables_)
735 return {};
736
737 static std::uint32_t const page_length(500);
738 auto onUnsavedLedger =
739 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
740 MetaTxsList ret;
741 auto onTransaction = [&ret](
742 std::uint32_t ledgerIndex,
743 std::string const& status,
744 Blob&& rawTxn,
745 Blob&& rawMeta) {
746 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
747 };
748
749 if (existsTransaction())
750 {
751 auto db = checkoutTransaction();
752 auto newmarker =
754 *db, onUnsavedLedger, onTransaction, options, page_length)
755 .first;
756 return {ret, newmarker};
757 }
758
759 return {};
760}
761
764 uint256 const& id,
766 error_code_i& ec)
767{
768 if (!useTxTables_)
769 return TxSearched::unknown;
770
771 if (existsTransaction())
772 {
773 auto db = checkoutTransaction();
774 return detail::getTransaction(*db, app_, id, range, ec);
775 }
776
777 return TxSearched::unknown;
778}
779
780bool
782{
783 if (existsLedger())
784 {
785 auto db = checkoutLedger();
786 return detail::dbHasSpace(*db, config, j_);
787 }
788
789 return true;
790}
791
792bool
794{
795 if (!useTxTables_)
796 return true;
797
798 if (existsTransaction())
799 {
800 auto db = checkoutTransaction();
801 return detail::dbHasSpace(*db, config, j_);
802 }
803
804 return true;
805}
806
809{
810 if (existsLedger())
811 {
812 return ripple::getKBUsedAll(lgrdb_->getSession());
813 }
814
815 return 0;
816}
817
820{
821 if (existsLedger())
822 {
823 return ripple::getKBUsedDB(lgrdb_->getSession());
824 }
825
826 return 0;
827}
828
831{
832 if (!useTxTables_)
833 return 0;
834
835 if (existsTransaction())
836 {
837 return ripple::getKBUsedDB(txdb_->getSession());
838 }
839
840 return 0;
841}
842
843void
848
849void
854
856getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue)
857{
858 return std::make_unique<SQLiteDatabaseImp>(app, config, jobQueue);
859}
860
861} // 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:58
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:176
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
Definition Node.cpp:525
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:502
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:1181
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
Definition Node.cpp:482
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:1167
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:70
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:147
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition Node.cpp:164
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:154
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:191
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:874
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:631
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:490
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:974
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
Definition Node.cpp:471
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
Definition Node.cpp:1276
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
Definition Node.cpp:514
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
Definition Node.cpp:127
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:885
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:984
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:555
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
Definition Node.cpp:137
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:1195
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
std::uint32_t getKBUsedAll(soci::session &s)
Definition SociDB.cpp:133
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:142
@ 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)