xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
nodestore
Backend.h
1
#pragma once
2
3
#include <xrpl/basics/base_uint.h>
4
#include <xrpl/basics/contract.h>
5
#include <xrpl/nodestore/NodeObject.h>
6
#include <xrpl/nodestore/Types.h>
7
8
#include <
cstddef
>
9
#include <
cstdint
>
10
#include <
functional
>
11
#include <
memory
>
12
#include <
optional
>
13
#include <
stdexcept
>
14
#include <
string
>
15
16
namespace
xrpl::node_store
{
17
28
class
Backend
29
{
30
public
:
38
virtual
~Backend
() =
default
;
39
44
virtual
std::string
45
getName
() = 0;
46
50
[[nodiscard]]
virtual
std::optional<std::size_t>
51
getBlockSize
()
const
52
{
53
return
std::nullopt;
54
}
55
61
virtual
void
62
open
(
bool
createIfMissing =
true
) = 0;
63
67
virtual
bool
68
isOpen
() = 0;
69
78
virtual
void
79
open
(
bool
createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
80
{
81
Throw<std::runtime_error>
(
82
"Deterministic appType/uid/salt not supported by backend "
+
getName
());
83
}
84
89
virtual
void
90
close
() = 0;
91
101
virtual
Status
102
fetch
(
UInt256
const
& hash,
std::shared_ptr<NodeObject>
* pObject) = 0;
103
111
virtual
void
112
store
(
std::shared_ptr<NodeObject>
const
&
object
) = 0;
113
119
virtual
void
120
storeBatch
(
Batch
const
& batch) = 0;
121
122
virtual
void
123
sync
() = 0;
124
132
virtual
void
133
forEach
(
std::function
<
void
(
std::shared_ptr<NodeObject>
)> f) = 0;
134
138
virtual
int
139
getWriteLoad
() = 0;
140
144
virtual
void
145
setDeletePath
() = 0;
146
154
virtual
void
155
verify
()
156
{
157
}
158
162
[[nodiscard]]
virtual
int
163
fdRequired
()
const
= 0;
164
};
165
166
}
// namespace xrpl::node_store
std::string
xrpl::node_store::Backend
A backend used for the NodeStore.
Definition
Backend.h:29
xrpl::node_store::Backend::close
virtual void close()=0
Close the backend.
xrpl::node_store::Backend::getWriteLoad
virtual int getWriteLoad()=0
Estimate the number of write operations pending.
xrpl::node_store::Backend::isOpen
virtual bool isOpen()=0
Returns true is the database is open.
xrpl::node_store::Backend::~Backend
virtual ~Backend()=default
Destroy the backend.
xrpl::node_store::Backend::verify
virtual void verify()
Perform consistency checks on database.
Definition
Backend.h:155
xrpl::node_store::Backend::store
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
xrpl::node_store::Backend::open
virtual void open(bool createIfMissing=true)=0
Open the backend.
xrpl::node_store::Backend::sync
virtual void sync()=0
xrpl::node_store::Backend::getName
virtual std::string getName()=0
Get the human-readable name of this backend.
xrpl::node_store::Backend::open
virtual void open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
Open the backend.
Definition
Backend.h:79
xrpl::node_store::Backend::getBlockSize
virtual std::optional< std::size_t > getBlockSize() const
Get the block size for backends that support it.
Definition
Backend.h:51
xrpl::node_store::Backend::forEach
virtual void forEach(std::function< void(std::shared_ptr< NodeObject >)> f)=0
Visit every object in the database This is usually called during import.
xrpl::node_store::Backend::storeBatch
virtual void storeBatch(Batch const &batch)=0
Store a group of objects.
xrpl::node_store::Backend::setDeletePath
virtual void setDeletePath()=0
Remove contents on disk upon destruction.
xrpl::node_store::Backend::fetch
virtual Status fetch(UInt256 const &hash, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
xrpl::node_store::Backend::fdRequired
virtual int fdRequired() const =0
Returns the number of file descriptors the backend expects to need.
cstddef
cstdint
std::function
functional
memory
xrpl::node_store
Definition
ServiceRegistry.h:18
xrpl::node_store::Batch
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
Definition
nodestore/Types.h:37
xrpl::node_store::Status
Status
Return codes from Backend operations.
Definition
nodestore/Types.h:24
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::Throw
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition
contract.h:52
optional
std::shared_ptr
stdexcept
string
Generated by
1.17.0