rippled
Loading...
Searching...
No Matches
DatabaseNodeImp.h
1#pragma once
2
3#include <xrpl/basics/TaggedCache.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/nodestore/Database.h>
6
7namespace xrpl {
8namespace NodeStore {
9
11{
12public:
13 DatabaseNodeImp() = delete;
16 operator=(DatabaseNodeImp const&) = delete;
17
19 Scheduler& scheduler,
20 int readThreads,
22 Section const& config,
24 : Database(scheduler, readThreads, config, j), backend_(std::move(backend))
25 {
26 XRPL_ASSERT(
28 "xrpl::NodeStore::DatabaseNodeImp::DatabaseNodeImp : non-null "
29 "backend");
30 }
31
33 {
34 stop();
35 }
36
38 getName() const override
39 {
40 return backend_->getName();
41 }
42
44 getWriteLoad() const override
45 {
46 return backend_->getWriteLoad();
47 }
48
49 void
50 importDatabase(Database& source) override
51 {
52 importInternal(*backend_.get(), source);
53 }
54
55 void
56 store(NodeObjectType type, Blob&& data, uint256 const& hash, std::uint32_t) override;
57
58 bool
60 {
61 // only one database
62 return true;
63 }
64
65 void
66 sync() override
67 {
68 backend_->sync();
69 }
70
72 fetchBatch(std::vector<uint256> const& hashes);
73
74 void
76 uint256 const& hash,
77 std::uint32_t ledgerSeq,
78 std::function<void(std::shared_ptr<NodeObject> const&)>&& callback) override;
79
80private:
81 // Persistent key/value storage
83
85 fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport& fetchReport, bool duplicate) override;
86
87 void
89 {
90 backend_->for_each(f);
91 }
92};
93
94} // namespace NodeStore
95} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
std::string getName() const override
Retrieve the name associated with this backend.
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
std::shared_ptr< Backend > backend_
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override
Fetch an object without waiting.
bool isSameDB(std::uint32_t, std::uint32_t) override
DatabaseNodeImp(Scheduler &scheduler, int readThreads, std::shared_ptr< Backend > backend, Section const &config, beast::Journal j)
DatabaseNodeImp(DatabaseNodeImp const &)=delete
DatabaseNodeImp & operator=(DatabaseNodeImp const &)=delete
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::vector< uint256 > const &hashes)
void importDatabase(Database &source) override
Import objects from another database.
Persistency layer for NodeObject.
Definition Database.h:31
void importInternal(Backend &dstBackend, Database &srcDB)
Definition Database.cpp:164
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
Definition BasicConfig.h:24
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
NodeObjectType
The types of node objects.
Definition NodeObject.h:12
Contains information about a fetch operation.