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