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/Mutex.hpp"
6#include "util/async/AnyExecutionContext.hpp"
7#include "util/async/AnyOperation.hpp"
8
9#include <boost/asio/io_context.hpp>
10#include <boost/asio/post.hpp>
11#include <boost/asio/steady_timer.hpp>
12
13#include <chrono>
14#include <functional>
15#include <optional>
16
17namespace etl::impl {
18
19class AmendmentBlockHandler : public AmendmentBlockHandlerInterface {
20public:
21 using ActionType = std::function<void()>;
22 using OperationType = std::optional<util::async::AnyOperation<void>>;
23
24private:
25 std::reference_wrapper<SystemState> state_;
26 std::chrono::steady_clock::duration interval_;
29
30 ActionType action_;
31
32public:
33 static ActionType const kDefaultAmendmentBlockAction;
34
35 AmendmentBlockHandler(
37 SystemState& state,
38 std::chrono::steady_clock::duration interval = std::chrono::seconds{1},
39 ActionType action = kDefaultAmendmentBlockAction
40 );
41
42 ~AmendmentBlockHandler() override;
43
44 void
45 stop() override;
46
47 void
48 notifyAmendmentBlocked() override;
49};
50
51} // namespace etl::impl
void notifyAmendmentBlocked() override
The function to call once an amendment block has been discovered.
Definition AmendmentBlockHandler.cpp:39
void stop() override
Stop the block handler from repeatedly executing.
Definition AmendmentBlockHandler.cpp:48
A container for data that is protected by a mutex. Inspired by Mutex in Rust.
Definition Mutex.hpp:82
A type-erased execution context.
Definition AnyExecutionContext.hpp:23
The interface of a handler for amendment blocking.
Definition AmendmentBlockHandlerInterface.hpp:8
Represents the state of the ETL subsystem.
Definition SystemState.hpp:20