Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
NetworkValidatedLedgers.hpp
1#pragma once
2
4
5#include <boost/signals2/connection.hpp>
6#include <boost/signals2/signal.hpp>
7#include <boost/signals2/variadic_signal.hpp>
8
9#include <condition_variable>
10#include <cstdint>
11#include <memory>
12#include <mutex>
13#include <optional>
14
15namespace etl {
16
27 std::optional<uint32_t> latest_; // currently known latest sequence validated by network
28
29 mutable std::mutex mtx_;
30 std::condition_variable cv_;
31
32 SignalType notificationChannel_;
33
34public:
40 static std::shared_ptr<NetworkValidatedLedgers>
42
48 void
49 push(uint32_t idx) final;
50
60 std::optional<uint32_t>
61 getMostRecent() final;
62
72 bool
73 waitUntilValidatedByNetwork(uint32_t sequence, std::optional<uint32_t> maxWaitMs = {}) final;
74
75 boost::signals2::scoped_connection
76 subscribe(SignalType::slot_type const& subscriber) override;
77};
78
79} // namespace etl
An interface for NetworkValidatedLedgers.
Definition NetworkValidatedLedgersInterface.hpp:16
This datastructure is used to keep track of the sequence of the most recent ledger validated by the n...
Definition NetworkValidatedLedgers.hpp:26
void push(uint32_t idx) final
Notify the datastructure that idx has been validated by the network.
Definition NetworkValidatedLedgers.cpp:19
bool waitUntilValidatedByNetwork(uint32_t sequence, std::optional< uint32_t > maxWaitMs={}) final
Waits for the sequence to be validated by the network.
Definition NetworkValidatedLedgers.cpp:38
static std::shared_ptr< NetworkValidatedLedgers > makeValidatedLedgers()
A factory function for NetworkValidatedLedgers.
Definition NetworkValidatedLedgers.cpp:13
std::optional< uint32_t > getMostRecent() final
Get most recently validated sequence.
Definition NetworkValidatedLedgers.cpp:30
boost::signals2::scoped_connection subscribe(SignalType::slot_type const &subscriber) override
Allows clients to get notified when a new validated ledger becomes known to Clio.
Definition NetworkValidatedLedgers.cpp:54