Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
BookChangesFeed.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/Types.hpp"
23#include "feed/impl/SingleFeedBase.hpp"
25#include "util/async/AnyExecutionContext.hpp"
26
27#include <boost/asio/io_context.hpp>
28#include <boost/json/serialize.hpp>
29#include <xrpl/protocol/LedgerHeader.h>
30
31#include <vector>
32
33namespace feed::impl {
34
41 BookChangesFeed(util::async::AnyExecutionContext& executionCtx) : SingleFeedBase(executionCtx, "book_changes")
42 {
43 }
44
50 void
51 pub(ripple::LedgerHeader const& lgrInfo, std::vector<data::TransactionAndMetadata> const& transactions)
52 {
53 SingleFeedBase::pub(boost::json::serialize(rpc::computeBookChanges(lgrInfo, transactions)));
54 }
55};
56} // namespace feed::impl
Base class for single feed.
Definition SingleFeedBase.hpp:42
void pub(std::string msg)
Publishes the feed in strand.
Definition SingleFeedBase.cpp:65
SingleFeedBase(util::async::AnyExecutionContext &executionCtx, std::string const &name)
Construct a new Single Feed Base object.
Definition SingleFeedBase.cpp:35
A type-erased execution context.
Definition AnyExecutionContext.hpp:41
boost::json::object computeBookChanges(ripple::LedgerHeader const &lgrInfo, std::vector< data::TransactionAndMetadata > const &transactions)
Computes all book changes for the given ledger header and transactions.
Definition BookChanges.cpp:106
Feed that publishes book changes. This feed will be published every ledger, even if there are no chan...
Definition BookChangesFeed.hpp:40
void pub(ripple::LedgerHeader const &lgrInfo, std::vector< data::TransactionAndMetadata > const &transactions)
Publishes the book changes.
Definition BookChangesFeed.hpp:51