Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
CorruptionDetector.hpp
1#pragma once
2
3#include "data/LedgerCacheInterface.hpp"
4#include "etl/SystemState.hpp"
5#include "util/log/Logger.hpp"
6
7#include <functional>
8
9namespace etl {
10
17 std::reference_wrapper<SystemState> state_;
18 std::reference_wrapper<data::LedgerCacheInterface> cache_;
19
20 util::Logger log_{"ETL"};
21
22public:
30 : state_{std::ref(state)}, cache_{std::ref(cache)}
31 {
32 }
33
37 void
39 {
40 if (not state_.get().isCorruptionDetected) {
41 state_.get().isCorruptionDetected = true;
42
43 LOG(
44 log_.error()
45 ) << "Disabling the cache to avoid corrupting the DB further. Please investigate.";
46 cache_.get().setDisabled();
47 }
48 }
49};
50
51} // namespace etl
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:21
void onCorruptionDetected()
Notify the operator about a corruption in the DB.
Definition CorruptionDetector.hpp:38
CorruptionDetector(SystemState &state, data::LedgerCacheInterface &cache)
Construct a new Corruption Detector object.
Definition CorruptionDetector.hpp:29
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:78
Represents the state of the ETL subsystem.
Definition SystemState.hpp:20