rippled
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ripple::RelationalDatabase Class Referenceabstract
Inheritance diagram for ripple::RelationalDatabase:
Inheritance graph
[legend]

Classes

struct  AccountTransactionsData
 Struct used to keep track of what to write to transactions and account_transactions tables in Postgres. More...
 
struct  AccountTxArgs
 
struct  AccountTxMarker
 
struct  AccountTxOptions
 
struct  AccountTxPageOptions
 
struct  AccountTxResult
 
struct  CountMinMax
 

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

virtual ~RelationalDatabase ()=default
 
virtual std::optional< LedgerIndexgetMinLedgerSeq ()=0
 getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table. More...
 
virtual std::optional< LedgerIndexgetMaxLedgerSeq ()=0
 getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table. More...
 
virtual std::optional< LedgerInfogetLedgerInfoByIndex (LedgerIndex ledgerSeq)=0
 getLedgerInfoByIndex Returns a ledger by its sequence. More...
 
virtual std::optional< LedgerInfogetNewestLedgerInfo ()=0
 getNewestLedgerInfo Returns the info of the newest saved ledger. More...
 
virtual std::optional< LedgerInfogetLedgerInfoByHash (uint256 const &ledgerHash)=0
 getLedgerInfoByHash Returns the info of the ledger with given hash. More...
 
virtual uint256 getHashByIndex (LedgerIndex ledgerIndex)=0
 getHashByIndex Returns the hash of the ledger with the given sequence. More...
 
virtual std::optional< LedgerHashPairgetHashesByIndex (LedgerIndex ledgerIndex)=0
 getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex. More...
 
virtual std::map< LedgerIndex, LedgerHashPairgetHashesByIndex (LedgerIndex minSeq, LedgerIndex maxSeq)=0
 getHashesByIndex Returns hashes of each ledger and its parent for all ledgers within the provided range. More...
 
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory (LedgerIndex startIndex)=0
 getTxHistory Returns the 20 most recent transactions starting from the given number. More...
 
virtual bool ledgerDbHasSpace (Config const &config)=0
 ledgerDbHasSpace Checks if the ledger database has available space. More...
 
virtual bool transactionDbHasSpace (Config const &config)=0
 transactionDbHasSpace Checks if the transaction database has available space. 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...
 

Detailed Description

Definition at line 48 of file RelationalDatabase.h.

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

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

◆ ~RelationalDatabase()

virtual ripple::RelationalDatabase::~RelationalDatabase ( )
virtualdefault

Member Function Documentation

◆ init()

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

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.

◆ getMinLedgerSeq()

virtual std::optional<LedgerIndex> ripple::RelationalDatabase::getMinLedgerSeq ( )
pure virtual

getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.

Returns
Ledger sequence or no value if no ledgers exist.

Implemented in ripple::PostgresDatabaseImp, and ripple::SQLiteDatabaseImp.

◆ getMaxLedgerSeq()

virtual std::optional<LedgerIndex> ripple::RelationalDatabase::getMaxLedgerSeq ( )
pure virtual

getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers table.

Returns
Ledger sequence or none if no ledgers exist.

Implemented in ripple::PostgresDatabaseImp, and ripple::SQLiteDatabaseImp.

◆ getLedgerInfoByIndex()

virtual std::optional<LedgerInfo> ripple::RelationalDatabase::getLedgerInfoByIndex ( LedgerIndex  ledgerSeq)
pure virtual

getLedgerInfoByIndex Returns a ledger by its sequence.

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

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getNewestLedgerInfo()

virtual std::optional<LedgerInfo> ripple::RelationalDatabase::getNewestLedgerInfo ( )
pure virtual

getNewestLedgerInfo Returns the info of the newest saved ledger.

Returns
Ledger info if found, otherwise no value.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getLedgerInfoByHash()

virtual std::optional<LedgerInfo> ripple::RelationalDatabase::getLedgerInfoByHash ( uint256 const &  ledgerHash)
pure virtual

getLedgerInfoByHash Returns the info of the ledger with given hash.

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

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getHashByIndex()

virtual uint256 ripple::RelationalDatabase::getHashByIndex ( LedgerIndex  ledgerIndex)
pure virtual

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

Parameters
ledgerIndexLedger sequence.
Returns
Hash of the ledger.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getHashesByIndex() [1/2]

virtual std::optional<LedgerHashPair> ripple::RelationalDatabase::getHashesByIndex ( LedgerIndex  ledgerIndex)
pure virtual

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.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getHashesByIndex() [2/2]

virtual std::map<LedgerIndex, LedgerHashPair> ripple::RelationalDatabase::getHashesByIndex ( LedgerIndex  minSeq,
LedgerIndex  maxSeq 
)
pure virtual

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.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ getTxHistory()

virtual std::vector<std::shared_ptr<Transaction> > ripple::RelationalDatabase::getTxHistory ( LedgerIndex  startIndex)
pure virtual

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.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ ledgerDbHasSpace()

virtual bool ripple::RelationalDatabase::ledgerDbHasSpace ( Config const &  config)
pure virtual

ledgerDbHasSpace Checks if the ledger database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.

◆ transactionDbHasSpace()

virtual bool ripple::RelationalDatabase::transactionDbHasSpace ( Config const &  config)
pure virtual

transactionDbHasSpace Checks if the transaction database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implemented in ripple::SQLiteDatabaseImp, and ripple::PostgresDatabaseImp.