rippled
Loading...
Searching...
No Matches
NullFactory.cpp
1#include <xrpl/nodestore/Factory.h>
2#include <xrpl/nodestore/Manager.h>
3
4#include <memory>
5
6namespace ripple {
7namespace NodeStore {
8
9class NullBackend : public Backend
10{
11public:
12 NullBackend() = default;
13
14 ~NullBackend() = default;
15
17 getName() override
18 {
19 return std::string();
20 }
21
22 void
23 open(bool createIfMissing) override
24 {
25 }
26
27 bool
28 isOpen() override
29 {
30 return false;
31 }
32
33 void
34 close() override
35 {
36 }
37
38 Status
39 fetch(void const*, std::shared_ptr<NodeObject>*) override
40 {
41 return notFound;
42 }
43
46 {
47 return {};
48 }
49
50 void
51 store(std::shared_ptr<NodeObject> const& object) override
52 {
53 }
54
55 void
56 storeBatch(Batch const& batch) override
57 {
58 }
59
60 void
61 sync() override
62 {
63 }
64
65 void
69
70 int
71 getWriteLoad() override
72 {
73 return 0;
74 }
75
76 void
77 setDeletePath() override
78 {
79 }
80
82 int
83 fdRequired() const override
84 {
85 return 0;
86 }
87
88private:
89};
90
91//------------------------------------------------------------------------------
92
93class NullFactory : public Factory
94{
95private:
97
98public:
99 explicit NullFactory(Manager& manager) : manager_(manager)
100 {
101 manager_.insert(*this);
102 }
103
105 getName() const override
106 {
107 return "none";
108 }
109
112 size_t,
113 Section const&,
115 Scheduler&,
116 beast::Journal) override
117 {
119 }
120};
121
122void
124{
125 static NullFactory instance{manager};
126}
127
128} // namespace NodeStore
129} // namespace ripple
A generic endpoint for log messages.
Definition Journal.h:41
A backend used for the NodeStore.
Definition Backend.h:21
Base class for backend factories.
Definition Factory.h:17
Singleton for managing NodeStore factories and back ends.
Definition Manager.h:13
virtual void insert(Factory &factory)=0
Add a factory.
void close() override
Close the backend.
int getWriteLoad() override
Estimate the number of write operations pending.
bool isOpen() override
Returns true is the database is open.
void open(bool createIfMissing) override
Open the backend.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
Status fetch(void const *, std::shared_ptr< NodeObject > *) override
Fetch a single object.
void setDeletePath() override
Remove contents on disk upon destruction.
std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes) override
Fetch a batch synchronously.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
std::string getName() override
Get the human-readable name of this backend.
void storeBatch(Batch const &batch) override
Store a group of objects.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
std::string getName() const override
Retrieve the name of this factory.
std::unique_ptr< Backend > createInstance(size_t, Section const &, std::size_t, Scheduler &, beast::Journal) override
Create an instance of this factory's backend.
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
Definition BasicConfig.h:26
T is_same_v
void registerNullFactory(Manager &manager)
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6