Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType > Class Template Reference

Implements CassandraBackendFamily for Keyspace. More...

#include <KeyspaceBackend.hpp>

Inheritance diagram for data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >:
Collaboration diagram for data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >:

Public Member Functions

 BasicKeyspaceBackend (BasicKeyspaceBackend &&)=delete
 Move constructor is deleted because handle_ is shared by reference with executor.
bool doFinishWrites () override
 Wait for pending writes and commit the ledger range update for the current ledger.
NFTsAndCursor fetchNFTsByIssuer (xrpl::AccountID const &issuer, std::optional< std::uint32_t > const &taxon, std::uint32_t const ledgerSequence, std::uint32_t const limit, std::optional< xrpl::uint256 > const &cursorIn, boost::asio::yield_context yield) const override
 Fetches all NFTs issued by a given address.
std::vector< xrpl::uint256 > fetchAccountRoots (std::uint32_t number, std::uint32_t pageSize, std::uint32_t seq, boost::asio::yield_context yield) const override
 (Unsupported in Keyspaces) Fetches account root object indexes by page.
Public Member Functions inherited from data::cassandra::CassandraBackendFamily< SettingsProviderType, ExecutionStrategyType, KeyspaceSchema< SettingsProviderType >, FetchLedgerCache >
 CassandraBackendFamily (SettingsProviderType settingsProvider, data::LedgerCacheInterface &cache, bool readOnly)
 Create a new cassandra/scylla backend instance.
std::chrono::milliseconds initialRetryDelay () const override
std::chrono::milliseconds maxRetryDelay () const override
TransactionsAndCursor fetchAccountTransactions (xrpl::AccountID const &account, std::uint32_t const limit, bool forward, std::optional< TransactionsCursor > const &txnCursor, boost::asio::yield_context yield) const override
 Fetches all transactions for a specific account.
void waitForWritesToFinish () override
 Wait for all pending writes to finish.
void writeLedger (xrpl::LedgerHeader const &ledgerHeader, std::string &&blob) override
 Write a ledger header and its hash-to-sequence mapping, and set the ledger that doFinishWrites() will commit.
std::optional< std::uint32_t > fetchLatestLedgerSequence (boost::asio::yield_context yield) const override
 Fetches the latest ledger sequence.
std::optional< xrpl::LedgerHeader > fetchLedgerBySequence (std::uint32_t const sequence, boost::asio::yield_context yield) const override
 Fetches a specific ledger by sequence number, using the ledger header cache first.
std::optional< xrpl::LedgerHeader > fetchLedgerByHash (xrpl::uint256 const &hash, boost::asio::yield_context yield) const override
 Fetches a specific ledger by hash.
std::optional< LedgerRange > hardFetchLedgerRange (boost::asio::yield_context yield) const override
 Fetches the ledger range from DB.
std::vector< TransactionAndMetadata > fetchAllTransactionsInLedger (std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Fetches all transactions from a specific ledger.
std::vector< xrpl::uint256 > fetchAllTransactionHashesInLedger (std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Fetches all transaction hashes from a specific ledger.
std::optional< NFT > fetchNFT (xrpl::uint256 const &tokenID, std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Fetches a specific NFT.
TransactionsAndCursor fetchNFTTransactions (xrpl::uint256 const &tokenID, std::uint32_t const limit, bool const forward, std::optional< TransactionsCursor > const &cursorIn, boost::asio::yield_context yield) const override
 Fetches all transactions for a specific NFT.
TransactionsAndCursor fetchMPTokenIssuanceTransactions (xrpl::uint192 const &mptIssuanceID, std::uint32_t const limit, bool const forward, std::optional< TransactionsCursor > const &cursorIn, boost::asio::yield_context yield) const override
 Fetches transactions for a particular MPTokenIssuance ID.
TransactionsAndCursor fetchAccountMPTokenIssuanceTransactions (xrpl::uint192 const &mptIssuanceID, xrpl::AccountID const &account, std::uint32_t const limit, bool const forward, std::optional< TransactionsCursor > const &cursorIn, boost::asio::yield_context yield) const override
 Fetches transactions for a particular MPTokenIssuance ID involving a particular account.
MPTHoldersAndCursor fetchMPTHolders (xrpl::uint192 const &mptID, std::uint32_t const limit, std::optional< xrpl::AccountID > const &cursorIn, std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Fetches a page of MPToken objects held for an MPTokenIssuance ID.
std::optional< Blob > doFetchLedgerObject (xrpl::uint256 const &key, std::uint32_t const sequence, boost::asio::yield_context yield) const override
 The database-specific implementation for fetching a ledger object.
std::optional< std::uint32_t > doFetchLedgerObjectSeq (xrpl::uint256 const &key, std::uint32_t const sequence, boost::asio::yield_context yield) const override
 The database-specific implementation for fetching a ledger object sequence.
std::optional< TransactionAndMetadata > fetchTransaction (xrpl::uint256 const &hash, boost::asio::yield_context yield) const override
 Fetches a specific transaction.
std::optional< xrpl::uint256 > doFetchSuccessorKey (xrpl::uint256 key, std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Database-specific implementation of fetching the successor key.
std::vector< TransactionAndMetadata > fetchTransactions (std::vector< xrpl::uint256 > const &hashes, boost::asio::yield_context yield) const override
 Fetches multiple transactions.
std::vector< Blob > doFetchLedgerObjects (std::vector< xrpl::uint256 > const &keys, std::uint32_t const sequence, boost::asio::yield_context yield) const override
 The database-specific implementation for fetching ledger objects.
std::vector< LedgerObject > fetchLedgerDiff (std::uint32_t const ledgerSequence, boost::asio::yield_context yield) const override
 Fetch the objects changed in the given ledger.
std::optional< std::string > fetchMigratorStatus (std::string const &migratorName, boost::asio::yield_context yield) const override
 Fetches the status of migrator by name.
std::expected< std::vector< std::pair< boost::uuids::uuid, std::string > >, std::string > fetchClioNodesData (boost::asio::yield_context yield) const override
 Fetches the data of all nodes in the cluster.
void doWriteLedgerObject (std::string &&key, std::uint32_t const seq, std::string &&blob) override
 Write a ledger object version to objects and, once the ledger range is known, record its key in diff.
void writeSuccessor (std::string &&key, std::uint32_t const seq, std::string &&successor) override
 Write a new successor.
void writeAccountTransactions (std::vector< AccountTransactionsData > data) override
 Write a new set of account transactions.
void writeAccountTransaction (AccountTransactionsData record) override
 Write a new account transaction.
void writeNFTTransactions (std::vector< NFTTransactionsData > const &data) override
 Write NFTs transactions.
void writeMPTokenIssuanceTransactions (std::vector< MPTokenIssuanceTransactionsData > const &data) override
 Write MPTokenIssuance transaction index rows to the mptoken_issuance_transactions table.
void writeAccountMPTokenIssuanceTransactions (std::vector< MPTokenIssuanceTransactionsData > const &data) override
 Write MPTokenIssuance transaction index rows to the account_mptoken_issuance_transactions table.
void writeTransaction (std::string &&hash, std::uint32_t const seq, std::uint32_t const date, std::string &&transaction, std::string &&metadata) override
 Writes a new transaction.
void writeNFTs (std::vector< NFTsData > const &data) override
 Writes NFTs to the database.
void writeMPTHolders (std::vector< MPTHolderData > const &data) override
 Write accounts that started holding onto a MPT.
void startWrites () const override
 Starts a write transaction with the DB. No-op for Cassandra.
void writeMigratorStatus (std::string const &migratorName, std::string const &status) override
 Write the migration status of a migrator to the database.
void writeNodeMessage (boost::uuids::uuid const &uuid, std::string message) override
 Write a node message. Used by ClusterCommunicationService.
bool isTooBusy () const override
 Check whether the database is overwhelmed with requests.
boost::json::object stats () const override
 Get backend usage statistics collected by the execution strategy.
Public Member Functions inherited from data::BackendInterface
 BackendInterface (LedgerCacheInterface &cache)
 Construct a new backend interface instance.
LedgerCacheInterface const & cache () const
LedgerCacheInterface & cache ()
void setCorruptionDetector (etl::CorruptionDetector detector)
 Sets the corruption detector.
std::optional< LedgerRange > fetchLedgerRange () const
 Fetch the current ledger range.
void updateRange (uint32_t newMax)
 Updates the range of sequences that are stored in the DB.
void forceUpdateRange (uint32_t newMax)
 Updates the range of sequences that are stored in the DB without any checks.
void setRange (uint32_t min, uint32_t max, bool force=false)
 Sets the range of sequences that are stored in the DB.
std::optional< xrpl::Fees > fetchFees (std::uint32_t seq, boost::asio::yield_context yield) const
 Fetch the fees from a specific ledger sequence.
std::optional< Blob > fetchLedgerObject (xrpl::uint256 const &key, std::uint32_t sequence, boost::asio::yield_context yield) const
 Fetches a specific ledger object.
std::optional< std::uint32_t > fetchLedgerObjectSeq (xrpl::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< xrpl::uint256 > const &keys, std::uint32_t sequence, boost::asio::yield_context yield) const
 Fetches all ledger objects by their keys.
LedgerPage fetchLedgerPage (std::optional< xrpl::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 (xrpl::uint256 key, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const
 Fetches the successor object.
std::optional< xrpl::uint256 > fetchSuccessorKey (xrpl::uint256 key, std::uint32_t ledgerSequence, boost::asio::yield_context yield) const
 Fetches the successor key.
BookOffersPage fetchBookOffers (xrpl::uint256 const &book, std::uint32_t ledgerSequence, std::uint32_t limit, boost::asio::yield_context yield) const
 Fetches book offers.
std::optional< LedgerRange > hardFetchLedgerRange () const
 Synchronously fetches the ledger range from DB.
std::optional< LedgerRange > hardFetchLedgerRangeNoThrow () const
 Fetches the ledger range from DB retrying until no DatabaseError is thrown.
virtual void writeLedgerObject (std::string &&key, std::uint32_t seq, std::string &&blob)
 Writes a new ledger object.
bool finishWrites (std::uint32_t ledgerSequence)
 Tells database we finished writing all data for a specific ledger.

Additional Inherited Members

Public Types inherited from data::BackendInterface
using ClioNodesDataFetchResult
 Return type for fetchClioNodesData() method.
Protected Member Functions inherited from data::cassandra::CassandraBackendFamily< SettingsProviderType, ExecutionStrategyType, KeyspaceSchema< SettingsProviderType >, FetchLedgerCache >
bool executeSyncUpdate (Statement statement)
 Executes statements and tries to write to DB.
TransactionsAndCursor fetchMPTokenIssuanceTransactionsImpl (Statement const &statement, std::size_t const cursorIdx, std::size_t const limitIdx, std::uint32_t const limit, bool const forward, std::optional< TransactionsCursor > const &cursorIn, boost::asio::yield_context yield) const
 Shared implementation of the two MPTokenIssuance transaction-index fetchers.
Protected Attributes inherited from data::cassandra::CassandraBackendFamily< SettingsProviderType, ExecutionStrategyType, KeyspaceSchema< SettingsProviderType >, FetchLedgerCache >
util::Logger log_
SettingsProviderType settingsProvider_
KeyspaceSchema< SettingsProviderType > schema_
std::atomic_uint32_t ledgerSequence_
Handle handle_
ExecutionStrategyType executor_
FetchLedgerCache ledgerCache_
Protected Attributes inherited from data::BackendInterface
util::Logger log_ {"Backend"}
std::shared_mutex rngMtx_
std::optional< LedgerRange > range_
std::reference_wrapper< LedgerCacheInterface > cache_
std::optional< etl::CorruptionDetector > corruptionDetector_
Static Protected Attributes inherited from data::cassandra::CassandraBackendFamily< SettingsProviderType, ExecutionStrategyType, KeyspaceSchema< SettingsProviderType >, FetchLedgerCache >
static constexpr std::size_t kTransactionCursorBindIndex
static constexpr std::size_t kTransactionLimitBindIndex
static constexpr std::size_t kMPTokenIssuanceTxCursorBindIndex
static constexpr std::size_t kMPTokenIssuanceTxLimitBindIndex
static constexpr std::size_t kAccountMPTokenIssuanceTxCursorBindIndex
static constexpr std::size_t kAccountMPTokenIssuanceTxLimitBindIndex

Detailed Description

template<SomeSettingsProvider SettingsProviderType, SomeExecutionStrategy ExecutionStrategyType, typename FetchLedgerCacheType = FetchLedgerCache>
class data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >

Implements CassandraBackendFamily for Keyspace.

Template Parameters
SettingsProviderTypeThe settings provider type
ExecutionStrategyTypeThe execution strategy type
FetchLedgerCacheTypeThe ledger header cache type

Member Function Documentation

◆ doFinishWrites()

template<SomeSettingsProvider SettingsProviderType, SomeExecutionStrategy ExecutionStrategyType, typename FetchLedgerCacheType = FetchLedgerCache>
bool data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >::doFinishWrites ( )
inlineoverridevirtual

Wait for pending writes and commit the ledger range update for the current ledger.

If the ledger range table is not yet populated, both the min and max sequence are first inserted for the current ledger.

Returns
true if ledger_range now has the current ledger as its max sequence; false otherwise (e.g. a write conflict)

Implements data::BackendInterface.

◆ fetchAccountRoots()

template<SomeSettingsProvider SettingsProviderType, SomeExecutionStrategy ExecutionStrategyType, typename FetchLedgerCacheType = FetchLedgerCache>
std::vector< xrpl::uint256 > data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >::fetchAccountRoots ( std::uint32_t number,
std::uint32_t pageSize,
std::uint32_t seq,
boost::asio::yield_context yield ) const
inlinenodiscardoverridevirtual

(Unsupported in Keyspaces) Fetches account root object indexes by page.

Note
Loading the cache by enumerating all accounts is currently unsupported by the AWS Keyspaces backend. This function's logic relies on "PER PARTITION LIMIT 1", which Keyspaces does not support, and there is no efficient alternative. This is acceptable as the cache is primarily loaded via diffs. Calling this function will throw an exception.
Parameters
numberThe total number of accounts to fetch.
pageSizeThe maximum number of accounts per page.
seqThe accounts need to exist at this ledger sequence.
yieldThe coroutine context.
Returns
A vector of xrpl::uint256 representing the account root hashes.

Implements data::BackendInterface.

◆ fetchNFTsByIssuer()

template<SomeSettingsProvider SettingsProviderType, SomeExecutionStrategy ExecutionStrategyType, typename FetchLedgerCacheType = FetchLedgerCache>
NFTsAndCursor data::cassandra::BasicKeyspaceBackend< SettingsProviderType, ExecutionStrategyType, FetchLedgerCacheType >::fetchNFTsByIssuer ( xrpl::AccountID const & issuer,
std::optional< std::uint32_t > const & taxon,
std::uint32_t const ledgerSequence,
std::uint32_t const limit,
std::optional< xrpl::uint256 > const & cursorIn,
boost::asio::yield_context yield ) const
inlinenodiscardoverridevirtual

Fetches all NFTs issued by a given address.

Parameters
issuerAccountID of the issuer to query
taxonOptional taxon of NFTs by which to filter
ledgerSequenceThe ledger sequence to fetch for
limitPaging limit
cursorInOptional cursor to pick up from where the previous page left off
yieldThe coroutine context
Returns
NFTs issued by this account (or issuer/taxon combination) and an optional cursor

Implements data::BackendInterface.


The documentation for this class was generated from the following file: