rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
xrpl::OrderBookDBImpl Class Referencefinal

#include <OrderBookDBImpl.h>

Inheritance diagram for xrpl::OrderBookDBImpl:
Inheritance graph
[legend]
Collaboration diagram for xrpl::OrderBookDBImpl:
Collaboration graph
[legend]

Public Member Functions

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

Private Types

using BookToListenersMap = hash_map< Book, BookListeners::pointer >
 

Private Attributes

ServiceRegistryregistry_
 
int const pathSearchMax_
 
bool const standalone_
 
hardened_hash_map< Issue, hardened_hash_set< Issue > > allBooks_
 
hardened_hash_map< std::pair< Issue, Domain >, hardened_hash_set< Issue > > domainBooks_
 
hash_set< IssuexrpBooks_
 
hash_set< std::pair< Issue, Domain > > xrpDomainBooks_
 
std::recursive_mutex mLock
 
BookToListenersMap mListeners
 
std::atomic< std::uint32_tseq_
 
beast::Journal const j_
 

Detailed Description

Definition at line 31 of file OrderBookDBImpl.h.

Member Typedef Documentation

◆ BookToListenersMap

Definition at line 84 of file OrderBookDBImpl.h.

Constructor & Destructor Documentation

◆ OrderBookDBImpl()

xrpl::OrderBookDBImpl::OrderBookDBImpl ( ServiceRegistry registry,
OrderBookDBConfig const &  config 
)

Definition at line 13 of file OrderBookDBImpl.cpp.

Member Function Documentation

◆ setup()

void xrpl::OrderBookDBImpl::setup ( std::shared_ptr< ReadView const > const &  ledger)
overridevirtual

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

Implements xrpl::OrderBookDB.

Definition at line 29 of file OrderBookDBImpl.cpp.

◆ addOrderBook()

void xrpl::OrderBookDBImpl::addOrderBook ( Book const &  book)
overridevirtual

Add an order book to track.

Parameters
bookThe order book to add

Implements xrpl::OrderBookDB.

Definition at line 161 of file OrderBookDBImpl.cpp.

◆ getBooksByTakerPays()

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

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

Implements xrpl::OrderBookDB.

Definition at line 180 of file OrderBookDBImpl.cpp.

◆ getBookSize()

int xrpl::OrderBookDBImpl::getBookSize ( Issue const &  issue,
std::optional< Domain > const &  domain = std::nullopt 
)
overridevirtual

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

Implements xrpl::OrderBookDB.

Definition at line 208 of file OrderBookDBImpl.cpp.

◆ isBookToXRP()

bool xrpl::OrderBookDBImpl::isBookToXRP ( Issue const &  issue,
std::optional< Domain domain = std::nullopt 
)
overridevirtual

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

Implements xrpl::OrderBookDB.

Definition at line 227 of file OrderBookDBImpl.cpp.

◆ update()

void xrpl::OrderBookDBImpl::update ( std::shared_ptr< ReadView const > const &  ledger)

Definition at line 64 of file OrderBookDBImpl.cpp.

◆ processTxn()

void xrpl::OrderBookDBImpl::processTxn ( std::shared_ptr< ReadView const > const &  ledger,
AcceptedLedgerTx const &  alTx,
MultiApiJson const &  jvObj 
)
overridevirtual

Implements xrpl::OrderBookDB.

Definition at line 271 of file OrderBookDBImpl.cpp.

◆ getBookListeners()

BookListeners::pointer xrpl::OrderBookDBImpl::getBookListeners ( Book const &  book)
overridevirtual

Implements xrpl::OrderBookDB.

Definition at line 256 of file OrderBookDBImpl.cpp.

◆ makeBookListeners()

BookListeners::pointer xrpl::OrderBookDBImpl::makeBookListeners ( Book const &  book)
overridevirtual

Implements xrpl::OrderBookDB.

Definition at line 236 of file OrderBookDBImpl.cpp.

Member Data Documentation

◆ registry_

ServiceRegistry& xrpl::OrderBookDBImpl::registry_
private

Definition at line 67 of file OrderBookDBImpl.h.

◆ pathSearchMax_

int const xrpl::OrderBookDBImpl::pathSearchMax_
private

Definition at line 68 of file OrderBookDBImpl.h.

◆ standalone_

bool const xrpl::OrderBookDBImpl::standalone_
private

Definition at line 69 of file OrderBookDBImpl.h.

◆ allBooks_

hardened_hash_map<Issue, hardened_hash_set<Issue> > xrpl::OrderBookDBImpl::allBooks_
private

Definition at line 72 of file OrderBookDBImpl.h.

◆ domainBooks_

hardened_hash_map<std::pair<Issue, Domain>, hardened_hash_set<Issue> > xrpl::OrderBookDBImpl::domainBooks_
private

Definition at line 74 of file OrderBookDBImpl.h.

◆ xrpBooks_

hash_set<Issue> xrpl::OrderBookDBImpl::xrpBooks_
private

Definition at line 77 of file OrderBookDBImpl.h.

◆ xrpDomainBooks_

hash_set<std::pair<Issue, Domain> > xrpl::OrderBookDBImpl::xrpDomainBooks_
private

Definition at line 80 of file OrderBookDBImpl.h.

◆ mLock

std::recursive_mutex xrpl::OrderBookDBImpl::mLock
private

Definition at line 82 of file OrderBookDBImpl.h.

◆ mListeners

BookToListenersMap xrpl::OrderBookDBImpl::mListeners
private

Definition at line 86 of file OrderBookDBImpl.h.

◆ seq_

std::atomic<std::uint32_t> xrpl::OrderBookDBImpl::seq_
private

Definition at line 88 of file OrderBookDBImpl.h.

◆ j_

beast::Journal const xrpl::OrderBookDBImpl::j_
private

Definition at line 90 of file OrderBookDBImpl.h.