Clio develop
The XRP Ledger API server.
|
The interface to the database used by Clio. More...
#include <BackendInterface.hpp>
Public Member Functions | |
LedgerCache const & | cache () const |
LedgerCache & | cache () |
void | setCorruptionDetector (etl::CorruptionDetector< LedgerCache > detector) |
Sets the corruption detector. | |
virtual std::optional< ripple::LedgerHeader > | fetchLedgerBySequence (std::uint32_t sequence, boost::asio::yield_context yield) const =0 |
Fetches a specific ledger by sequence number. | |
virtual std::optional< ripple::LedgerHeader > | fetchLedgerByHash (ripple::uint256 const &hash, boost::asio::yield_context yield) const =0 |
Fetches a specific ledger by hash. | |
virtual std::optional< std::uint32_t > | fetchLatestLedgerSequence (boost::asio::yield_context yield) const =0 |
Fetches the latest ledger sequence. | |
std::optional< LedgerRange > | fetchLedgerRange () const |
Fetch the current ledger range. | |
virtual std::vector< ripple::uint256 > | fetchAccountRoots (std::uint32_t number, std::uint32_t pageSize, std::uint32_t seq, boost::asio::yield_context yield) const =0 |
Fetch the specified number of account root object indexes by page, the accounts need to exist for seq. | |
void | updateRange (uint32_t newMax) |
Updates the range of sequences that are stored in the DB. | |
void | setRange (uint32_t min, uint32_t max, bool force=false) |
Sets the range of sequences that are stored in the DB. | |
std::optional< ripple::Fees > | fetchFees (std::uint32_t seq, boost::asio::yield_context yield) const |
Fetch the fees from a specific ledger sequence. | |
virtual std::optional< TransactionAndMetadata > | fetchTransaction (ripple::uint256 const &hash, boost::asio::yield_context yield) const =0 |
Fetches a specific transaction. | |
virtual std::vector< TransactionAndMetadata > | fetchTransactions (std::vector< ripple::uint256 > const &hashes, boost::asio::yield_context yield) const =0 |
Fetches multiple transactions. | |
virtual TransactionsAndCursor | fetchAccountTransactions (ripple::AccountID const &account, std::uint32_t limit, bool forward, std::optional< TransactionsCursor > const &cursor, boost::asio::yield_context yield) const =0 |
Fetches all transactions for a specific account. | |
virtual std::vector< TransactionAndMetadata > | fetchAllTransactionsInLedger (std::uint32_t ledgerSequence, boost::asio::yield_context yield) const =0 |
Fetches all transactions from a specific ledger. | |
virtual std::vector< ripple::uint256 > | fetchAllTransactionHashesInLedger (std::uint32_t ledgerSequence, boost::asio::yield_context yield) const =0 |
Fetches all transaction hashes from a specific ledger. | |
virtual std::optional< NFT > | fetchNFT (ripple::uint256 const &tokenID, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const =0 |
Fetches a specific NFT. | |
virtual TransactionsAndCursor | fetchNFTTransactions (ripple::uint256 const &tokenID, std::uint32_t limit, bool forward, std::optional< TransactionsCursor > const &cursorIn, boost::asio::yield_context yield) const =0 |
Fetches all transactions for a specific NFT. | |
virtual NFTsAndCursor | fetchNFTsByIssuer (ripple::AccountID const &issuer, std::optional< std::uint32_t > const &taxon, std::uint32_t ledgerSequence, std::uint32_t limit, std::optional< ripple::uint256 > const &cursorIn, boost::asio::yield_context yield) const =0 |
Fetches all NFTs issued by a given address. | |
virtual MPTHoldersAndCursor | fetchMPTHolders (ripple::uint192 const &mptID, std::uint32_t const limit, std::optional< ripple::AccountID > const &cursorIn, std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const =0 |
Fetches all holders' balances for a MPTIssuanceID. | |
std::optional< Blob > | fetchLedgerObject (ripple::uint256 const &key, std::uint32_t sequence, boost::asio::yield_context yield) const |
Fetches a specific ledger object. | |
std::optional< std::uint32_t > | fetchLedgerObjectSeq (ripple::uint256 const &key, std::uint32_t sequence, boost::asio::yield_context yield) const |
Fetches a specific ledger object sequence. | |
std::vector< Blob > | fetchLedgerObjects (std::vector< ripple::uint256 > const &keys, std::uint32_t sequence, boost::asio::yield_context yield) const |
Fetches all ledger objects by their keys. | |
virtual std::optional< Blob > | doFetchLedgerObject (ripple::uint256 const &key, std::uint32_t sequence, boost::asio::yield_context yield) const =0 |
The database-specific implementation for fetching a ledger object. | |
virtual std::optional< std::uint32_t > | doFetchLedgerObjectSeq (ripple::uint256 const &key, std::uint32_t sequence, boost::asio::yield_context yield) const =0 |
The database-specific implementation for fetching a ledger object sequence. | |
virtual std::vector< Blob > | doFetchLedgerObjects (std::vector< ripple::uint256 > const &keys, std::uint32_t sequence, boost::asio::yield_context yield) const =0 |
The database-specific implementation for fetching ledger objects. | |
virtual std::vector< LedgerObject > | fetchLedgerDiff (std::uint32_t ledgerSequence, boost::asio::yield_context yield) const =0 |
Returns the difference between ledgers. | |
LedgerPage | fetchLedgerPage (std::optional< ripple::uint256 > const &cursor, std::uint32_t ledgerSequence, std::uint32_t limit, bool outOfOrder, boost::asio::yield_context yield) |
Fetches a page of ledger objects, ordered by key/index. | |
std::optional< LedgerObject > | fetchSuccessorObject (ripple::uint256 key, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const |
Fetches the successor object. | |
std::optional< ripple::uint256 > | fetchSuccessorKey (ripple::uint256 key, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const |
Fetches the successor key. | |
virtual std::optional< ripple::uint256 > | doFetchSuccessorKey (ripple::uint256 key, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const =0 |
Database-specific implementation of fetching the successor key. | |
BookOffersPage | fetchBookOffers (ripple::uint256 const &book, std::uint32_t ledgerSequence, std::uint32_t limit, boost::asio::yield_context yield) const |
Fetches book offers. | |
virtual std::optional< std::string > | fetchMigratorStatus (std::string const &migratorName, boost::asio::yield_context yield) const =0 |
Fetches the status of migrator by name. | |
std::optional< LedgerRange > | hardFetchLedgerRange () const |
Synchronously fetches the ledger range from DB. | |
virtual std::optional< LedgerRange > | hardFetchLedgerRange (boost::asio::yield_context yield) const =0 |
Fetches the ledger range from DB. | |
std::optional< LedgerRange > | hardFetchLedgerRangeNoThrow () const |
Fetches the ledger range from DB retrying until no DatabaseTimeout is thrown. | |
virtual void | writeLedger (ripple::LedgerHeader const &ledgerHeader, std::string &&blob)=0 |
Writes to a specific ledger. | |
virtual void | writeLedgerObject (std::string &&key, std::uint32_t seq, std::string &&blob) |
Writes a new ledger object. | |
virtual void | writeTransaction (std::string &&hash, std::uint32_t seq, std::uint32_t date, std::string &&transaction, std::string &&metadata)=0 |
Writes a new transaction. | |
virtual void | writeNFTs (std::vector< NFTsData > const &data)=0 |
Writes NFTs to the database. | |
virtual void | writeAccountTransactions (std::vector< AccountTransactionsData > data)=0 |
Write a new set of account transactions. | |
virtual void | writeNFTTransactions (std::vector< NFTTransactionsData > const &data)=0 |
Write NFTs transactions. | |
virtual void | writeMPTHolders (std::vector< MPTHolderData > const &data)=0 |
Write accounts that started holding onto a MPT. | |
virtual void | writeSuccessor (std::string &&key, std::uint32_t seq, std::string &&successor)=0 |
Write a new successor. | |
virtual void | startWrites () const =0 |
Starts a write transaction with the DB. No-op for cassandra. | |
bool | finishWrites (std::uint32_t ledgerSequence) |
Tells database we finished writing all data for a specific ledger. | |
virtual void | waitForWritesToFinish ()=0 |
Wait for all pending writes to finish. | |
virtual void | writeMigratorStatus (std::string const &migratorName, std::string const &status)=0 |
Mark the migration status of a migrator as Migrated in the database. | |
virtual bool | isTooBusy () const =0 |
virtual boost::json::object | stats () const =0 |
Protected Attributes | |
std::shared_mutex | rngMtx_ |
std::optional< LedgerRange > | range_ |
LedgerCache | cache_ |
std::optional< etl::CorruptionDetector< LedgerCache > > | corruptionDetector_ |
The interface to the database used by Clio.
|
inline |
|
inline |
|
pure virtual |
The database-specific implementation for fetching a ledger object.
key | The key to fetch for |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
The database-specific implementation for fetching ledger objects.
keys | The keys to fetch for |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
The database-specific implementation for fetching a ledger object sequence.
key | The key to fetch for |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Database-specific implementation of fetching the successor key.
key | The key to fetch for |
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetch the specified number of account root object indexes by page, the accounts need to exist for seq.
number | The number of accounts to fetch |
pageSize | The maximum number of accounts per page |
seq | The accounts need to exist for this sequence |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all transactions for a specific account.
account | The account to fetch transactions for |
limit | The maximum number of transactions per result page |
forward | Whether to fetch the page forwards or backwards from the given cursor |
cursor | The cursor to resume fetching from |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all transaction hashes from a specific ledger.
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all transactions from a specific ledger.
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
BookOffersPage data::BackendInterface::fetchBookOffers | ( | ripple::uint256 const & | book, |
std::uint32_t | ledgerSequence, | ||
std::uint32_t | limit, | ||
boost::asio::yield_context | yield ) const |
Fetches book offers.
book | Unsigned 256-bit integer. |
ledgerSequence | The ledger sequence to fetch for |
limit | Pagaing limit as to how many transactions returned per page. |
yield | The coroutine context |
std::optional< ripple::Fees > data::BackendInterface::fetchFees | ( | std::uint32_t | seq, |
boost::asio::yield_context | yield ) const |
Fetch the fees from a specific ledger sequence.
seq | The sequence to fetch for |
yield | The coroutine context |
|
pure virtual |
Fetches the latest ledger sequence.
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches a specific ledger by hash.
hash | The hash to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches a specific ledger by sequence number.
sequence | The sequence number to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Returns the difference between ledgers.
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
std::optional< Blob > data::BackendInterface::fetchLedgerObject | ( | ripple::uint256 const & | key, |
std::uint32_t | sequence, | ||
boost::asio::yield_context | yield ) const |
Fetches a specific ledger object.
Currently the real fetch happens in doFetchLedgerObject and fetchLedgerObject attempts to fetch from Cache first and only calls out to the real DB if a cache miss ocurred.
key | The key of the object |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
std::vector< Blob > data::BackendInterface::fetchLedgerObjects | ( | std::vector< ripple::uint256 > const & | keys, |
std::uint32_t | sequence, | ||
boost::asio::yield_context | yield ) const |
Fetches all ledger objects by their keys.
Currently the real fetch happens in doFetchLedgerObjects and fetchLedgerObjects attempts to fetch from Cache first and only calls out to the real DB for each of the keys that was not found in the cache.
keys | A vector with the keys of the objects to fetch |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
std::optional< std::uint32_t > data::BackendInterface::fetchLedgerObjectSeq | ( | ripple::uint256 const & | key, |
std::uint32_t | sequence, | ||
boost::asio::yield_context | yield ) const |
Fetches a specific ledger object sequence.
Currently the real fetch happens in doFetchLedgerObjectSeq
key | The key of the object |
sequence | The ledger sequence to fetch for |
yield | The coroutine context |
LedgerPage data::BackendInterface::fetchLedgerPage | ( | std::optional< ripple::uint256 > const & | cursor, |
std::uint32_t | ledgerSequence, | ||
std::uint32_t | limit, | ||
bool | outOfOrder, | ||
boost::asio::yield_context | yield ) |
Fetches a page of ledger objects, ordered by key/index.
cursor | The cursor to resume fetching from |
ledgerSequence | The ledger sequence to fetch for |
limit | The maximum number of transactions per result page |
outOfOrder | If set to true max available sequence is used instead of ledgerSequence |
yield | The coroutine context |
std::optional< LedgerRange > data::BackendInterface::fetchLedgerRange | ( | ) | const |
Fetch the current ledger range.
|
pure virtual |
Fetches the status of migrator by name.
migratorName | The name of the migrator |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all holders' balances for a MPTIssuanceID.
mptID | MPTIssuanceID you wish you query. |
limit | Paging limit. |
cursorIn | Optional cursor to allow us to pick up from where we last left off. |
ledgerSequence | The ledger sequence to fetch for |
yield | Currently executing coroutine. |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches a specific NFT.
tokenID | The ID of the NFT |
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all NFTs issued by a given address.
issuer | AccountID of issuer you wish you query. |
taxon | Optional taxon of NFTs by which you wish to filter. |
ledgerSequence | The ledger sequence to fetch for |
limit | Paging limit. |
cursorIn | Optional cursor to allow us to pick up from where we last left off. |
yield | Currently executing coroutine. |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches all transactions for a specific NFT.
tokenID | The ID of the NFT |
limit | The maximum number of transactions per result page |
forward | Whether to fetch the page forwards or backwards from the given cursor |
cursorIn | The cursor to resume fetching from |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
std::optional< ripple::uint256 > data::BackendInterface::fetchSuccessorKey | ( | ripple::uint256 | key, |
std::uint32_t | ledgerSequence, | ||
boost::asio::yield_context | yield ) const |
Fetches the successor key.
Thea real fetch happens in doFetchSuccessorKey. This function will attempt to lookup the successor in the cache first and only if it's not found in the cache will it fetch from the actual DB.
key | The key to fetch for |
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
std::optional< LedgerObject > data::BackendInterface::fetchSuccessorObject | ( | ripple::uint256 | key, |
std::uint32_t | ledgerSequence, | ||
boost::asio::yield_context | yield ) const |
Fetches the successor object.
key | The key to fetch for |
ledgerSequence | The ledger sequence to fetch for |
yield | The coroutine context |
|
pure virtual |
Fetches a specific transaction.
hash | The hash of the transaction to fetch |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Fetches multiple transactions.
hashes | A vector of hashes to fetch transactions for |
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
bool data::BackendInterface::finishWrites | ( | std::uint32_t | ledgerSequence | ) |
Tells database we finished writing all data for a specific ledger.
Uses doFinishWrites to synchronize with the pending writes.
ledgerSequence | The ledger sequence to finish writing for |
std::optional< LedgerRange > data::BackendInterface::hardFetchLedgerRange | ( | ) | const |
Synchronously fetches the ledger range from DB.
This function just wraps hardFetchLedgerRange(boost::asio::yield_context) using synchronous(FnType&&).
|
pure virtual |
Fetches the ledger range from DB.
yield | The coroutine context |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
std::optional< LedgerRange > data::BackendInterface::hardFetchLedgerRangeNoThrow | ( | ) | const |
Fetches the ledger range from DB retrying until no DatabaseTimeout is thrown.
|
pure virtual |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
inline |
Sets the corruption detector.
detector | The corruption detector to set |
void data::BackendInterface::setRange | ( | uint32_t | min, |
uint32_t | max, | ||
bool | force = false ) |
Sets the range of sequences that are stored in the DB.
min | The new minimum sequence available |
max | The new maximum sequence available |
force | If set to true, the range will be set even if it's already set |
|
pure virtual |
Starts a write transaction with the DB. No-op for cassandra.
Note: Can potentially be deprecated and removed.
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
void data::BackendInterface::updateRange | ( | uint32_t | newMax | ) |
Updates the range of sequences that are stored in the DB.
newMax | The new maximum sequence available |
|
pure virtual |
Wait for all pending writes to finish.
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Write a new set of account transactions.
data | A vector of AccountTransactionsData objects representing the account transactions |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Writes to a specific ledger.
ledgerHeader | Ledger header. |
blob | r-value string serialization of ledger header. |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
virtual |
Writes a new ledger object.
key | The key to write the ledger object under |
seq | The ledger sequence to write for |
blob | The data to write |
|
pure virtual |
Mark the migration status of a migrator as Migrated in the database.
migratorName | The name of the migrator |
status | The status to set |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Write accounts that started holding onto a MPT.
data | A vector of MPT ID and account pairs |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Writes NFTs to the database.
data | A vector of NFTsData objects representing the NFTs |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Write NFTs transactions.
data | A vector of NFTTransactionsData objects |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Write a new successor.
key | Key of the object that the passed successor will be the successor for |
seq | The ledger sequence to write for |
successor | The successor data to write |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.
|
pure virtual |
Writes a new transaction.
hash | The hash of the transaction |
seq | The ledger sequence to write for |
date | The timestamp of the entry |
transaction | The transaction data to write |
metadata | The metadata to write |
Implemented in data::cassandra::BasicCassandraBackend< SettingsProviderType, ExecutionStrategyType >.