rippled
Loading...
Searching...
No Matches
NullFactory.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpld/nodestore/Factory.h>
21#include <xrpld/nodestore/Manager.h>
22
23#include <memory>
24
25namespace ripple {
26namespace NodeStore {
27
28class NullBackend : public Backend
29{
30public:
31 NullBackend() = default;
32
33 ~NullBackend() = default;
34
36 getName() override
37 {
38 return std::string();
39 }
40
41 void
42 open(bool createIfMissing) override
43 {
44 }
45
46 bool
47 isOpen() override
48 {
49 return false;
50 }
51
52 void
53 close() override
54 {
55 }
56
57 Status
58 fetch(void const*, std::shared_ptr<NodeObject>*) override
59 {
60 return notFound;
61 }
62
65 {
66 return {};
67 }
68
69 void
70 store(std::shared_ptr<NodeObject> const& object) override
71 {
72 }
73
74 void
75 storeBatch(Batch const& batch) override
76 {
77 }
78
79 void
80 sync() override
81 {
82 }
83
84 void
88
89 int
90 getWriteLoad() override
91 {
92 return 0;
93 }
94
95 void
96 setDeletePath() override
97 {
98 }
99
101 int
102 fdRequired() const override
103 {
104 return 0;
105 }
106
107private:
108};
109
110//------------------------------------------------------------------------------
111
112class NullFactory : public Factory
113{
114public:
116 {
117 Manager::instance().insert(*this);
118 }
119
120 ~NullFactory() override
121 {
122 Manager::instance().erase(*this);
123 }
124
126 getName() const override
127 {
128 return "none";
129 }
130
133 size_t,
134 Section const&,
136 Scheduler&,
137 beast::Journal) override
138 {
140 }
141};
142
144
145} // namespace NodeStore
146} // namespace ripple
A generic endpoint for log messages.
Definition Journal.h:60
A backend used for the NodeStore.
Definition Backend.h:40
Base class for backend factories.
Definition Factory.h:37
static Manager & instance()
Returns the instance of the manager singleton.
virtual void erase(Factory &factory)=0
Remove a factory.
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:45
T is_same_v
static NullFactory nullFactory
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25