xrpld
Loading...
Searching...
No Matches
OrderBookDB.h
1#pragma once
2
3#include <xrpl/basics/UnorderedContainers.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/AcceptedLedgerTx.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/protocol/Asset.h>
8#include <xrpl/protocol/Book.h>
9#include <xrpl/protocol/UintTypes.h>
10
11#include <memory>
12#include <optional>
13#include <vector>
14
15namespace xrpl {
16
30{
31public:
32 virtual ~OrderBookDB() = default;
33
42 virtual void
44
50 virtual void
51 addOrderBook(Book const& book) = 0;
52
64 virtual std::vector<Book>
65 getBooksByTakerPays(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) = 0;
66
74 virtual int
75 getBookSize(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) = 0;
76
84 virtual bool
85 isBookToXRP(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) = 0;
86};
87
105affectedBooks(AcceptedLedgerTx const& alTx, beast::Journal const& j);
106
107} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
A transaction that is in a closed ledger.
Specifies an order book.
Definition Book.h:28
Tracks order books in the ledger.
Definition OrderBookDB.h:30
virtual int getBookSize(Asset const &asset, std::optional< Domain > const &domain=std::nullopt)=0
Get the count of order books that want a specific issue.
virtual bool isBookToXRP(Asset const &asset, std::optional< Domain > const &domain=std::nullopt)=0
Check if an order book to XRP exists for the given issue.
virtual std::vector< Book > getBooksByTakerPays(Asset const &asset, std::optional< Domain > const &domain=std::nullopt)=0
Get all order books that want a specific issue.
virtual void addOrderBook(Book const &book)=0
Add an order book to track.
virtual void setup(std::shared_ptr< ReadView const > const &ledger)=0
Initialize or update the order book database with a new ledger.
virtual ~OrderBookDB()=default
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
hash_set< Book > affectedBooks(AcceptedLedgerTx const &alTx, beast::Journal const &j)
Extract the set of books affected by a transaction.