rippled
Loading...
Searching...
No Matches
Backend.h
1#ifndef XRPL_NODESTORE_BACKEND_H_INCLUDED
2#define XRPL_NODESTORE_BACKEND_H_INCLUDED
3
4#include <xrpl/nodestore/Types.h>
5
6#include <cstdint>
7
8namespace ripple {
9namespace NodeStore {
10
21{
22public:
29 virtual ~Backend() = default;
30
34 virtual std::string
35 getName() = 0;
36
41 {
42 return std::nullopt;
43 }
44
49 virtual void
50 open(bool createIfMissing = true) = 0;
51
54 virtual bool
55 isOpen() = 0;
56
64 virtual void
65 open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
66 {
67 Throw<std::runtime_error>(
68 "Deterministic appType/uid/salt not supported by backend " +
69 getName());
70 }
71
75 virtual void
76 close() = 0;
77
86 virtual Status
87 fetch(void const* key, std::shared_ptr<NodeObject>* pObject) = 0;
88
92
99 virtual void
101
106 virtual void
107 storeBatch(Batch const& batch) = 0;
108
109 virtual void
110 sync() = 0;
111
118 virtual void
120
122 virtual int
124
126 virtual void
128
135 virtual void
137 {
138 }
139
141 virtual int
142 fdRequired() const = 0;
143};
144
145} // namespace NodeStore
146} // namespace ripple
147
148#endif
A backend used for the NodeStore.
Definition Backend.h:21
virtual std::string getName()=0
Get the human-readable name of this backend.
virtual void open(bool createIfMissing=true)=0
Open the backend.
virtual std::optional< std::size_t > getBlockSize() const
Get the block size for backends that support it.
Definition Backend.h:40
virtual void close()=0
Close the backend.
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 ~Backend()=default
Destroy the backend.
virtual Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
virtual void setDeletePath()=0
Remove contents on disk upon destruction.
virtual int fdRequired() const =0
Returns the number of file descriptors the backend expects to need.
virtual std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes)=0
Fetch a batch synchronously.
virtual int getWriteLoad()=0
Estimate the number of write operations pending.
virtual void storeBatch(Batch const &batch)=0
Store a group of objects.
virtual bool isOpen()=0
Returns true is the database is open.
virtual void open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
Open the backend.
Definition Backend.h:65
virtual void verify()
Perform consistency checks on database.
Definition Backend.h:136
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:6