xrpld
Loading...
Searching...
No Matches
Backend.h
1#pragma once
2
3#include <xrpl/nodestore/Types.h>
4
5#include <cstdint>
6
7namespace xrpl::NodeStore {
8
19{
20public:
27 virtual ~Backend() = default;
28
32 virtual std::string
33 getName() = 0;
34
37 [[nodiscard]] virtual std::optional<std::size_t>
39 {
40 return std::nullopt;
41 }
42
47 virtual void
48 open(bool createIfMissing = true) = 0;
49
52 virtual bool
53 isOpen() = 0;
54
62 virtual void
63 open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
64 {
66 "Deterministic appType/uid/salt not supported by backend " + getName());
67 }
68
72 virtual void
73 close() = 0;
74
83 virtual Status
84 fetch(uint256 const& hash, std::shared_ptr<NodeObject>* pObject) = 0;
85
92 virtual void
94
99 virtual void
100 storeBatch(Batch const& batch) = 0;
101
102 virtual void
103 sync() = 0;
104
111 virtual void
113
115 virtual int
117
119 virtual void
121
128 virtual void
130 {
131 }
132
134 [[nodiscard]] virtual int
135 fdRequired() const = 0;
136};
137
138} // namespace xrpl::NodeStore
A backend used for the NodeStore.
Definition Backend.h:19
virtual std::optional< std::size_t > getBlockSize() const
Get the block size for backends that support it.
Definition Backend.h:38
virtual ~Backend()=default
Destroy the backend.
virtual int getWriteLoad()=0
Estimate the number of write operations pending.
virtual int fdRequired() const =0
Returns the number of file descriptors the backend expects to need.
virtual void close()=0
Close the backend.
virtual void forEach(std::function< void(std::shared_ptr< NodeObject >)> f)=0
Visit every object in the database This is usually called during import.
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
virtual void sync()=0
virtual std::string getName()=0
Get the human-readable name of this backend.
virtual void open(bool createIfMissing=true)=0
Open the backend.
virtual bool isOpen()=0
Returns true is the database is open.
virtual void verify()
Perform consistency checks on database.
Definition Backend.h:129
virtual void storeBatch(Batch const &batch)=0
Store a group of objects.
virtual void open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
Open the backend.
Definition Backend.h:63
virtual Status fetch(uint256 const &hash, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
virtual void setDeletePath()=0
Remove contents on disk upon destruction.
Status
Return codes from Backend operations.
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
BaseUInt< 256 > uint256
Definition base_uint.h:562
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:49