Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
LedgerCacheInterface.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/Types.hpp"
23#include "etlng/Models.hpp"
24
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/basics/hardened_hash.h>
27
28#include <cstddef>
29#include <cstdint>
30#include <optional>
31#include <vector>
32
33namespace data {
34
39public:
40 virtual ~LedgerCacheInterface() = default;
41 LedgerCacheInterface() = default;
45 operator=(LedgerCacheInterface&&) = delete;
47 operator=(LedgerCacheInterface const&) = delete;
48
56 virtual void
57 update(std::vector<LedgerObject> const& objs, uint32_t seq, bool isBackground = false) = 0;
58
65 virtual void
66 update(std::vector<etlng::model::Object> const& objs, uint32_t seq) = 0;
67
75 virtual std::optional<Blob>
76 get(ripple::uint256 const& key, uint32_t seq) const = 0;
77
85 virtual std::optional<Blob>
86 getDeleted(ripple::uint256 const& key, uint32_t seq) const = 0;
87
97 virtual std::optional<LedgerObject>
98 getSuccessor(ripple::uint256 const& key, uint32_t seq) const = 0;
99
109 virtual std::optional<LedgerObject>
110 getPredecessor(ripple::uint256 const& key, uint32_t seq) const = 0;
111
115 virtual void
117
121 virtual bool
122 isDisabled() const = 0;
123
131 virtual void
132 setFull() = 0;
133
137 virtual uint32_t
139
143 virtual bool
144 isFull() const = 0;
145
149 virtual size_t
150 size() const = 0;
151
155 virtual float
156 getObjectHitRate() const = 0;
157
161 virtual float
163
169 virtual void
170 waitUntilCacheContainsSeq(uint32_t seq) = 0;
171};
172
173} // namespace data
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:38
virtual std::optional< LedgerObject > getPredecessor(ripple::uint256 const &key, uint32_t seq) const =0
Gets a cached predcessor.
virtual bool isFull() const =0
virtual float getObjectHitRate() const =0
virtual void update(std::vector< LedgerObject > const &objs, uint32_t seq, bool isBackground=false)=0
Update the cache with new ledger objects.
virtual bool isDisabled() const =0
virtual void setDisabled()=0
Disables the cache.
virtual void setFull()=0
Sets the full flag to true.
virtual std::optional< Blob > get(ripple::uint256 const &key, uint32_t seq) const =0
Fetch a cached object by its key and sequence number.
virtual size_t size() const =0
virtual std::optional< LedgerObject > getSuccessor(ripple::uint256 const &key, uint32_t seq) const =0
Gets a cached successor.
virtual void update(std::vector< etlng::model::Object > const &objs, uint32_t seq)=0
Update the cache with new ledger objects.
virtual void waitUntilCacheContainsSeq(uint32_t seq)=0
Waits until the cache contains a specific sequence.
virtual std::optional< Blob > getDeleted(ripple::uint256 const &key, uint32_t seq) const =0
Fetch a recently deleted object by its key and sequence number.
virtual float getSuccessorHitRate() const =0
virtual uint32_t latestLedgerSequence() const =0
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70