rippled
Loading...
Searching...
No Matches
Backend.h
1#pragma once
2
3#include <xrpl/nodestore/Types.h>
4
5#include <cstdint>
6
7namespace xrpl {
8namespace NodeStore {
9
20{
21public:
28 virtual ~Backend() = default;
29
33 virtual std::string
34 getName() = 0;
35
40 {
41 return std::nullopt;
42 }
43
48 virtual void
49 open(bool createIfMissing = true) = 0;
50
53 virtual bool
54 isOpen() = 0;
55
63 virtual void
64 open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
65 {
66 Throw<std::runtime_error>("Deterministic appType/uid/salt not supported by backend " + getName());
67 }
68
72 virtual void
73 close() = 0;
74
83 virtual Status
84 fetch(void const* key, std::shared_ptr<NodeObject>* pObject) = 0;
85
89
96 virtual void
98
103 virtual void
104 storeBatch(Batch const& batch) = 0;
105
106 virtual void
107 sync() = 0;
108
115 virtual void
117
119 virtual int
121
123 virtual void
125
132 virtual void
134 {
135 }
136
138 virtual int
139 fdRequired() const = 0;
140};
141
142} // namespace NodeStore
143} // namespace xrpl
A backend used for the NodeStore.
Definition Backend.h:20
virtual std::optional< std::size_t > getBlockSize() const
Get the block size for backends that support it.
Definition Backend.h:39
virtual std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes)=0
Fetch a batch synchronously.
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 store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
virtual void for_each(std::function< void(std::shared_ptr< NodeObject >)> f)=0
Visit every object in the database This is usually called during import.
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 Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
virtual bool isOpen()=0
Returns true is the database is open.
virtual void verify()
Perform consistency checks on database.
Definition Backend.h:133
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:64
virtual void setDeletePath()=0
Remove contents on disk upon destruction.
T is_same_v
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5