22#include "data/Types.hpp"
23#include "etl/Models.hpp"
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/basics/hardened_hash.h>
40class LedgerCacheInterface {
42 virtual ~LedgerCacheInterface() =
default;
43 LedgerCacheInterface() =
default;
44 LedgerCacheInterface(LedgerCacheInterface&&) =
delete;
45 LedgerCacheInterface(LedgerCacheInterface
const&) =
delete;
47 operator=(LedgerCacheInterface&&) =
delete;
49 operator=(LedgerCacheInterface
const&) =
delete;
59 update(std::vector<LedgerObject>
const& objs, uint32_t seq,
bool isBackground =
false) = 0;
68 update(std::vector<etl::model::Object>
const& objs, uint32_t seq) = 0;
77 virtual std::optional<Blob>
78 get(ripple::uint256
const& key, uint32_t seq)
const = 0;
87 virtual std::optional<Blob>
88 getDeleted(ripple::uint256
const& key, uint32_t seq)
const = 0;
99 virtual std::optional<LedgerObject>
111 virtual std::optional<LedgerObject>
181 [[nodiscard]]
virtual std::expected<void, std::string>
192 [[nodiscard]]
virtual std::expected<void, std::string>
virtual std::optional< LedgerObject > getPredecessor(ripple::uint256 const &key, uint32_t seq) const =0
Gets a cached predcessor.
virtual std::expected< void, std::string > saveToFile(std::string const &path) const =0
Save the cache to file.
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< etl::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 std::expected< void, std::string > loadFromFile(std::string const &path, uint32_t minLatestSequence)=0
Load the cache from file.
virtual uint32_t latestLedgerSequence() const =0
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70