Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
LedgerHeaderCache.hpp
1
#pragma once
2
3
#include "util/Mutex.hpp"
4
5
#include <xrpl/protocol/LedgerHeader.h>
6
7
#include <cstdint>
8
#include <optional>
9
#include <shared_mutex>
10
11
namespace
data
{
12
22
class
FetchLedgerCache {
23
public
:
24
FetchLedgerCache();
25
29
struct
CacheEntry
{
30
ripple::LedgerHeader ledger;
31
uint32_t seq{};
32
39
bool
40
operator==
(
CacheEntry
const
& other)
const
41
{
42
return
ledger.hash == other.ledger.hash && seq == other.seq;
43
}
44
};
45
51
void
52
put
(CacheEntry
const
& cacheEntry);
53
59
std::optional<CacheEntry>
60
get
()
const
;
61
62
private
:
63
mutable
util::Mutex<std::optional<CacheEntry>
, std::shared_mutex> mutex_;
64
};
65
66
}
// namespace data
data::FetchLedgerCache::put
void put(CacheEntry const &cacheEntry)
Put CacheEntry into thread-safe container.
Definition
LedgerHeaderCache.cpp:14
data::FetchLedgerCache::get
std::optional< CacheEntry > get() const
Read CacheEntry from thread-safe container.
Definition
LedgerHeaderCache.cpp:21
util::Mutex
A container for data that is protected by a mutex. Inspired by Mutex in Rust.
Definition
Mutex.hpp:82
data
This namespace implements the data access layer and related components.
Definition
AmendmentCenter.cpp:56
data::FetchLedgerCache::CacheEntry
Struct to store ledger header cache entry and the sequence it belongs to.
Definition
LedgerHeaderCache.hpp:29
data::FetchLedgerCache::CacheEntry::operator==
bool operator==(CacheEntry const &other) const
Comparing CacheEntry. Used in testing for EXPECT_CALL.
Definition
LedgerHeaderCache.hpp:40
src
data
LedgerHeaderCache.hpp
Generated by
1.16.1