Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AmendmentBlockHandler.hpp
1#pragma once
2
3#include "etl/AmendmentBlockHandlerInterface.hpp"
4#include "etl/SystemState.hpp"
5#include "util/async/AnyExecutionContext.hpp"
6#include "util/async/AnyOperation.hpp"
7
8#include <boost/asio/io_context.hpp>
9#include <boost/asio/post.hpp>
10#include <boost/asio/steady_timer.hpp>
11
12#include <chrono>
13#include <functional>
14#include <optional>
15
16namespace etl::impl {
17
18class AmendmentBlockHandler : public AmendmentBlockHandlerInterface {
19public:
20 using ActionType = std::function<void()>;
21
22private:
23 std::reference_wrapper<SystemState> state_;
24 std::chrono::steady_clock::duration interval_;
26 std::optional<util::async::AnyOperation<void>> operation_;
27
28 ActionType action_;
29
30public:
31 static ActionType const kDEFAULT_AMENDMENT_BLOCK_ACTION;
32
33 AmendmentBlockHandler(
35 SystemState& state,
36 std::chrono::steady_clock::duration interval = std::chrono::seconds{1},
37 ActionType action = kDEFAULT_AMENDMENT_BLOCK_ACTION
38 );
39
40 ~AmendmentBlockHandler() override;
41
42 void
43 stop() override;
44
45 void
46 notifyAmendmentBlocked() override;
47};
48
49} // namespace etl::impl
void notifyAmendmentBlocked() override
The function to call once an amendment block has been discovered.
Definition AmendmentBlockHandler.cpp:40
void stop() override
Stop the block handler from repeatedly executing.
Definition AmendmentBlockHandler.cpp:48
A type-erased execution context.
Definition AnyExecutionContext.hpp:22
The interface of a handler for amendment blocking.
Definition AmendmentBlockHandlerInterface.hpp:8
Represents the state of the ETL subsystem.
Definition SystemState.hpp:20