rippled
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ripple::SQLiteDatabaseImp Class Referencefinalabstract
Inheritance diagram for ripple::SQLiteDatabaseImp:
Inheritance graph
[legend]
Collaboration diagram for ripple::SQLiteDatabaseImp:
Collaboration graph
[legend]

Public Types

using AccountTx = std::pair< std::shared_ptr< Transaction >, std::shared_ptr< TxMeta > >
 
using AccountTxs = std::vector< AccountTx >
 
using txnMetaLedgerType = std::tuple< Blob, Blob, std::uint32_t >
 
using MetaTxsList = std::vector< txnMetaLedgerType >
 
using LedgerSequence = uint32_t
 
using LedgerHash = uint256
 
using LedgerShortcut = RPC::LedgerShortcut
 
using LedgerSpecifier = std::variant< LedgerRange, LedgerShortcut, LedgerSequence, LedgerHash >
 

Public Member Functions

 SQLiteDatabaseImp (Application &app, Config const &config, JobQueue &jobQueue)
 
std::optional< LedgerIndexgetMinLedgerSeq () override
 getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table. More...
 
std::optional< LedgerIndexgetTransactionsMinLedgerSeq () override
 getTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the Transactions table. More...
 
std::optional< LedgerIndexgetAccountTransactionsMinLedgerSeq () override
 getAccountTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the AccountTransactions table. More...
 
std::optional< LedgerIndexgetMaxLedgerSeq () override
 getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table. More...
 
void deleteTransactionByLedgerSeq (LedgerIndex ledgerSeq) override
 deleteTransactionByLedgerSeq Deletes transactions from the ledger with the given sequence. More...
 
void deleteBeforeLedgerSeq (LedgerIndex ledgerSeq) override
 deleteBeforeLedgerSeq Deletes all ledgers with a sequence number less than or equal to the given ledger sequence. More...
 
void deleteTransactionsBeforeLedgerSeq (LedgerIndex ledgerSeq) override
 deleteTransactionsBeforeLedgerSeq Deletes all transactions with a sequence number less than or equal to the given ledger sequence. More...
 
void deleteAccountTransactionsBeforeLedgerSeq (LedgerIndex ledgerSeq) override
 deleteAccountTransactionsBeforeLedgerSeq Deletes all account transactions with a sequence number less than or equal to the given ledger sequence. More...
 
std::size_t getTransactionCount () override
 getTransactionCount Returns the number of transactions. More...
 
std::size_t getAccountTransactionCount () override
 getAccountTransactionCount Returns the number of account transactions. More...
 
RelationalDatabase::CountMinMax getLedgerCountMinMax () override
 getLedgerCountMinMax Returns the minimum ledger sequence, maximum ledger sequence and total number of saved ledgers. More...
 
bool saveValidatedLedger (std::shared_ptr< Ledger const > const &ledger, bool current) override
 saveValidatedLedger Saves a ledger into the database. More...
 
std::optional< LedgerInfogetLedgerInfoByIndex (LedgerIndex ledgerSeq) override
 getLedgerInfoByIndex Returns a ledger by its sequence. More...
 
std::optional< LedgerInfogetNewestLedgerInfo () override
 getNewestLedgerInfo Returns the info of the newest saved ledger. More...
 
std::optional< LedgerInfogetLimitedOldestLedgerInfo (LedgerIndex ledgerFirstIndex) override
 getLimitedOldestLedgerInfo Returns the info of the oldest ledger whose sequence number is greater than or equal to the given sequence number. More...
 
std::optional< LedgerInfogetLimitedNewestLedgerInfo (LedgerIndex ledgerFirstIndex) override
 getLimitedNewestLedgerInfo Returns the info of the newest ledger whose sequence number is greater than or equal to the given sequence number. More...
 
std::optional< LedgerInfogetLedgerInfoByHash (uint256 const &ledgerHash) override
 getLedgerInfoByHash Returns the info of the ledger with given hash. More...
 
uint256 getHashByIndex (LedgerIndex ledgerIndex) override
 getHashByIndex Returns the hash of the ledger with the given sequence. More...
 
std::optional< LedgerHashPairgetHashesByIndex (LedgerIndex ledgerIndex) override
 getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex. More...
 
std::map< LedgerIndex, LedgerHashPairgetHashesByIndex (LedgerIndex minSeq, LedgerIndex maxSeq) override
 getHashesByIndex Returns hashes of each ledger and its parent for all ledgers within the provided range. More...
 
std::vector< std::shared_ptr< Transaction > > getTxHistory (LedgerIndex startIndex) override
 getTxHistory Returns the 20 most recent transactions starting from the given number. More...
 
AccountTxs getOldestAccountTxs (AccountTxOptions const &options) override
 getOldestAccountTxs Returns the oldest transactions for the account that matches the given criteria starting from the provided offset. More...
 
AccountTxs getNewestAccountTxs (AccountTxOptions const &options) override
 getNewestAccountTxs Returns the newest transactions for the account that matches the given criteria starting from the provided offset. More...
 
MetaTxsList getOldestAccountTxsB (AccountTxOptions const &options) override
 getOldestAccountTxsB Returns the oldest transactions in binary form for the account that matches the given criteria starting from the provided offset. More...
 
MetaTxsList getNewestAccountTxsB (AccountTxOptions const &options) override
 getNewestAccountTxsB Returns the newest transactions in binary form for the account that matches the given criteria starting from the provided offset. More...
 
std::pair< AccountTxs, std::optional< AccountTxMarker > > oldestAccountTxPage (AccountTxPageOptions const &options) override
 oldestAccountTxPage Returns the oldest transactions for the account that matches the given criteria starting from the provided marker. More...
 
std::pair< AccountTxs, std::optional< AccountTxMarker > > newestAccountTxPage (AccountTxPageOptions const &options) override
 newestAccountTxPage Returns the newest transactions for the account that matches the given criteria starting from the provided marker. More...
 
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 given criteria starting from the provided marker. More...
 
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 given criteria starting from the provided marker. More...
 
std::variant< AccountTx, TxSearchedgetTransaction (uint256 const &id, std::optional< ClosedInterval< std::uint32_t >> const &range, error_code_i &ec) override
 
bool ledgerDbHasSpace (Config const &config) override
 ledgerDbHasSpace Checks if the ledger database has available space. More...
 
bool transactionDbHasSpace (Config const &config) override
 transactionDbHasSpace Checks if the transaction database has available space. More...
 
std::uint32_t getKBUsedAll () override
 getKBUsedAll Returns the amount of space used by all databases. More...
 
std::uint32_t getKBUsedLedger () override
 getKBUsedLedger Returns the amount of space space used by the ledger database. More...
 
std::uint32_t getKBUsedTransaction () override
 getKBUsedTransaction Returns the amount of space used by the transaction database. More...
 
void closeLedgerDB () override
 Closes the ledger database. More...
 
void closeTransactionDB () override
 Closes the transaction database. More...
 
virtual std::variant< AccountTx, TxSearchedgetTransaction (uint256 const &id, std::optional< ClosedInterval< uint32_t >> const &range, error_code_i &ec)=0
 getTransaction Returns the transaction with the given hash. More...
 

Static Public Member Functions

static std::unique_ptr< RelationalDatabaseinit (Application &app, Config const &config, JobQueue &jobQueue)
 init Creates and returns an appropriate RelationalDatabase instance based on configuration. More...
 

Private Member Functions

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 in private member variables. More...
 
bool makeMetaDBs (Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
 makeMetaDBs Opens shard index lookup databases, and stores their descriptors in private member variables. More...
 
std::uint32_t seqToShardIndex (LedgerIndex ledgerSeq)
 seqToShardIndex Provides the index of the shard that stores the ledger with the given sequence. More...
 
LedgerIndex firstLedgerSeq (std::uint32_t shardIndex)
 firstLedgerSeq Returns the sequence of the first ledger stored in the shard specified by the shard index parameter. More...
 
LedgerIndex lastLedgerSeq (std::uint32_t shardIndex)
 lastLedgerSeq Returns the sequence of the last ledger stored in the shard specified by the shard index parameter. More...
 
bool existsLedger ()
 existsLedger Checks if the node store ledger database exists. More...
 
bool existsTransaction ()
 existsTransaction Checks if the node store transaction database exists. More...
 
bool shardStoreExists ()
 shardStoreExists Checks whether the shard store exists More...
 
auto checkoutLedger ()
 checkoutTransaction Checks out and returns node store ledger database. More...
 
auto checkoutTransaction ()
 checkoutTransaction Checks out and returns the node store transaction database. More...
 
bool doLedger (LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)
 doLedger Checks out the ledger database owned by the shard containing the given ledger, and invokes the provided callback with a session to that database. More...
 
bool doTransaction (LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback)
 doTransaction Checks out the transaction database owned by the shard containing the given ledger, and invokes the provided callback with a session to that database. More...
 
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 the given shard index, until all shards in range have been visited or the callback returns false. More...
 
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 from the given shard index, until all shards in range have been visited or the callback returns false. More...
 
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 the given shard index, until all shards in range have been visited or the callback returns false. More...
 
bool iterateTransactionBack (std::optional< std::uint32_t > firstIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback)
 iterateTransactionBack Checks out transaction databases for all shards in descending order starting from the given shard index, until all shards in range have been visited or the callback returns false. More...
 

Private Attributes

Applicationapp_
 
const bool useTxTables_
 
beast::Journal j_
 
std::unique_ptr< DatabaseConlgrdb_
 
std::unique_ptr< DatabaseContxdb_
 
std::unique_ptr< DatabaseConlgrMetaDB_
 
std::unique_ptr< DatabaseContxMetaDB_
 

Detailed Description

Definition at line 39 of file SQLiteDatabase.cpp.

Member Typedef Documentation

◆ AccountTx

Definition at line 85 of file RelationalDatabase.h.

◆ AccountTxs

Definition at line 86 of file RelationalDatabase.h.

◆ txnMetaLedgerType

Definition at line 87 of file RelationalDatabase.h.

◆ MetaTxsList

Definition at line 88 of file RelationalDatabase.h.

◆ LedgerSequence

using ripple::RelationalDatabase::LedgerSequence = uint32_t
inherited

Definition at line 90 of file RelationalDatabase.h.

◆ LedgerHash

Definition at line 91 of file RelationalDatabase.h.

◆ LedgerShortcut

Definition at line 92 of file RelationalDatabase.h.

◆ LedgerSpecifier

Definition at line 94 of file RelationalDatabase.h.

Constructor & Destructor Documentation

◆ SQLiteDatabaseImp()

ripple::SQLiteDatabaseImp::SQLiteDatabaseImp ( Application app,
Config const &  config,
JobQueue jobQueue 
)

Definition at line 42 of file SQLiteDatabase.cpp.

Member Function Documentation

◆ getMinLedgerSeq()

std::optional< LedgerIndex > ripple::SQLiteDatabaseImp::getMinLedgerSeq ( )
overridevirtual

getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.

Returns
Ledger sequence or no value if no ledgers exist.

Implements ripple::RelationalDatabase.

Definition at line 472 of file SQLiteDatabase.cpp.

◆ getTransactionsMinLedgerSeq()

std::optional< LedgerIndex > ripple::SQLiteDatabaseImp::getTransactionsMinLedgerSeq ( )
overridevirtual

getTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the Transactions table.

Returns
Ledger sequence or no value if no ledgers exist.

Implements ripple::SQLiteDatabase.

Definition at line 499 of file SQLiteDatabase.cpp.

◆ getAccountTransactionsMinLedgerSeq()

std::optional< LedgerIndex > ripple::SQLiteDatabaseImp::getAccountTransactionsMinLedgerSeq ( )
overridevirtual

getAccountTransactionsMinLedgerSeq Returns the minimum ledger sequence stored in the AccountTransactions table.

Returns
Ledger sequence or no value if no ledgers exist.

Implements ripple::SQLiteDatabase.

Definition at line 526 of file SQLiteDatabase.cpp.

◆ getMaxLedgerSeq()

std::optional< LedgerIndex > ripple::SQLiteDatabaseImp::getMaxLedgerSeq ( )
overridevirtual

getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.

Returns
Ledger sequence or none if no ledgers exist.

Implements ripple::RelationalDatabase.

Definition at line 554 of file SQLiteDatabase.cpp.

◆ deleteTransactionByLedgerSeq()

void ripple::SQLiteDatabaseImp::deleteTransactionByLedgerSeq ( LedgerIndex  ledgerSeq)
overridevirtual

deleteTransactionByLedgerSeq Deletes transactions from the ledger with the given sequence.

Parameters
ledgerSeqLedger sequence.

Implements ripple::SQLiteDatabase.

Definition at line 578 of file SQLiteDatabase.cpp.

◆ deleteBeforeLedgerSeq()

void ripple::SQLiteDatabaseImp::deleteBeforeLedgerSeq ( LedgerIndex  ledgerSeq)
overridevirtual

deleteBeforeLedgerSeq Deletes all ledgers with a sequence number less than or equal to the given ledger sequence.

Parameters
ledgerSeqLedger sequence.

Implements ripple::SQLiteDatabase.

Definition at line 602 of file SQLiteDatabase.cpp.

◆ deleteTransactionsBeforeLedgerSeq()

void ripple::SQLiteDatabaseImp::deleteTransactionsBeforeLedgerSeq ( LedgerIndex  ledgerSeq)
overridevirtual

deleteTransactionsBeforeLedgerSeq Deletes all transactions with a sequence number less than or equal to the given ledger sequence.

Parameters
ledgerSeqLedger sequence.

Implements ripple::SQLiteDatabase.

Definition at line 625 of file SQLiteDatabase.cpp.

◆ deleteAccountTransactionsBeforeLedgerSeq()

void ripple::SQLiteDatabaseImp::deleteAccountTransactionsBeforeLedgerSeq ( LedgerIndex  ledgerSeq)
overridevirtual

deleteAccountTransactionsBeforeLedgerSeq Deletes all account transactions with a sequence number less than or equal to the given ledger sequence.

Parameters
ledgerSeqLedger sequence.

Implements ripple::SQLiteDatabase.

Definition at line 651 of file SQLiteDatabase.cpp.

◆ getTransactionCount()

std::size_t ripple::SQLiteDatabaseImp::getTransactionCount ( )
overridevirtual

getTransactionCount Returns the number of transactions.

Returns
Number of transactions.

Implements ripple::SQLiteDatabase.

Definition at line 678 of file SQLiteDatabase.cpp.

◆ getAccountTransactionCount()

std::size_t ripple::SQLiteDatabaseImp::getAccountTransactionCount ( )
overridevirtual

getAccountTransactionCount Returns the number of account transactions.

Returns
Number of account transactions.

Implements ripple::SQLiteDatabase.

Definition at line 705 of file SQLiteDatabase.cpp.

◆ getLedgerCountMinMax()

RelationalDatabase::CountMinMax ripple::SQLiteDatabaseImp::getLedgerCountMinMax ( )
overridevirtual

getLedgerCountMinMax Returns the minimum ledger sequence, maximum ledger sequence and total number of saved ledgers.

Returns
Struct CountMinMax which contains the minimum sequence, maximum sequence and number of ledgers.

Implements ripple::SQLiteDatabase.

Definition at line 732 of file SQLiteDatabase.cpp.

◆ saveValidatedLedger()

bool ripple::SQLiteDatabaseImp::saveValidatedLedger ( std::shared_ptr< Ledger const > const &  ledger,
bool  current 
)
overridevirtual

saveValidatedLedger Saves a ledger into the database.

Parameters
ledgerThe ledger.
currentTrue if the ledger is current.
Returns
True if saving was successful.

Implements ripple::SQLiteDatabase.

Definition at line 763 of file SQLiteDatabase.cpp.

◆ getLedgerInfoByIndex()

std::optional< LedgerInfo > ripple::SQLiteDatabaseImp::getLedgerInfoByIndex ( LedgerIndex  ledgerSeq)
overridevirtual

getLedgerInfoByIndex Returns a ledger by its sequence.

Parameters
ledgerSeqLedger sequence.
Returns
The ledger if found, otherwise no value.

Implements ripple::RelationalDatabase.

Definition at line 799 of file SQLiteDatabase.cpp.

◆ getNewestLedgerInfo()

std::optional< LedgerInfo > ripple::SQLiteDatabaseImp::getNewestLedgerInfo ( )
overridevirtual

getNewestLedgerInfo Returns the info of the newest saved ledger.

Returns
Ledger info if found, otherwise no value.

Implements ripple::RelationalDatabase.

Definition at line 824 of file SQLiteDatabase.cpp.

◆ getLimitedOldestLedgerInfo()

std::optional< LedgerInfo > ripple::SQLiteDatabaseImp::getLimitedOldestLedgerInfo ( LedgerIndex  ledgerFirstIndex)
overridevirtual

getLimitedOldestLedgerInfo Returns the info of the oldest ledger whose sequence number is greater than or equal to the given sequence number.

Parameters
ledgerFirstIndexMinimum ledger sequence.
Returns
Ledger info if found, otherwise no value.

Implements ripple::SQLiteDatabase.

Definition at line 855 of file SQLiteDatabase.cpp.

◆ getLimitedNewestLedgerInfo()

std::optional< LedgerInfo > ripple::SQLiteDatabaseImp::getLimitedNewestLedgerInfo ( LedgerIndex  ledgerFirstIndex)
overridevirtual

getLimitedNewestLedgerInfo Returns the info of the newest ledger whose sequence number is greater than or equal to the given sequence number.

Parameters
ledgerFirstIndexMinimum ledger sequence.
Returns
Ledger info if found, otherwise no value.

Implements ripple::SQLiteDatabase.

Definition at line 889 of file SQLiteDatabase.cpp.

◆ getLedgerInfoByHash()

std::optional< LedgerInfo > ripple::SQLiteDatabaseImp::getLedgerInfoByHash ( uint256 const &  ledgerHash)
overridevirtual

getLedgerInfoByHash Returns the info of the ledger with given hash.

Parameters
ledgerHashHash of the ledger.
Returns
Ledger if found, otherwise no value.

Implements ripple::RelationalDatabase.

Definition at line 922 of file SQLiteDatabase.cpp.

◆ getHashByIndex()

uint256 ripple::SQLiteDatabaseImp::getHashByIndex ( LedgerIndex  ledgerIndex)
overridevirtual

getHashByIndex Returns the hash of the ledger with the given sequence.

Parameters
ledgerIndexLedger sequence.
Returns
Hash of the ledger.

Implements ripple::RelationalDatabase.

Definition at line 955 of file SQLiteDatabase.cpp.

◆ getHashesByIndex() [1/2]

std::optional< LedgerHashPair > ripple::SQLiteDatabaseImp::getHashesByIndex ( LedgerIndex  ledgerIndex)
overridevirtual

getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.

Parameters
ledgerIndexLedger sequence.
Returns
Struct LedgerHashPair which contains hashes of the ledger and its parent.

Implements ripple::RelationalDatabase.

Definition at line 980 of file SQLiteDatabase.cpp.

◆ getHashesByIndex() [2/2]

std::map< LedgerIndex, LedgerHashPair > ripple::SQLiteDatabaseImp::getHashesByIndex ( LedgerIndex  minSeq,
LedgerIndex  maxSeq 
)
overridevirtual

getHashesByIndex Returns hashes of each ledger and its parent for all ledgers within the provided range.

Parameters
minSeqMinimum ledger sequence.
maxSeqMaximum ledger sequence.
Returns
Container that maps the sequence number of a found ledger to the struct LedgerHashPair which contains the hashes of the ledger and its parent.

Implements ripple::RelationalDatabase.

Definition at line 1005 of file SQLiteDatabase.cpp.

◆ getTxHistory()

std::vector< std::shared_ptr< Transaction > > ripple::SQLiteDatabaseImp::getTxHistory ( LedgerIndex  startIndex)
overridevirtual

getTxHistory Returns the 20 most recent transactions starting from the given number.

Parameters
startIndexFirst number of returned entry.
Returns
Vector of shared pointers to transactions sorted in descending order by ledger sequence.

Implements ripple::RelationalDatabase.

Definition at line 1040 of file SQLiteDatabase.cpp.

◆ getOldestAccountTxs()

RelationalDatabase::AccountTxs ripple::SQLiteDatabaseImp::getOldestAccountTxs ( AccountTxOptions const &  options)
overridevirtual

getOldestAccountTxs Returns the oldest transactions for the account that matches the given criteria starting from the provided offset.

Parameters
optionsStruct AccountTxOptions which contains the criteria to match: the account, ledger search range, the offset of the first entry to return, the number of transactions to return, a flag if this number is unlimited.
Returns
Vector of pairs of found transactions and their metadata sorted in ascending order by account sequence.

Implements ripple::SQLiteDatabase.

Definition at line 1085 of file SQLiteDatabase.cpp.

◆ getNewestAccountTxs()

RelationalDatabase::AccountTxs ripple::SQLiteDatabaseImp::getNewestAccountTxs ( AccountTxOptions const &  options)
overridevirtual

getNewestAccountTxs Returns the newest transactions for the account that matches the given criteria starting from the provided offset.

Parameters
optionsStruct AccountTxOptions which contains the criteria to match: the account, the ledger search range, the offset of the first entry to return, the number of transactions to return, a flag if this number unlimited.
Returns
Vector of pairs of found transactions and their metadata sorted in descending order by account sequence.

Implements ripple::SQLiteDatabase.

Definition at line 1145 of file SQLiteDatabase.cpp.

◆ getOldestAccountTxsB()

RelationalDatabase::MetaTxsList ripple::SQLiteDatabaseImp::getOldestAccountTxsB ( AccountTxOptions const &  options)
overridevirtual

getOldestAccountTxsB Returns the oldest transactions in binary form for the account that matches the given criteria starting from the provided offset.

Parameters
optionsStruct AccountTxOptions which contains the criteria to match: the account, the ledger search range, the offset of the first entry to return, the number of transactions to return, a flag if this number unlimited.
Returns
Vector of tuples of found transactions, their metadata and account sequences sorted in ascending order by account sequence.

Implements ripple::SQLiteDatabase.

Definition at line 1205 of file SQLiteDatabase.cpp.

◆ getNewestAccountTxsB()

RelationalDatabase::MetaTxsList ripple::SQLiteDatabaseImp::getNewestAccountTxsB ( AccountTxOptions const &  options)
overridevirtual

getNewestAccountTxsB Returns the newest transactions in binary form for the account that matches the given criteria starting from the provided offset.

Parameters
optionsStruct AccountTxOptions which contains the criteria to match: the account, the ledger search range, the offset of the first entry to return, the number of transactions to return, a flag if this number is unlimited.
Returns
Vector of tuples of found transactions, their metadata and account sequences sorted in descending order by account sequence.

Implements ripple::SQLiteDatabase.

Definition at line 1261 of file SQLiteDatabase.cpp.

◆ oldestAccountTxPage()

std::pair< RelationalDatabase::AccountTxs, std::optional< RelationalDatabase::AccountTxMarker > > ripple::SQLiteDatabaseImp::oldestAccountTxPage ( AccountTxPageOptions const &  options)
overridevirtual

oldestAccountTxPage Returns the oldest transactions for the account that matches the given criteria starting from the provided marker.

Parameters
optionsStruct AccountTxPageOptions which contains the criteria to match: the account, the ledger search range, the marker of first returned entry, the number of transactions to return, a flag if this number is unlimited.
Returns
Vector of pairs of found transactions and their metadata sorted in ascending order by account sequence and a marker for the next search if the search was not finished.

Implements ripple::SQLiteDatabase.

Definition at line 1319 of file SQLiteDatabase.cpp.

◆ newestAccountTxPage()

std::pair< RelationalDatabase::AccountTxs, std::optional< RelationalDatabase::AccountTxMarker > > ripple::SQLiteDatabaseImp::newestAccountTxPage ( AccountTxPageOptions const &  options)
overridevirtual

newestAccountTxPage Returns the newest transactions for the account that matches the given criteria starting from the provided marker.

Parameters
optionsStruct AccountTxPageOptions which contains the criteria to match: the account, the ledger search range, the marker of the first returned entry, the number of transactions to return, a flag if this number unlimited.
Returns
Vector of pairs of found transactions and their metadata sorted in descending order by account sequence and a marker for the next search if the search was not finished.

Implements ripple::SQLiteDatabase.

Definition at line 1381 of file SQLiteDatabase.cpp.

◆ oldestAccountTxPageB()

std::pair< RelationalDatabase::MetaTxsList, std::optional< RelationalDatabase::AccountTxMarker > > ripple::SQLiteDatabaseImp::oldestAccountTxPageB ( AccountTxPageOptions const &  options)
overridevirtual

oldestAccountTxPageB Returns the oldest transactions in binary form for the account that matches the given criteria starting from the provided marker.

Parameters
optionsStruct AccountTxPageOptions which contains criteria to match: the account, the ledger search range, the marker of the first returned entry, the number of transactions to return, a flag if this number unlimited.
Returns
Vector of tuples of found transactions, their metadata and account sequences sorted in ascending order by account sequence and a marker for the next search if the search was not finished.

Implements ripple::SQLiteDatabase.

Definition at line 1443 of file SQLiteDatabase.cpp.

◆ newestAccountTxPageB()

std::pair< RelationalDatabase::MetaTxsList, std::optional< RelationalDatabase::AccountTxMarker > > ripple::SQLiteDatabaseImp::newestAccountTxPageB ( AccountTxPageOptions const &  options)
overridevirtual

newestAccountTxPageB Returns the newest transactions in binary form for the account that matches the given criteria starting from the provided marker.

Parameters
optionsStruct AccountTxPageOptions which contains the criteria to match: the account, the ledger search range, the marker of the first returned entry, the number of transactions to return, a flag if this number is unlimited.
Returns
Vector of tuples of found transactions, their metadata and account sequences sorted in descending order by account sequence and a marker for the next search if the search was not finished.

Implements ripple::SQLiteDatabase.

Definition at line 1504 of file SQLiteDatabase.cpp.

◆ getTransaction() [1/2]

std::variant< RelationalDatabase::AccountTx, TxSearched > ripple::SQLiteDatabaseImp::getTransaction ( uint256 const &  id,
std::optional< ClosedInterval< std::uint32_t >> const &  range,
error_code_i ec 
)
override

Definition at line 1563 of file SQLiteDatabase.cpp.

◆ ledgerDbHasSpace()

bool ripple::SQLiteDatabaseImp::ledgerDbHasSpace ( Config const &  config)
overridevirtual

ledgerDbHasSpace Checks if the ledger database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implements ripple::RelationalDatabase.

Definition at line 1612 of file SQLiteDatabase.cpp.

◆ transactionDbHasSpace()

bool ripple::SQLiteDatabaseImp::transactionDbHasSpace ( Config const &  config)
overridevirtual

transactionDbHasSpace Checks if the transaction database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implements ripple::RelationalDatabase.

Definition at line 1632 of file SQLiteDatabase.cpp.

◆ getKBUsedAll()

std::uint32_t ripple::SQLiteDatabaseImp::getKBUsedAll ( )
overridevirtual

getKBUsedAll Returns the amount of space used by all databases.

Returns
Space in kilobytes.

Implements ripple::SQLiteDatabase.

Definition at line 1655 of file SQLiteDatabase.cpp.

◆ getKBUsedLedger()

std::uint32_t ripple::SQLiteDatabaseImp::getKBUsedLedger ( )
overridevirtual

getKBUsedLedger Returns the amount of space space used by the ledger database.

Returns
Space in kilobytes.

Implements ripple::SQLiteDatabase.

Definition at line 1677 of file SQLiteDatabase.cpp.

◆ getKBUsedTransaction()

std::uint32_t ripple::SQLiteDatabaseImp::getKBUsedTransaction ( )
overridevirtual

getKBUsedTransaction Returns the amount of space used by the transaction database.

Returns
Space in kilobytes.

Implements ripple::SQLiteDatabase.

Definition at line 1699 of file SQLiteDatabase.cpp.

◆ closeLedgerDB()

void ripple::SQLiteDatabaseImp::closeLedgerDB ( )
overridevirtual

Closes the ledger database.

Implements ripple::SQLiteDatabase.

Definition at line 1724 of file SQLiteDatabase.cpp.

◆ closeTransactionDB()

void ripple::SQLiteDatabaseImp::closeTransactionDB ( )
overridevirtual

Closes the transaction database.

Implements ripple::SQLiteDatabase.

Definition at line 1730 of file SQLiteDatabase.cpp.

◆ makeLedgerDBs()

bool ripple::SQLiteDatabaseImp::makeLedgerDBs ( Config const &  config,
DatabaseCon::Setup const &  setup,
DatabaseCon::CheckpointerSetup const &  checkpointerSetup 
)
private

makeLedgerDBs Opens ledger and transaction databases for the node store, and stores their descriptors in private member variables.

Parameters
configConfig object.
setupPath to the databases and other opening parameters.
checkpointerSetupCheckpointer parameters.
Returns
True if node databases opened successfully.

Definition at line 444 of file SQLiteDatabase.cpp.

◆ makeMetaDBs()

bool ripple::SQLiteDatabaseImp::makeMetaDBs ( Config const &  config,
DatabaseCon::Setup const &  setup,
DatabaseCon::CheckpointerSetup const &  checkpointerSetup 
)
private

makeMetaDBs Opens shard index lookup databases, and stores their descriptors in private member variables.

Parameters
configConfig object.
setupPath to the databases and other opening parameters.
checkpointerSetupCheckpointer parameters.
Returns
True if node databases opened successfully.

Definition at line 457 of file SQLiteDatabase.cpp.

◆ seqToShardIndex()

std::uint32_t ripple::SQLiteDatabaseImp::seqToShardIndex ( LedgerIndex  ledgerSeq)
private

seqToShardIndex Provides the index of the shard that stores the ledger with the given sequence.

Parameters
ledgerSeqLedger sequence.
Returns
Shard index.

Definition at line 235 of file SQLiteDatabase.cpp.

◆ firstLedgerSeq()

LedgerIndex ripple::SQLiteDatabaseImp::firstLedgerSeq ( std::uint32_t  shardIndex)
private

firstLedgerSeq Returns the sequence of the first ledger stored in the shard specified by the shard index parameter.

Parameters
shardIndexShard Index.
Returns
First ledger sequence.

Definition at line 247 of file SQLiteDatabase.cpp.

◆ lastLedgerSeq()

LedgerIndex ripple::SQLiteDatabaseImp::lastLedgerSeq ( std::uint32_t  shardIndex)
private

lastLedgerSeq Returns the sequence of the last ledger stored in the shard specified by the shard index parameter.

Parameters
shardIndexShard Index.
Returns
Last ledger sequence.

Definition at line 259 of file SQLiteDatabase.cpp.

◆ existsLedger()

bool ripple::SQLiteDatabaseImp::existsLedger ( )
private

existsLedger Checks if the node store ledger database exists.

Returns
True if the node store ledger database exists.

Definition at line 269 of file SQLiteDatabase.cpp.

◆ existsTransaction()

bool ripple::SQLiteDatabaseImp::existsTransaction ( )
private

existsTransaction Checks if the node store transaction database exists.

Returns
True if the node store transaction database exists.

Definition at line 280 of file SQLiteDatabase.cpp.

◆ shardStoreExists()

bool ripple::SQLiteDatabaseImp::shardStoreExists ( )
private

shardStoreExists Checks whether the shard store exists

Returns
True if the shard store exists

Definition at line 290 of file SQLiteDatabase.cpp.

◆ checkoutLedger()

auto ripple::SQLiteDatabaseImp::checkoutLedger ( )
private

checkoutTransaction Checks out and returns node store ledger database.

Returns
Session to the node store ledger database.

Definition at line 301 of file SQLiteDatabase.cpp.

◆ checkoutTransaction()

auto ripple::SQLiteDatabaseImp::checkoutTransaction ( )
private

checkoutTransaction Checks out and returns the node store transaction database.

Returns
Session to the node store transaction database.

Definition at line 312 of file SQLiteDatabase.cpp.

◆ doLedger()

bool ripple::SQLiteDatabaseImp::doLedger ( LedgerIndex  ledgerSeq,
std::function< bool(soci::session &session)> const &  callback 
)
private

doLedger Checks out the ledger database owned by the shard containing the given ledger, and invokes the provided callback with a session to that database.

Parameters
ledgerSeqLedger sequence.
callbackCallback function to call.
Returns
Value returned by callback function.

Definition at line 326 of file SQLiteDatabase.cpp.

◆ doTransaction()

bool ripple::SQLiteDatabaseImp::doTransaction ( LedgerIndex  ledgerSeq,
std::function< bool(soci::session &session)> const &  callback 
)
private

doTransaction Checks out the transaction database owned by the shard containing the given ledger, and invokes the provided callback with a session to that database.

Parameters
ledgerSeqLedger sequence.
callbackCallback function to call.
Returns
Value returned by callback function.

Definition at line 343 of file SQLiteDatabase.cpp.

◆ iterateLedgerForward()

bool ripple::SQLiteDatabaseImp::iterateLedgerForward ( std::optional< std::uint32_t firstIndex,
std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &  callback 
)
private

iterateLedgerForward Checks out ledger databases for all shards in ascending order starting from the given shard index, until all shards in range have been visited or the callback returns false.

For each visited shard, we invoke the provided callback with a session to the database and the current shard index.

Parameters
firstIndexFirst shard index to visit or no value if all shards should be visited.
callbackCallback function to call.
Returns
True if each callback function returned true, false otherwise.

Definition at line 363 of file SQLiteDatabase.cpp.

◆ iterateTransactionForward()

bool ripple::SQLiteDatabaseImp::iterateTransactionForward ( std::optional< std::uint32_t firstIndex,
std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &  callback 
)
private

iterateTransactionForward Checks out transaction databases for all shards in ascending order starting from the given shard index, until all shards in range have been visited or the callback returns false.

For each visited shard, we invoke the provided callback with a session to the database and the current shard index.

Parameters
firstIndexFirst shard index to visit or no value if all shards should be visited.
callbackCallback function to call.
Returns
True if each callback function returned true, false otherwise.

Definition at line 386 of file SQLiteDatabase.cpp.

◆ iterateLedgerBack()

bool ripple::SQLiteDatabaseImp::iterateLedgerBack ( std::optional< std::uint32_t firstIndex,
std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &  callback 
)
private

iterateLedgerBack Checks out ledger databases for all shards in descending order starting from the given shard index, until all shards in range have been visited or the callback returns false.

For each visited shard, we invoke the provided callback with a session to the database and the current shard index.

Parameters
firstIndexFirst shard index to visit or no value if all shards should be visited.
callbackCallback function to call.
Returns
True if each callback function returned true, false otherwise.

Definition at line 409 of file SQLiteDatabase.cpp.

◆ iterateTransactionBack()

bool ripple::SQLiteDatabaseImp::iterateTransactionBack ( std::optional< std::uint32_t firstIndex,
std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &  callback 
)
private

iterateTransactionBack Checks out transaction databases for all shards in descending order starting from the given shard index, until all shards in range have been visited or the callback returns false.

For each visited shard, we invoke the provided callback with a session to the database and the current shard index.

Parameters
firstIndexFirst shard index to visit or no value if all shards should be visited.
callbackCallback function to call.
Returns
True if each callback function returned true, false otherwise.

Definition at line 432 of file SQLiteDatabase.cpp.

◆ getTransaction() [2/2]

virtual std::variant<AccountTx, TxSearched> ripple::SQLiteDatabase::getTransaction ( uint256 const &  id,
std::optional< ClosedInterval< uint32_t >> const &  range,
error_code_i ec 
)
pure virtualinherited

getTransaction Returns the transaction with the given hash.

If a range is provided but the transaction is not found, then check if all ledgers in the range are present in the database.

Parameters
idHash of the transaction.
rangeRange of ledgers to check, if present.
ecDefault error code value.
Returns
Transaction and its metadata if found, otherwise TxSearched::all if a range is provided and all ledgers from the range are present in the database, TxSearched::some if a range is provided and not all ledgers are present, TxSearched::unknown if the range is not provided or a deserializing error occurred. In the last case the error code is returned via the ec parameter, in other cases the default error code is not changed.

◆ init()

std::unique_ptr< RelationalDatabase > ripple::RelationalDatabase::init ( Application app,
Config const &  config,
JobQueue jobQueue 
)
staticinherited

init Creates and returns an appropriate RelationalDatabase instance based on configuration.

Parameters
appApplication object.
configConfig object.
jobQueueJobQueue object.
Returns
Unique pointer to the interface.

Definition at line 34 of file RelationalDatabase.cpp.

Member Data Documentation

◆ app_

Application& ripple::SQLiteDatabaseImp::app_
private

Definition at line 194 of file SQLiteDatabase.cpp.

◆ useTxTables_

const bool ripple::SQLiteDatabaseImp::useTxTables_
private

Definition at line 195 of file SQLiteDatabase.cpp.

◆ j_

beast::Journal ripple::SQLiteDatabaseImp::j_
private

Definition at line 196 of file SQLiteDatabase.cpp.

◆ lgrdb_

std::unique_ptr<DatabaseCon> ripple::SQLiteDatabaseImp::lgrdb_
private

Definition at line 197 of file SQLiteDatabase.cpp.

◆ txdb_

std::unique_ptr<DatabaseCon> ripple::SQLiteDatabaseImp::txdb_
private

Definition at line 197 of file SQLiteDatabase.cpp.

◆ lgrMetaDB_

std::unique_ptr<DatabaseCon> ripple::SQLiteDatabaseImp::lgrMetaDB_
private

Definition at line 198 of file SQLiteDatabase.cpp.

◆ txMetaDB_

std::unique_ptr<DatabaseCon> ripple::SQLiteDatabaseImp::txMetaDB_
private

Definition at line 198 of file SQLiteDatabase.cpp.