rippled
Loading...
Searching...
No Matches
Public Member Functions | List of all members
xrpl::OrderBookDB Class Referenceabstract

Tracks order books in the ledger. More...

#include <OrderBookDB.h>

Inheritance diagram for xrpl::OrderBookDB:
Inheritance graph
[legend]

Public Member Functions

virtual ~OrderBookDB ()=default
 
virtual void setup (std::shared_ptr< ReadView const > const &ledger)=0
 Initialize or update the order book database with a new ledger.
 
virtual void addOrderBook (Book const &book)=0
 Add an order book to track.
 
virtual std::vector< BookgetBooksByTakerPays (Issue const &issue, std::optional< Domain > const &domain=std::nullopt)=0
 Get all order books that want a specific issue.
 
virtual int getBookSize (Issue const &issue, std::optional< Domain > const &domain=std::nullopt)=0
 Get the count of order books that want a specific issue.
 
virtual bool isBookToXRP (Issue const &issue, std::optional< Domain > domain=std::nullopt)=0
 Check if an order book to XRP exists for the given issue.
 
virtual void processTxn (std::shared_ptr< ReadView const > const &ledger, AcceptedLedgerTx const &alTx, MultiApiJson const &jvObj)=0
 
virtual BookListeners::pointer getBookListeners (Book const &)=0
 
virtual BookListeners::pointer makeBookListeners (Book const &)=0
 

Detailed Description

Tracks order books in the ledger.

This interface provides access to order book information, including:

The order book database is updated as ledgers are accepted and provides efficient lookup of order book information for pathfinding and client subscriptions.

Definition at line 28 of file OrderBookDB.h.

Constructor & Destructor Documentation

◆ ~OrderBookDB()

virtual xrpl::OrderBookDB::~OrderBookDB ( )
virtualdefault

Member Function Documentation

◆ setup()

virtual void xrpl::OrderBookDB::setup ( std::shared_ptr< ReadView const > const &  ledger)
pure virtual

Initialize or update the order book database with a new ledger.

This method should be called when a new ledger is accepted to update the order book database with the current state of all order books.

Parameters
ledgerThe ledger to scan for order books

Implemented in xrpl::OrderBookDBImpl.

◆ addOrderBook()

virtual void xrpl::OrderBookDB::addOrderBook ( Book const &  book)
pure virtual

Add an order book to track.

Parameters
bookThe order book to add

Implemented in xrpl::OrderBookDBImpl.

◆ getBooksByTakerPays()

virtual std::vector< Book > xrpl::OrderBookDB::getBooksByTakerPays ( Issue const &  issue,
std::optional< Domain > const &  domain = std::nullopt 
)
pure virtual

Get all order books that want a specific issue.

Returns a list of all order books where the taker pays the specified issue. This is useful for pathfinding to find all possible next hops from a given currency.

Parameters
issueThe issue to search for
domainOptional domain restriction for the order book
Returns
Vector of books that want this issue

Implemented in xrpl::OrderBookDBImpl.

◆ getBookSize()

virtual int xrpl::OrderBookDB::getBookSize ( Issue const &  issue,
std::optional< Domain > const &  domain = std::nullopt 
)
pure virtual

Get the count of order books that want a specific issue.

Parameters
issueThe issue to search for
domainOptional domain restriction for the order book
Returns
Number of books that want this issue

Implemented in xrpl::OrderBookDBImpl.

◆ isBookToXRP()

virtual bool xrpl::OrderBookDB::isBookToXRP ( Issue const &  issue,
std::optional< Domain domain = std::nullopt 
)
pure virtual

Check if an order book to XRP exists for the given issue.

Parameters
issueThe issue to check
domainOptional domain restriction for the order book
Returns
true if a book from this issue to XRP exists

Implemented in xrpl::OrderBookDBImpl.

◆ processTxn()

virtual void xrpl::OrderBookDB::processTxn ( std::shared_ptr< ReadView const > const &  ledger,
AcceptedLedgerTx const &  alTx,
MultiApiJson const &  jvObj 
)
pure virtual

Implemented in xrpl::OrderBookDBImpl.

◆ getBookListeners()

virtual BookListeners::pointer xrpl::OrderBookDB::getBookListeners ( Book const &  )
pure virtual

Implemented in xrpl::OrderBookDBImpl.

◆ makeBookListeners()

virtual BookListeners::pointer xrpl::OrderBookDB::makeBookListeners ( Book const &  )
pure virtual

Implemented in xrpl::OrderBookDBImpl.