xrpld
Loading...
Searching...
No Matches
NullFactory.cpp
1#include <xrpl/basics/base_uint.h>
2#include <xrpl/beast/utility/Journal.h>
3#include <xrpl/config/BasicConfig.h>
4#include <xrpl/nodestore/Backend.h>
5#include <xrpl/nodestore/Factory.h>
6#include <xrpl/nodestore/Manager.h>
7#include <xrpl/nodestore/NodeObject.h>
8#include <xrpl/nodestore/Scheduler.h>
9#include <xrpl/nodestore/Types.h>
10
11#include <cstddef>
12#include <functional>
13#include <memory>
14#include <string>
15
16namespace xrpl::node_store {
17
18class NullBackend : public Backend
19{
20public:
21 NullBackend() = default;
22
23 ~NullBackend() override = default;
24
26 getName() override
27 {
28 return std::string();
29 }
30
31 void
32 open(bool createIfMissing) override
33 {
34 }
35
36 bool
37 isOpen() override
38 {
39 return false;
40 }
41
42 void
43 close() override
44 {
45 }
46
47 Status
49 {
50 return Status::NotFound;
51 }
52
53 void
54 store(std::shared_ptr<NodeObject> const& object) override
55 {
56 }
57
58 void
59 storeBatch(Batch const& batch) override
60 {
61 }
62
63 void
64 sync() override
65 {
66 }
67
68 void
72
73 int
74 getWriteLoad() override
75 {
76 return 0;
77 }
78
79 void
80 setDeletePath() override
81 {
82 }
83
87 [[nodiscard]] int
88 fdRequired() const override
89 {
90 return 0;
91 }
92
93private:
94};
95
96//------------------------------------------------------------------------------
97
98class NullFactory : public Factory
99{
100private:
102
103public:
104 explicit NullFactory(Manager& manager) : manager_(manager)
105 {
106 manager_.insert(*this);
107 }
108
109 [[nodiscard]] std::string
110 getName() const override
111 {
112 return "none";
113 }
114
117 {
119 }
120};
121
122void
124{
125 static NullFactory const kInstance{manager};
126}
127
128} // namespace xrpl::node_store
A generic endpoint for log messages.
Definition Journal.h:44
Holds a collection of configuration values.
Definition BasicConfig.h:29
A backend used for the NodeStore.
Definition Backend.h:29
Base class for backend factories.
Definition Factory.h:23
Singleton for managing NodeStore factories and back ends.
Definition Manager.h:19
bool isOpen() override
Returns true is the database is open.
Status fetch(uint256 const &, std::shared_ptr< NodeObject > *) override
Fetch a single object.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void storeBatch(Batch const &batch) override
Store a group of objects.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
void close() override
Close the backend.
void open(bool createIfMissing) override
Open the backend.
~NullBackend() override=default
std::string getName() override
Get the human-readable name of this backend.
int getWriteLoad() override
Estimate the number of write operations pending.
void setDeletePath() override
Remove contents on disk upon destruction.
std::unique_ptr< Backend > createInstance(size_t, Section const &, std::size_t, Scheduler &, beast::Journal) override
Create an instance of this factory's backend.
std::string getName() const override
Retrieve the name of this factory.
Scheduling for asynchronous backend activity.
T make_unique(T... args)
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
Status
Return codes from Backend operations.
void registerNullFactory(Manager &manager)
BaseUInt< 256 > uint256
Definition base_uint.h:580