20 #include <ripple/app/ledger/AcceptedLedger.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/ledger/LedgerToJson.h>
23 #include <ripple/app/ledger/TransactionMaster.h>
24 #include <ripple/app/misc/Manifest.h>
25 #include <ripple/app/misc/impl/AccountTxPaging.h>
26 #include <ripple/app/rdb/RelationalDBInterface_nodes.h>
27 #include <ripple/app/rdb/RelationalDBInterface_postgres.h>
28 #include <ripple/app/rdb/RelationalDBInterface_shards.h>
29 #include <ripple/app/rdb/backend/RelationalDBInterfaceSqlite.h>
30 #include <ripple/basics/BasicConfig.h>
31 #include <ripple/basics/StringUtilities.h>
32 #include <ripple/core/DatabaseCon.h>
33 #include <ripple/core/SociDB.h>
34 #include <ripple/json/to_string.h>
35 #include <ripple/nodestore/DatabaseShard.h>
36 #include <boost/algorithm/string.hpp>
37 #include <boost/range/adaptor/transformed.hpp>
38 #include <soci/sqlite3/soci-sqlite3.h>
58 <<
"AccountTransactions database should not have a primary key";
59 Throw<std::runtime_error>(
60 "AccountTransactions database initialization failed.");
70 <<
"Error during meta DB init";
71 Throw<std::runtime_error>(
72 "Shard meta database initialization failed.");
112 bool current)
override;
286 return lgrdb_->checkoutDb();
296 return txdb_->checkoutDb();
313 ledgerSeq, callback);
330 ledgerSeq, callback);
348 bool(soci::session& session,
std::uint32_t shardIndex)>
const&
352 firstIndex, callback);
370 bool(soci::session& session,
std::uint32_t shardIndex)>
const&
374 firstIndex, callback);
392 bool(soci::session& session,
std::uint32_t shardIndex)>
const&
396 firstIndex, callback);
414 bool(soci::session& session,
std::uint32_t shardIndex)>
const&
418 firstIndex, callback);
428 auto [lgr, tx, res] =
430 txdb_ = std::move(tx);
441 auto [lgrMetaDB, txMetaDB] =
673 res.numberOfRows += r.numberOfRows;
674 if (res.minLedgerSequence == 0)
675 res.minLedgerSequence = r.minLedgerSequence;
676 res.maxLedgerSequence = r.maxLedgerSequence;
698 if (ledger->info().seq < shardStore->earliestLedgerSeq())
706 auto lgrMetaSession =
lgrMetaDB_->checkoutDb();
707 auto txMetaSession =
txMetaDB_->checkoutDb();
714 shardStore->seqToShardIndex(ledger->info().seq));
732 doLedger(ledgerSeq, [&](soci::session& session) {
781 session, ledgerFirstIndex,
j_))
808 session, ledgerFirstIndex,
j_))
833 auto lgrMetaSession =
lgrMetaDB_->checkoutDb();
835 if (
auto const shardIndex =
838 shardStore->callForLedgerSQLByShardIndex(
839 *shardIndex, [&](soci::session& session) {
863 doLedger(ledgerIndex, [&](soci::session& session) {
882 doLedger(ledgerIndex, [&](soci::session& session) {
903 while (minSeq <= maxSeq)
906 if (shardMaxSeq > maxSeq)
907 shardMaxSeq = maxSeq;
908 doLedger(minSeq, [&](soci::session& session) {
910 res.
insert(r.begin(), r.end());
913 minSeq = shardMaxSeq + 1;
936 txs.
insert(txs.
end(), tx.begin(), tx.end());
977 if (opt.maxLedger && shardIndex > seqToShardIndex(opt.maxLedger))
979 auto [r, total] = ripple::getOldestAccountTxs(
980 session, app_, ledgerMaster, opt, limit_used, j_);
981 ret.insert(ret.end(), r.begin(), r.end());
992 if (opt.offset <= total)
1003 RelationalDBInterface::AccountTxs
1004 RelationalDBInterfaceSqliteImp::getNewestAccountTxs(
1010 if (existsTransaction())
1012 auto db = checkoutTransaction();
1022 iterateTransactionBack(
1026 if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
1028 auto [r, total] = ripple::getNewestAccountTxs(
1029 session, app_, ledgerMaster, opt, limit_used, j_);
1030 ret.insert(ret.end(), r.begin(), r.end());
1035 limit_used += total;
1041 if (opt.offset <= total)
1044 opt.offset -= total;
1052 RelationalDBInterface::MetaTxsList
1053 RelationalDBInterfaceSqliteImp::getOldestAccountTxsB(
1057 if (existsTransaction())
1059 auto db = checkoutTransaction();
1067 iterateTransactionForward(
1071 if (opt.maxLedger && shardIndex > seqToShardIndex(opt.maxLedger))
1073 auto [r, total] = ripple::getOldestAccountTxsB(
1074 session, app_, opt, limit_used, j_);
1075 ret.insert(ret.end(), r.begin(), r.end());
1080 limit_used += total;
1086 if (opt.offset <= total)
1089 opt.offset -= total;
1097 RelationalDBInterface::MetaTxsList
1098 RelationalDBInterfaceSqliteImp::getNewestAccountTxsB(
1102 if (existsTransaction())
1104 auto db = checkoutTransaction();
1112 iterateTransactionBack(
1116 if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
1118 auto [r, total] = ripple::getNewestAccountTxsB(
1119 session, app_, opt, limit_used, j_);
1120 ret.insert(ret.end(), r.begin(), r.end());
1125 limit_used += total;
1131 if (opt.offset <= total)
1134 opt.offset -= total;
1143 RelationalDBInterface::AccountTxs,
1145 RelationalDBInterfaceSqliteImp::oldestAccountTxPage(
1150 auto onUnsavedLedger =
1154 auto onTransaction = [&ret, &app](
1163 if (existsTransaction())
1165 auto db = checkoutTransaction();
1175 return {ret, newmarker};
1181 iterateTransactionForward(
1185 if (opt.maxLedger != UINT32_MAX &&
1186 shardIndex > seqToShardIndex(opt.minLedger))
1188 auto [marker, total] = ripple::oldestAccountTxPage(
1196 opt.marker = marker;
1199 limit_used += total;
1203 return {ret, opt.
marker};
1209 RelationalDBInterfaceSqliteImp::newestAccountTxPage(
1214 auto onUnsavedLedger =
1218 auto onTransaction = [&ret, &app](
1227 if (existsTransaction())
1229 auto db = checkoutTransaction();
1239 return {ret, newmarker};
1245 iterateTransactionBack(
1249 if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
1251 auto [marker, total] = ripple::newestAccountTxPage(
1259 opt.marker = marker;
1262 limit_used += total;
1266 return {ret, opt.
marker};
1272 RelationalDBInterfaceSqliteImp::oldestAccountTxPageB(
1277 auto onUnsavedLedger =
1280 auto onTransaction = [&ret](
1285 ret.
emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
1289 if (existsTransaction())
1291 auto db = checkoutTransaction();
1301 return {ret, newmarker};
1307 iterateTransactionForward(
1311 if (opt.maxLedger != UINT32_MAX &&
1312 shardIndex > seqToShardIndex(opt.minLedger))
1314 auto [marker, total] = ripple::oldestAccountTxPage(
1322 opt.marker = marker;
1325 limit_used += total;
1329 return {ret, opt.
marker};
1335 RelationalDBInterfaceSqliteImp::newestAccountTxPageB(
1340 auto onUnsavedLedger =
1343 auto onTransaction = [&ret](
1348 ret.
emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
1352 if (existsTransaction())
1354 auto db = checkoutTransaction();
1364 return {ret, newmarker};
1370 iterateTransactionBack(
1374 if (opt.minLedger && shardIndex < seqToShardIndex(opt.minLedger))
1376 auto [marker, total] = ripple::newestAccountTxPage(
1384 opt.marker = marker;
1387 limit_used += total;
1391 return {ret, opt.
marker};
1395 RelationalDBInterfaceSqliteImp::getTransaction(
1401 if (existsTransaction())
1403 auto db = checkoutTransaction();
1411 auto txMetaSession = txMetaDB_->checkoutDb();
1413 if (
auto const shardIndex =
1416 shardStore->callForTransactionSQLByShardIndex(
1417 *shardIndex, [&](soci::session& session) {
1422 range->lower(), firstLedgerSeq(*shardIndex));
1424 range->upper(), lastLedgerSeq(*shardIndex));
1430 return res.
index() == 1 &&
1431 std::get<TxSearched>(res) !=
1432 TxSearched::unknown;
1439 return {TxSearched::unknown};
1443 RelationalDBInterfaceSqliteImp::ledgerDbHasSpace(
Config const& config)
1448 auto db = checkoutLedger();
1453 return iterateLedgerBack(
1460 RelationalDBInterfaceSqliteImp::transactionDbHasSpace(
Config const& config)
1463 if (existsTransaction())
1465 auto db = checkoutTransaction();
1470 return iterateTransactionBack(
1477 RelationalDBInterfaceSqliteImp::getKBUsedAll()
1496 RelationalDBInterfaceSqliteImp::getKBUsedLedger()
1515 RelationalDBInterfaceSqliteImp::getKBUsedTransaction()
1518 if (existsTransaction())
1525 iterateTransactionBack(
1534 RelationalDBInterfaceSqliteImp::closeLedgerDB()
1540 RelationalDBInterfaceSqliteImp::closeTransactionDB()
1551 return std::make_unique<RelationalDBInterfaceSqliteImp>(
1552 app, config, jobQueue);
std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const noexcept
Calculates the last ledger sequence for a given shard index.
void deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionByLedgerSeq Deletes transactions from ledger with given sequence.
std::optional< LedgerInfo > getLedgerInfoByIndex(soci::session &session, LedgerIndex ledgerSeq, beast::Journal j)
getLedgerInfoByIndex Returns ledger by its sequence.
void deleteBeforeLedgerSeq(soci::session &session, TableType type, LedgerIndex ledgerSeq)
deleteBeforeLedgerSeq Deletes all entries in given table for the ledgers with given sequence and all ...
@ ledgerMaster
ledger master data for signing
virtual bool callForLedgerSQLByLedgerSeq(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)=0
Invoke a callback on the SQLite db holding the corresponding ledger.
std::pair< std::vector< std::shared_ptr< Transaction > >, int > getTxHistory(soci::session &session, Application &app, LedgerIndex startIndex, int quantity, bool count)
getTxHistory Returns given number of most recent transactions starting from given number of entry.
uint256 getHashByIndex(soci::session &session, LedgerIndex ledgerIndex)
getHashByIndex Returns hash of ledger with given sequence.
std::unique_ptr< RelationalDBInterface > getRelationalDBInterfaceSqlite(Application &app, Config const &config, JobQueue &jobQueue)
std::pair< RelationalDBInterface::AccountTxs, int > getOldestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getOldestAccountTxs Returns oldest transactions for given account which match given criteria starting...
std::pair< MetaTxsList, std::optional< AccountTxMarker > > newestAccountTxPageB(AccountTxPageOptions const &options) override
newestAccountTxPageB Returns newest transactions in binary form for given account which match given c...
std::unique_ptr< DatabaseCon > txMetaDB_
std::pair< std::vector< RelationalDBInterface::txnMetaLedgerType >, int > getOldestAccountTxsB(soci::session &session, Application &app, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getOldestAccountTxsB Returns oldest transactions in binary form for given account which match given c...
MetaTxsList getNewestAccountTxsB(AccountTxOptions const &options) override
getNewestAccountTxsB Returns newest transactions in binary form for given account which match given c...
std::unique_ptr< DatabaseCon > lgrdb_
void deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteAccountTransactionsBeforeLedgerSeq Deletes all account transactions with given ledger sequence ...
std::pair< AccountTxs, std::optional< AccountTxMarker > > oldestAccountTxPage(AccountTxPageOptions const &options) override
oldestAccountTxPage Returns oldest transactions for given account which match given criteria starting...
std::pair< MetaTxsList, std::optional< AccountTxMarker > > oldestAccountTxPageB(AccountTxPageOptions const &options) override
oldestAccountTxPageB Returns oldest transactions in binary form for given account which match given c...
DatabaseCon::Setup setup_DatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
bool iterateTransactionBack(std::optional< std::uint32_t > firstIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)
iterateTransactionForward Checks out transaction databases for all shards in descending order startin...
RelationalDBInterface::CountMinMax getRowsMinMax(soci::session &session, TableType type)
getRowsMinMax Returns minumum ledger sequence, maximum ledger sequence and total number of rows in gi...
std::pair< std::optional< RelationalDBInterface::AccountTxMarker >, int > newestAccountTxPage(soci::session &session, AccountIDCache const &idCache, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDBInterface::AccountTxPageOptions const &options, int limit_used, std::uint32_t page_length)
newestAccountTxPage Searches newest transactions for given account which match given criteria startin...
std::uint32_t getKBUsedDB(soci::session &s)
std::optional< LedgerInfo > getLedgerInfoByHash(soci::session &session, uint256 const &ledgerHash, beast::Journal j)
getLedgerInfoByHash Returns info of ledger with given hash.
virtual NodeStore::DatabaseShard * getShardStore()=0
std::optional< LedgerIndex > getAccountTransactionsMinLedgerSeq() override
getAccountTransactionsMinLedgerSeq Returns minimum ledger sequence among records in the AccountTransa...
virtual bool callForTransactionSQLByLedgerSeq(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)=0
Invoke a callback on the transaction SQLite db for the corresponding ledger.
std::unique_ptr< DatabaseCon > lgrMetaDB_
std::optional< AccountTxMarker > marker
auto checkoutTransaction()
checkoutTransaction Checks out and returns node transaction DB.
std::unique_ptr< DatabaseCon > txdb_
void closeLedgerDB() override
Closes the ledger database.
bool iterateLedgerBack(std::optional< std::uint32_t > firstIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)
iterateLedgerBack Checks out ledger databases for all shards in descending order starting from given ...
uint256 getHashByIndex(LedgerIndex ledgerIndex) override
getHashByIndex Returns hash of ledger with given sequence.
bool transactionDbHasSpace(Config const &config) override
transactionDbHasSpace Checks if transaction database has available space.
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...
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...
bool iterateTransactionForward(std::optional< std::uint32_t > firstIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)
iterateTransactionForward Checks out transaction databases for all shards in ascending order starting...
virtual AccountIDCache const & accountIDCache() const =0
bool makeLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeLedgerDBs Opens node ledger and transaction databases, and saves its descriptors into internal va...
std::pair< RelationalDBInterface::AccountTxs, int > getNewestAccountTxs(soci::session &session, Application &app, LedgerMaster &ledgerMaster, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getNewestAccountTxs Returns newest transactions for given account which match given criteria starting...
bool doLedger(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)
doLedger Checks out ledger database for shard containing given ledger and calls given callback functi...
Integers of any length that is a multiple of 32-bits.
LedgerIndex lastLedgerSeq(std::uint32_t shardIndex)
lastLedgerSeq Returns last ledger sequence for given shard.
MetaTxsList getOldestAccountTxsB(AccountTxOptions const &options) override
getOldestAccountTxsB Returns oldest transactions in binary form for given account which match given c...
std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const noexcept
Calculates the first ledger sequence for a given shard index.
std::uint32_t getKBUsedAll(soci::session &s)
std::uint32_t getKBUsedAll() override
getKBUsedAll Returns space used by all databases.
static bool saveValidatedLedger(Application &app, std::shared_ptr< Ledger const > const &ledger, bool current)
void deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteTransactionsBeforeLedgerSeq Deletes all transactions with given ledger sequence and all sequenc...
virtual LedgerMaster & getLedgerMaster()=0
virtual bool iterateLedgerSQLsBack(std::optional< std::uint32_t > maxShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)=0
iterateLedgerSQLsBack Checks out ledger databases for all shards in descending order starting from gi...
std::optional< LedgerInfo > getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedOldestLedgerInfo Returns info of oldest ledger from ledgers with sequences greater or equal...
bool existsLedger()
checkoutLedger Checks if node ledger DB exists.
virtual bool iterateLedgerSQLsForward(std::optional< std::uint32_t > minShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)=0
iterateLedgerSQLsForward Checks out ledger databases for all shards in ascending order starting from ...
std::size_t getTransactionCount() override
getTransactionCount Returns number of transactions.
void saveLedgerAsync(Application &app, std::uint32_t seq)
auto checkoutLedger()
checkoutTransaction Checks out and returns node ledger DB.
std::optional< LedgerInfo > getLedgerInfoByHash(uint256 const &ledgerHash) override
std::optional< LedgerInfo > getNewestLedgerInfo() override
getNewestLedgerInfo Returns info of newest saved ledger.
std::optional< LedgerIndex > getMinLedgerSeq() override
getMinLedgerSeq Returns minimum ledger sequence in Ledgers table.
void deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override
deleteBeforeLedgerSeq Deletes all ledgers with given sequence and all sequences below it.
void deleteByLedgerSeq(soci::session &session, TableType type, LedgerIndex ledgerSeq)
deleteByLedgerSeq Deletes all entries in given table for the ledger with given sequence.
bool makeMetaDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeMetaDBs Opens shard index lookup databases, and saves their descriptors into internal variables.
@ current
This was a new validation and was added.
A generic endpoint for log messages.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
RelationalDBInterface::CountMinMax getLedgerCountMinMax() override
getLedgerCountMinMax Returns minumum ledger sequence, maximum ledger sequence and total number of sav...
std::optional< LedgerInfo > getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override
getLimitedNewestLedgerInfo Returns info of newest ledger from ledgers with sequences greater or equal...
A pool of threads to perform work.
LedgerIndex firstLedgerSeq(std::uint32_t shardIndex)
firstLedgerSeq Returns first ledger sequence for given shard.
std::pair< std::vector< RelationalDBInterface::txnMetaLedgerType >, int > getNewestAccountTxsB(soci::session &session, Application &app, RelationalDBInterface::AccountTxOptions const &options, std::optional< int > const &limit_used, beast::Journal j)
getNewestAccountTxsB Returns newest transactions in binary form for given account which match given c...
bool existsTransaction()
checkoutTransaction Checks if node transaction DB exists.
std::uint32_t getKBUsedTransaction() override
getKBUsedTransaction Returns space used by transaction database.
std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex) override
getTxHistory Returns most recent 20 transactions starting from given number or entry.
std::optional< LedgerInfo > getLedgerInfoByIndex(LedgerIndex ledgerSeq) override
getLedgerInfoByIndex Returns ledger by its sequence.
std::uint32_t seqToShardIndex(LedgerIndex ledgerSeq)
seqToShardIndex Converts ledgers sequence to shard index.
T emplace_back(T... args)
std::variant< RelationalDBInterface::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.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t getRows(soci::session &session, TableType type)
getRows Returns number of rows in given table.
virtual beast::Journal journal(std::string const &name)=0
std::vector< txnMetaLedgerType > MetaTxsList
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...
std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept
Calculates the shard index for a given ledger sequence.
std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex) override
getHashesByIndex Returns hash of the ledger and hash of parent ledger for the ledger of given sequenc...
AccountTxs getNewestAccountTxs(AccountTxOptions const &options) override
getNewestAccountTxs Returns newest transactions for given account which match given criteria starting...
void convertBlobsToTxResult(RelationalDBInterface::AccountTxs &to, std::uint32_t ledger_index, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
void closeTransactionDB() override
Closes the transaction database.
DatabasePair makeMetaDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeMetaDBs Opens ledger and transaction 'meta' databases which map ledger hashes and transaction IDs...
bool doTransaction(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)
doTransaction Checks out transaction database for shard containing given ledger and calls given callb...
DatabasePairValid makeLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeLedgerDBs Opens ledger and transactions databases.
std::pair< AccountTxs, std::optional< AccountTxMarker > > newestAccountTxPage(AccountTxPageOptions const &options) override
newestAccountTxPage Returns newest transactions for given account which match given criteria starting...
bool ledgerDbHasSpace(Config const &config) override
ledgerDbHasSpace Checks if ledger database has available space.
std::pair< std::optional< RelationalDBInterface::AccountTxMarker >, int > oldestAccountTxPage(soci::session &session, AccountIDCache const &idCache, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob &&, Blob &&)> const &onTransaction, RelationalDBInterface::AccountTxPageOptions const &options, int limit_used, std::uint32_t page_length)
oldestAccountTxPage Searches oldest transactions for given account which match given criteria startin...
std::size_t getAccountTransactionCount() override
getAccountTransactionCount Returns number of account transactions.
bool saveLedgerMeta(std::shared_ptr< Ledger const > const &ledger, Application &app, soci::session &lgrMetaSession, soci::session &txnMetaSession, std::uint32_t const shardIndex)
saveLedgerMeta Stores (transaction ID -> shard index) and (ledger hash -> shard index) mappings in th...
std::optional< LedgerIndex > getMaxLedgerSeq() override
getMaxLedgerSeq Returns maximum ledger sequence in Ledgers table.
bool iterateLedgerForward(std::optional< std::uint32_t > firstIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)
iterateLedgerForward Checks out ledger databases for all shards in ascending order starting from give...
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
bool dbHasSpace(soci::session &session, Config const &config, beast::Journal j)
dbHasSpace Checks if given database has available space.
std::optional< LedgerIndex > getMinLedgerSeq(soci::session &session, TableType type)
getMinLedgerSeq Returns minimum ledger sequence in given table.
AccountTxs getOldestAccountTxs(AccountTxOptions const &options) override
getOldestAccountTxs Returns oldest transactions for given account which match given criteria starting...
std::optional< std::uint32_t > getShardIndexforTransaction(soci::session &session, TxID const &id)
getShardIndexforTransaction Queries the transaction meta database to retrieve the index of the shard ...
bool saveValidatedLedger(std::shared_ptr< Ledger const > const &ledger, bool current) override
saveValidatedLedger Saves ledger into database.
std::optional< LedgerInfo > getNewestLedgerInfo(soci::session &session, beast::Journal j)
getNewestLedgerInfo Returns info of newest saved ledger.
std::optional< LedgerIndex > getTransactionsMinLedgerSeq() override
getTransactionsMinLedgerSeq Returns minimum ledger sequence among records in the Transactions table.
std::optional< LedgerIndex > getMaxLedgerSeq(soci::session &session, TableType type)
getMaxLedgerSeq Returns maximum ledger sequence in given table.
RelationalDBInterfaceSqliteImp(Application &app, Config const &config, JobQueue &jobQueue)
std::vector< AccountTx > AccountTxs
std::uint32_t getKBUsedLedger() override
getKBUsedLedger Returns space used by ledger database.
std::optional< std::uint32_t > getShardIndexforLedger(soci::session &session, LedgerHash const &hash)
getShardIndexforLedger Queries the ledger meta database to retrieve the index of the shard that conta...
std::variant< AccountTx, TxSearched > getTransaction(uint256 const &id, std::optional< ClosedInterval< std::uint32_t >> const &range, error_code_i &ec) override