rippled
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ripple::RelationalDBInterfacePostgres Class Referenceabstract
Inheritance diagram for ripple::RelationalDBInterfacePostgres:
Inheritance graph
[legend]
Collaboration diagram for ripple::RelationalDBInterfacePostgres:
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
 There is only one implementation of this interface: RelationalDBInterfacePostgresImp. More...
 
virtual void sweep ()=0
 sweep Sweep the database. More...
 
virtual std::string getCompleteLedgers ()=0
 getCompleteLedgers Returns string which contains list of completed ledgers. More...
 
virtual std::chrono::seconds getValidatedLedgerAge ()=0
 getValidatedLedgerAge Returns age of last validated ledger. More...
 
virtual bool writeLedgerAndTransactions (LedgerInfo const &info, std::vector< AccountTransactionsData > const &accountTxData)=0
 writeLedgerAndTransactions Write new ledger and transaction data into database. More...
 
virtual std::vector< uint256getTxHashes (LedgerIndex seq)=0
 getTxHashes Returns vector of tx hashes by given ledger sequence. More...
 
virtual std::pair< AccountTxResult, RPC::StatusgetAccountTx (AccountTxArgs const &args)=0
 getAccountTx Get last account transactions specifies by passed argumenrs structure. 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 minimum ledger sequence in Ledgers table. More...
 
virtual std::optional< LedgerIndexgetMaxLedgerSeq ()=0
 getMaxLedgerSeq Returns maximum ledger sequence in Ledgers table. More...
 
virtual std::optional< LedgerInfogetLedgerInfoByIndex (LedgerIndex ledgerSeq)=0
 getLedgerInfoByIndex Returns ledger by its sequence. More...
 
virtual std::optional< LedgerInfogetNewestLedgerInfo ()=0
 getNewestLedgerInfo Returns info of newest saved ledger. More...
 
virtual std::optional< LedgerInfogetLedgerInfoByHash (uint256 const &ledgerHash)=0
 getLedgerInfoByHash Returns info of ledger with given hash. More...
 
virtual uint256 getHashByIndex (LedgerIndex ledgerIndex)=0
 getHashByIndex Returns hash of ledger with given sequence. More...
 
virtual std::optional< LedgerHashPairgetHashesByIndex (LedgerIndex ledgerIndex)=0
 getHashesByIndex Returns hash of the ledger and hash of parent ledger for the ledger of given sequence. More...
 
virtual std::map< LedgerIndex, LedgerHashPairgetHashesByIndex (LedgerIndex minSeq, LedgerIndex maxSeq)=0
 getHashesByIndex Returns hash of the ledger and hash of parent ledger for all ledgers with sequences from given minimum limit to given maximum limit. More...
 
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory (LedgerIndex startIndex)=0
 getTxHistory Returns most recent 20 transactions starting from given number or entry. More...
 
virtual bool ledgerDbHasSpace (Config const &config)=0
 ledgerDbHasSpace Checks if ledger database has available space. More...
 
virtual bool transactionDbHasSpace (Config const &config)=0
 transactionDbHasSpace Checks if transaction database has available space. More...
 

Static Public Member Functions

static std::unique_ptr< RelationalDBInterfaceinit (Application &app, Config const &config, JobQueue &jobQueue)
 init Creates and returns appropriate interface based on config. More...
 

Detailed Description

Definition at line 27 of file RelationalDBInterfacePostgres.h.

Member Typedef Documentation

◆ AccountTx

Definition at line 85 of file RelationalDBInterface.h.

◆ AccountTxs

Definition at line 86 of file RelationalDBInterface.h.

◆ txnMetaLedgerType

Definition at line 87 of file RelationalDBInterface.h.

◆ MetaTxsList

Definition at line 88 of file RelationalDBInterface.h.

◆ LedgerSequence

Definition at line 90 of file RelationalDBInterface.h.

◆ LedgerHash

Definition at line 91 of file RelationalDBInterface.h.

◆ LedgerShortcut

Definition at line 92 of file RelationalDBInterface.h.

◆ LedgerSpecifier

Definition at line 94 of file RelationalDBInterface.h.

Member Function Documentation

◆ stop()

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

There is only one implementation of this interface: RelationalDBInterfacePostgresImp.

It wraps a stoppable object (PgPool) that does not follow RAII, and it does not go through the effort of following RAII either. The owner of the only object of that type (ApplicationImp) holds it by the type of its interface instead of its implementation, and thus the lifetime management methods need to be part of the interface.

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ sweep()

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

sweep Sweep the database.

Method is specific for postgres backend.

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ getCompleteLedgers()

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

getCompleteLedgers Returns string which contains list of completed ledgers.

Method is specific for postgres backend.

Returns
String with completed ledger numbers

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ getValidatedLedgerAge()

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

getValidatedLedgerAge Returns age of last validated ledger.

Method is specific for postgres backend.

Returns
Age of last validated ledger in seconds

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ writeLedgerAndTransactions()

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

writeLedgerAndTransactions Write new ledger and transaction data into database.

Method is specific for Postgres backend.

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

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ getTxHashes()

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

getTxHashes Returns vector of tx hashes by given ledger sequence.

Method is specific to postgres backend.

Parameters
seqLedger sequence
Returns
Vector of tx hashes

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ getAccountTx()

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

getAccountTx Get last account transactions specifies by passed argumenrs structure.

Function if specific to postgres backend.

Parameters
argsArguments which specify account and whose tx to return.
appApplication
jJournal
Returns
Vector of account transactions and RPC status of responce.

Implemented in ripple::RelationalDBInterfacePostgresImp.

◆ locateTransaction()

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

locateTransaction Returns information used to locate a transaction.

Function is specific to postgres backend.

Parameters
idHash of the transaction.
Returns
Information used to locate a transaction. Contains a nodestore hash and 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::RelationalDBInterfacePostgresImp.

◆ isCaughtUp()

virtual bool ripple::RelationalDBInterfacePostgres::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::RelationalDBInterfacePostgresImp.

◆ init()

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

init Creates and returns appropriate interface based on config.

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

Definition at line 40 of file RelationalDBInterface.cpp.

◆ getMinLedgerSeq()

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

getMinLedgerSeq Returns minimum ledger sequence in Ledgers table.

Returns
Ledger sequence or none if no ledgers exist.

Implemented in ripple::RelationalDBInterfacePostgresImp, and ripple::RelationalDBInterfaceSqliteImp.

◆ getMaxLedgerSeq()

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

getMaxLedgerSeq Returns maximum ledger sequence in Ledgers table.

Returns
Ledger sequence or none if no ledgers exist.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getLedgerInfoByIndex()

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

getLedgerInfoByIndex Returns ledger by its sequence.

Parameters
ledgerSeqLedger sequence.
Returns
Ledger or none if ledger not found.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getNewestLedgerInfo()

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

getNewestLedgerInfo Returns info of newest saved ledger.

Returns
Ledger info or none if ledger not found.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getLedgerInfoByHash()

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

getLedgerInfoByHash Returns info of ledger with given hash.

Parameters
ledgerHashHash of the ledger.
Returns
Ledger or none if ledger not found.

◆ getHashByIndex()

virtual uint256 ripple::RelationalDBInterface::getHashByIndex ( LedgerIndex  ledgerIndex)
pure virtualinherited

getHashByIndex Returns hash of ledger with given sequence.

Parameters
ledgerIndexLedger sequence.
Returns
Hash of the ledger.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getHashesByIndex() [1/2]

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

getHashesByIndex Returns hash of the ledger and hash of parent ledger for the ledger of given sequence.

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

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getHashesByIndex() [2/2]

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

getHashesByIndex Returns hash of the ledger and hash of parent ledger for all ledgers with sequences from given minimum limit to given maximum limit.

Parameters
minSeqMinimum ledger sequence.
maxSeqMaximum ledger sequence.
Returns
Map which points sequence number of found ledger to the struct LedgerHashPair which contains ledger hash and its parent hash.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ getTxHistory()

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

getTxHistory Returns most recent 20 transactions starting from given number or entry.

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

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ ledgerDbHasSpace()

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

ledgerDbHasSpace Checks if ledger database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.

◆ transactionDbHasSpace()

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

transactionDbHasSpace Checks if transaction database has available space.

Parameters
configConfig object.
Returns
True if space is available.

Implemented in ripple::RelationalDBInterfaceSqliteImp, and ripple::RelationalDBInterfacePostgresImp.