rippled
Loading...
Searching...
No Matches
Backend.h
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#ifndef RIPPLE_NODESTORE_BACKEND_H_INCLUDED
21#define RIPPLE_NODESTORE_BACKEND_H_INCLUDED
22
23#include <xrpld/nodestore/Types.h>
24
25#include <cstdint>
26
27namespace ripple {
28namespace NodeStore {
29
40{
41public:
48 virtual ~Backend() = default;
49
53 virtual std::string
54 getName() = 0;
55
60 virtual void
61 open(bool createIfMissing = true) = 0;
62
65 virtual bool
66 isOpen() = 0;
67
75 virtual void
76 open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
77 {
78 Throw<std::runtime_error>(
79 "Deterministic appType/uid/salt not supported by backend " +
80 getName());
81 }
82
86 virtual void
87 close() = 0;
88
97 virtual Status
98 fetch(void const* key, std::shared_ptr<NodeObject>* pObject) = 0;
99
103
110 virtual void
112
117 virtual void
118 storeBatch(Batch const& batch) = 0;
119
120 virtual void
121 sync() = 0;
122
129 virtual void
131
133 virtual int
135
137 virtual void
139
146 virtual void
148 {
149 }
150
152 virtual int
153 fdRequired() const = 0;
154};
155
156} // namespace NodeStore
157} // namespace ripple
158
159#endif
A backend used for the NodeStore.
Definition: Backend.h:40
virtual std::string getName()=0
Get the human-readable name of this backend.
virtual void open(bool createIfMissing=true)=0
Open the backend.
virtual void close()=0
Close the backend.
virtual void for_each(std::function< void(std::shared_ptr< NodeObject >)> f)=0
Visit every object in the database This is usually called during import.
virtual ~Backend()=default
Destroy the backend.
virtual Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
virtual void setDeletePath()=0
Remove contents on disk upon destruction.
virtual int fdRequired() const =0
Returns the number of file descriptors the backend expects to need.
virtual std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes)=0
Fetch a batch synchronously.
virtual int getWriteLoad()=0
Estimate the number of write operations pending.
virtual void storeBatch(Batch const &batch)=0
Store a group of objects.
virtual bool isOpen()=0
Returns true is the database is open.
virtual void open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
Open the backend.
Definition: Backend.h:76
virtual void verify()
Perform consistency checks on database.
Definition: Backend.h:147
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:25