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/AcceptedLedger.h>
21#include <xrpld/app/ledger/LedgerMaster.h>
22#include <xrpld/app/ledger/LedgerToJson.h>
23#include <xrpld/app/ledger/TransactionMaster.h>
24#include <xrpld/app/misc/Manifest.h>
25#include <xrpld/app/misc/detail/AccountTxPaging.h>
26#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
27#include <xrpld/app/rdb/backend/detail/Node.h>
28#include <xrpld/core/DatabaseCon.h>
29#include <xrpld/core/SociDB.h>
30#include <xrpl/basics/BasicConfig.h>
31#include <xrpl/basics/StringUtilities.h>
32#include <xrpl/json/to_string.h>
33#include <soci/sqlite3/soci-sqlite3.h>
34
35namespace ripple {
36
38{
39public:
41 Application& app,
42 Config const& config,
43 JobQueue& jobQueue)
44 : app_(app)
45 , useTxTables_(config.useTxTables())
46 , j_(app_.journal("SQLiteDatabaseImp"))
47 {
48 DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_);
49 if (!makeLedgerDBs(
50 config,
51 setup,
53 {
54 std::string_view constexpr error =
55 "Failed to create ledger databases";
56
57 JLOG(j_.fatal()) << error;
58 Throw<std::runtime_error>(error.data());
59 }
60 }
61
63 getMinLedgerSeq() override;
64
67
70
72 getMaxLedgerSeq() override;
73
74 void
75 deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override;
76
77 void
78 deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override;
79
80 void
82
83 void
85
87 getTransactionCount() override;
88
91
93 getLedgerCountMinMax() override;
94
95 bool
98 bool current) override;
99
101 getLedgerInfoByIndex(LedgerIndex ledgerSeq) override;
102
104 getNewestLedgerInfo() override;
105
107 getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
108
110 getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override;
111
113 getLedgerInfoByHash(uint256 const& ledgerHash) override;
114
115 uint256
116 getHashByIndex(LedgerIndex ledgerIndex) override;
117
119 getHashesByIndex(LedgerIndex ledgerIndex) override;
120
122 getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override;
123
125 getTxHistory(LedgerIndex startIndex) override;
126
128 getOldestAccountTxs(AccountTxOptions const& options) override;
129
131 getNewestAccountTxs(AccountTxOptions const& options) override;
132
134 getOldestAccountTxsB(AccountTxOptions const& options) override;
135
137 getNewestAccountTxsB(AccountTxOptions const& options) override;
138
140 oldestAccountTxPage(AccountTxPageOptions const& options) override;
141
143 newestAccountTxPage(AccountTxPageOptions const& options) override;
144
146 oldestAccountTxPageB(AccountTxPageOptions const& options) override;
147
149 newestAccountTxPageB(AccountTxPageOptions const& options) override;
150
153 uint256 const& id,
155 error_code_i& ec) override;
156
157 bool
158 ledgerDbHasSpace(Config const& config) override;
159
160 bool
161 transactionDbHasSpace(Config const& config) override;
162
164 getKBUsedAll() override;
165
167 getKBUsedLedger() override;
168
170 getKBUsedTransaction() override;
171
172 void
173 closeLedgerDB() override;
174
175 void
176 closeTransactionDB() override;
177
178private:
180 bool const useTxTables_;
183
192 bool
194 Config const& config,
195 DatabaseCon::Setup const& setup,
196 DatabaseCon::CheckpointerSetup const& checkpointerSetup);
197
202 bool
204 {
205 return static_cast<bool>(lgrdb_);
206 }
207
213 bool
215 {
216 return static_cast<bool>(txdb_);
217 }
218
224 auto
226 {
227 return lgrdb_->checkoutDb();
228 }
229
235 auto
237 {
238 return txdb_->checkoutDb();
239 }
240};
241
242bool
244 Config const& config,
245 DatabaseCon::Setup const& setup,
246 DatabaseCon::CheckpointerSetup const& checkpointerSetup)
247{
248 auto [lgr, tx, res] =
249 detail::makeLedgerDBs(config, setup, checkpointerSetup, j_);
250 txdb_ = std::move(tx);
251 lgrdb_ = std::move(lgr);
252 return res;
253}
254
257{
258 /* if databases exists, use it */
259 if (existsLedger())
260 {
261 auto db = checkoutLedger();
263 }
264
265 /* else return empty value */
266 return {};
267}
268
271{
272 if (!useTxTables_)
273 return {};
274
275 if (existsTransaction())
276 {
277 auto db = checkoutTransaction();
279 }
280
281 return {};
282}
283
286{
287 if (!useTxTables_)
288 return {};
289
290 if (existsTransaction())
291 {
292 auto db = checkoutTransaction();
295 }
296
297 return {};
298}
299
302{
303 if (existsLedger())
304 {
305 auto db = checkoutLedger();
307 }
308
309 return {};
310}
311
312void
314{
315 if (!useTxTables_)
316 return;
317
318 if (existsTransaction())
319 {
320 auto db = checkoutTransaction();
322 *db, detail::TableType::Transactions, ledgerSeq);
323 return;
324 }
325}
326
327void
329{
330 if (existsLedger())
331 {
332 auto db = checkoutLedger();
334 *db, detail::TableType::Ledgers, ledgerSeq);
335 return;
336 }
337}
338
339void
341{
342 if (!useTxTables_)
343 return;
344
345 if (existsTransaction())
346 {
347 auto db = checkoutTransaction();
349 *db, detail::TableType::Transactions, ledgerSeq);
350 return;
351 }
352}
353
354void
356 LedgerIndex ledgerSeq)
357{
358 if (!useTxTables_)
359 return;
360
361 if (existsTransaction())
362 {
363 auto db = checkoutTransaction();
366 return;
367 }
368}
369
372{
373 if (!useTxTables_)
374 return 0;
375
376 if (existsTransaction())
377 {
378 auto db = checkoutTransaction();
380 }
381
382 return 0;
383}
384
387{
388 if (!useTxTables_)
389 return 0;
390
391 if (existsTransaction())
392 {
393 auto db = checkoutTransaction();
395 }
396
397 return 0;
398}
399
402{
403 if (existsLedger())
404 {
405 auto db = checkoutLedger();
407 }
408
409 return {0, 0, 0};
410}
411
412bool
414 std::shared_ptr<Ledger const> const& ledger,
415 bool current)
416{
417 if (existsLedger())
418 {
420 *lgrdb_, *txdb_, app_, ledger, current))
421 return false;
422 }
423
424 return true;
425}
426
429{
430 if (existsLedger())
431 {
432 auto db = checkoutLedger();
433 auto const res = detail::getLedgerInfoByIndex(*db, ledgerSeq, j_);
434
435 if (res.has_value())
436 return res;
437 }
438
439 return {};
440}
441
444{
445 if (existsLedger())
446 {
447 auto db = checkoutLedger();
448 auto const res = detail::getNewestLedgerInfo(*db, j_);
449
450 if (res.has_value())
451 return res;
452 }
453
454 return {};
455}
456
459{
460 if (existsLedger())
461 {
462 auto db = checkoutLedger();
463 auto const res =
464 detail::getLimitedOldestLedgerInfo(*db, ledgerFirstIndex, j_);
465
466 if (res.has_value())
467 return res;
468 }
469
470 return {};
471}
472
475{
476 if (existsLedger())
477 {
478 auto db = checkoutLedger();
479 auto const res =
480 detail::getLimitedNewestLedgerInfo(*db, ledgerFirstIndex, j_);
481
482 if (res.has_value())
483 return res;
484 }
485
486 return {};
487}
488
491{
492 if (existsLedger())
493 {
494 auto db = checkoutLedger();
495 auto const res = detail::getLedgerInfoByHash(*db, ledgerHash, j_);
496
497 if (res.has_value())
498 return res;
499 }
500
501 return {};
502}
503
506{
507 if (existsLedger())
508 {
509 auto db = checkoutLedger();
510 auto const res = detail::getHashByIndex(*db, ledgerIndex);
511
512 if (res.isNonZero())
513 return res;
514 }
515
516 return uint256();
517}
518
521{
522 if (existsLedger())
523 {
524 auto db = checkoutLedger();
525 auto const res = detail::getHashesByIndex(*db, ledgerIndex, j_);
526
527 if (res.has_value())
528 return res;
529 }
530
531 return {};
532}
533
536{
537 if (existsLedger())
538 {
539 auto db = checkoutLedger();
540 auto const res = detail::getHashesByIndex(*db, minSeq, maxSeq, j_);
541
542 if (!res.empty())
543 return res;
544 }
545
546 return {};
547}
548
551{
552 if (!useTxTables_)
553 return {};
554
555 if (existsTransaction())
556 {
557 auto db = checkoutTransaction();
558 auto const res = detail::getTxHistory(*db, app_, startIndex, 20).first;
559
560 if (!res.empty())
561 return res;
562 }
563
564 return {};
565}
566
569{
570 if (!useTxTables_)
571 return {};
572
574
575 if (existsTransaction())
576 {
577 auto db = checkoutTransaction();
578 return detail::getOldestAccountTxs(*db, app_, ledgerMaster, options, j_)
579 .first;
580 }
581
582 return {};
583}
584
587{
588 if (!useTxTables_)
589 return {};
590
592
593 if (existsTransaction())
594 {
595 auto db = checkoutTransaction();
596 return detail::getNewestAccountTxs(*db, app_, ledgerMaster, options, j_)
597 .first;
598 }
599
600 return {};
601}
602
605{
606 if (!useTxTables_)
607 return {};
608
609 if (existsTransaction())
610 {
611 auto db = checkoutTransaction();
612 return detail::getOldestAccountTxsB(*db, app_, options, j_).first;
613 }
614
615 return {};
616}
617
620{
621 if (!useTxTables_)
622 return {};
623
624 if (existsTransaction())
625 {
626 auto db = checkoutTransaction();
627 return detail::getNewestAccountTxsB(*db, app_, options, j_).first;
628 }
629
630 return {};
631}
632
637{
638 if (!useTxTables_)
639 return {};
640
641 static std::uint32_t const page_length(200);
642 auto onUnsavedLedger =
643 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
644 AccountTxs ret;
645 Application& app = app_;
646 auto onTransaction = [&ret, &app](
647 std::uint32_t ledger_index,
648 std::string const& status,
649 Blob&& rawTxn,
650 Blob&& rawMeta) {
651 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
652 };
653
654 if (existsTransaction())
655 {
656 auto db = checkoutTransaction();
657 auto newmarker =
659 *db, onUnsavedLedger, onTransaction, options, page_length)
660 .first;
661 return {ret, newmarker};
662 }
663
664 return {};
665}
666
671{
672 if (!useTxTables_)
673 return {};
674
675 static std::uint32_t const page_length(200);
676 auto onUnsavedLedger =
677 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
678 AccountTxs ret;
679 Application& app = app_;
680 auto onTransaction = [&ret, &app](
681 std::uint32_t ledger_index,
682 std::string const& status,
683 Blob&& rawTxn,
684 Blob&& rawMeta) {
685 convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
686 };
687
688 if (existsTransaction())
689 {
690 auto db = checkoutTransaction();
691 auto newmarker =
693 *db, onUnsavedLedger, onTransaction, options, page_length)
694 .first;
695 return {ret, newmarker};
696 }
697
698 return {};
699}
700
705{
706 if (!useTxTables_)
707 return {};
708
709 static std::uint32_t const page_length(500);
710 auto onUnsavedLedger =
711 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
712 MetaTxsList ret;
713 auto onTransaction = [&ret](
714 std::uint32_t ledgerIndex,
715 std::string const& status,
716 Blob&& rawTxn,
717 Blob&& rawMeta) {
718 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
719 };
720
721 if (existsTransaction())
722 {
723 auto db = checkoutTransaction();
724 auto newmarker =
726 *db, onUnsavedLedger, onTransaction, options, page_length)
727 .first;
728 return {ret, newmarker};
729 }
730
731 return {};
732}
733
738{
739 if (!useTxTables_)
740 return {};
741
742 static std::uint32_t const page_length(500);
743 auto onUnsavedLedger =
744 std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1);
745 MetaTxsList ret;
746 auto onTransaction = [&ret](
747 std::uint32_t ledgerIndex,
748 std::string const& status,
749 Blob&& rawTxn,
750 Blob&& rawMeta) {
751 ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
752 };
753
754 if (existsTransaction())
755 {
756 auto db = checkoutTransaction();
757 auto newmarker =
759 *db, onUnsavedLedger, onTransaction, options, page_length)
760 .first;
761 return {ret, newmarker};
762 }
763
764 return {};
765}
766
769 uint256 const& id,
771 error_code_i& ec)
772{
773 if (!useTxTables_)
774 return TxSearched::unknown;
775
776 if (existsTransaction())
777 {
778 auto db = checkoutTransaction();
779 return detail::getTransaction(*db, app_, id, range, ec);
780 }
781
782 return TxSearched::unknown;
783}
784
785bool
787{
788 if (existsLedger())
789 {
790 auto db = checkoutLedger();
791 return detail::dbHasSpace(*db, config, j_);
792 }
793
794 return true;
795}
796
797bool
799{
800 if (!useTxTables_)
801 return true;
802
803 if (existsTransaction())
804 {
805 auto db = checkoutTransaction();
806 return detail::dbHasSpace(*db, config, j_);
807 }
808
809 return true;
810}
811
814{
815 if (existsLedger())
816 {
817 return ripple::getKBUsedAll(lgrdb_->getSession());
818 }
819
820 return 0;
821}
822
825{
826 if (existsLedger())
827 {
828 return ripple::getKBUsedDB(lgrdb_->getSession());
829 }
830
831 return 0;
832}
833
836{
837 if (!useTxTables_)
838 return 0;
839
840 if (existsTransaction())
841 {
842 return ripple::getKBUsedDB(txdb_->getSession());
843 }
844
845 return 0;
846}
847
848void
850{
851 lgrdb_.reset();
852}
853
854void
856{
857 txdb_.reset();
858}
859
861getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue)
862{
863 return std::make_unique<SQLiteDatabaseImp>(app, config, jobQueue);
864}
865
866} // namespace ripple
T bind(T... args)
A generic endpoint for log messages.
Definition: Journal.h:59
Stream fatal() const
Definition: Journal.h:341
virtual LedgerMaster & getLedgerMaster()=0
virtual Logs & logs()=0
A pool of threads to perform work.
Definition: JobQueue.h:56
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:173
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:67
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:144
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
Definition: Node.cpp:161
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:151
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:188
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
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:124
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:134
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: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:130
error_code_i
Definition: ErrorCodes.h:40
base_uint< 256 > uint256
Definition: base_uint.h:557
void saveLedgerAsync(Application &app, std::uint32_t seq)
std::uint32_t getKBUsedDB(soci::session &s)
Definition: SociDB.cpp:139
@ 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)