rippled
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ripple::PostgresDatabase Class Referenceabstract
Inheritance diagram for ripple::PostgresDatabase:
Inheritance graph
[legend]
Collaboration diagram for ripple::PostgresDatabase:
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

virtual void stop ()=0
 
virtual void sweep ()=0
 sweep Sweeps the database. More...
 
virtual std::string getCompleteLedgers ()=0
 getCompleteLedgers Returns a string which contains a list of completed ledgers. More...
 
virtual std::chrono::seconds getValidatedLedgerAge ()=0
 getValidatedLedgerAge Returns the age of the last validated ledger. More...
 
virtual bool writeLedgerAndTransactions (LedgerInfo const &info, std::vector< AccountTransactionsData > const &accountTxData)=0
 writeLedgerAndTransactions Writes new ledger and transaction data into the database. More...
 
virtual std::vector< uint256getTxHashes (LedgerIndex seq)=0
 getTxHashes Returns a vector of the hashes of transactions belonging to the ledger with the provided sequence. More...
 
virtual std::pair< AccountTxResult, RPC::StatusgetAccountTx (AccountTxArgs const &args)=0
 getAccountTx Get the last account transactions specified by the AccountTxArgs struct. More...
 
virtual Transaction::Locator locateTransaction (uint256 const &id)=0
 locateTransaction Returns information used to locate a transaction. More...
 
virtual bool isCaughtUp (std::string &reason)=0
 isCaughtUp returns whether the database is caught up with the network More...
 
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 27 of file PostgresDatabase.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

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.

Member Function Documentation

◆ stop()

virtual void ripple::PostgresDatabase::stop ( )
pure virtual

Implemented in ripple::PostgresDatabaseImp.

◆ sweep()

virtual void ripple::PostgresDatabase::sweep ( )
pure virtual

sweep Sweeps the database.

Implemented in ripple::PostgresDatabaseImp.

◆ getCompleteLedgers()

virtual std::string ripple::PostgresDatabase::getCompleteLedgers ( )
pure virtual

getCompleteLedgers Returns a string which contains a list of completed ledgers.

Returns
String with completed ledger sequences

Implemented in ripple::PostgresDatabaseImp.

◆ getValidatedLedgerAge()

virtual std::chrono::seconds ripple::PostgresDatabase::getValidatedLedgerAge ( )
pure virtual

getValidatedLedgerAge Returns the age of the last validated ledger.

Returns
Age of the last validated ledger in seconds

Implemented in ripple::PostgresDatabaseImp.

◆ writeLedgerAndTransactions()

virtual bool ripple::PostgresDatabase::writeLedgerAndTransactions ( LedgerInfo const &  info,
std::vector< AccountTransactionsData > const &  accountTxData 
)
pure virtual

writeLedgerAndTransactions Writes new ledger and transaction data into the database.

Parameters
infoLedger info to write.
accountTxDataTransaction data to write
Returns
True on success, false on failure.

Implemented in ripple::PostgresDatabaseImp.

◆ getTxHashes()

virtual std::vector<uint256> ripple::PostgresDatabase::getTxHashes ( LedgerIndex  seq)
pure virtual

getTxHashes Returns a vector of the hashes of transactions belonging to the ledger with the provided sequence.

Parameters
seqLedger sequence
Returns
Vector of transaction hashes

Implemented in ripple::PostgresDatabaseImp.

◆ getAccountTx()

virtual std::pair<AccountTxResult, RPC::Status> ripple::PostgresDatabase::getAccountTx ( AccountTxArgs const &  args)
pure virtual

getAccountTx Get the last account transactions specified by the AccountTxArgs struct.

Parameters
argsArguments which specify the account and which transactions to return.
Returns
Vector of account transactions and the RPC status response.

Implemented in ripple::PostgresDatabaseImp.

◆ locateTransaction()

virtual Transaction::Locator ripple::PostgresDatabase::locateTransaction ( uint256 const &  id)
pure virtual

locateTransaction Returns information used to locate a transaction.

Parameters
idHash of the transaction.
Returns
Information used to locate a transaction. Contains a nodestore hash and a ledger sequence pair if the transaction was found. Otherwise, contains the range of ledgers present in the database at the time of search.

Implemented in ripple::PostgresDatabaseImp.

◆ isCaughtUp()

virtual bool ripple::PostgresDatabase::isCaughtUp ( std::string reason)
pure virtual

isCaughtUp returns whether the database is caught up with the network

Parameters
[out]reasonif the database is not caught up, reason contains a helpful message describing why
Returns
false if the most recently written ledger has a close time over 3 minutes ago, or if there are no ledgers in the database. true otherwise

Implemented in ripple::PostgresDatabaseImp.

◆ 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.

◆ getMinLedgerSeq()

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

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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 virtualinherited

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.