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::NodeStore {
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
85 [[nodiscard]] int
86 fdRequired() const override
87 {
88 return 0;
89 }
90
91private:
92};
93
94//------------------------------------------------------------------------------
95
96class NullFactory : public Factory
97{
98private:
100
101public:
102 explicit NullFactory(Manager& manager) : manager_(manager)
103 {
104 manager_.insert(*this);
105 }
106
107 [[nodiscard]] std::string
108 getName() const override
109 {
110 return "none";
111 }
112
115 {
117 }
118};
119
120void
122{
123 static NullFactory const kInstance{manager};
124}
125
126} // namespace xrpl::NodeStore
A generic endpoint for log messages.
Definition Journal.h:38
A backend used for the NodeStore.
Definition Backend.h:19
Base class for backend factories.
Definition Factory.h:17
Singleton for managing NodeStore factories and back ends.
Definition Manager.h:10
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
bool isOpen() override
Returns true is the database is open.
Status fetch(uint256 const &, std::shared_ptr< NodeObject > *) override
Fetch a single object.
void storeBatch(Batch const &batch) override
Store a group of objects.
void close() override
Close the backend.
int getWriteLoad() override
Estimate the number of write operations pending.
void open(bool createIfMissing) override
Open the backend.
~NullBackend() override=default
void setDeletePath() override
Remove contents on disk upon destruction.
std::string getName() override
Get the human-readable name of this backend.
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
std::unique_ptr< Backend > createInstance(size_t, Section const &, std::size_t, Scheduler &, beast::Journal) override
Create an instance of this factory's backend.
NullFactory(Manager &manager)
std::string getName() const override
Retrieve the name of this factory.
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
Definition BasicConfig.h:24
T make_unique(T... args)
void registerNullFactory(Manager &manager)
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