rippled
Loading...
Searching...
No Matches
common.h
1#pragma once
2
3#include <xrpl/basics/chrono.h>
4#include <xrpl/nodestore/DummyScheduler.h>
5#include <xrpl/nodestore/Manager.h>
6#include <xrpl/shamap/Family.h>
7
8namespace xrpl {
9namespace tests {
10
11class TestNodeFamily : public Family
12{
13private:
15
18
21
23
24public:
26 : fbCache_(std::make_shared<FullBelowCache>("App family full below cache", clock_, j))
27 , tnCache_(
28 std::make_shared<TreeNodeCache>("App family tree node cache", 65536, std::chrono::minutes{1}, clock_, j))
29 , j_(j)
30 {
31 Section testSection;
32 testSection.set("type", "memory");
33 testSection.set("path", "SHAMap_test");
35 }
36
38 db() override
39 {
40 return *db_;
41 }
42
44 db() const override
45 {
46 return *db_;
47 }
48
49 beast::Journal const&
50 journal() override
51 {
52 return j_;
53 }
54
57 {
58 return fbCache_;
59 }
60
63 {
64 return tnCache_;
65 }
66
67 void
68 sweep() override
69 {
70 fbCache_->sweep();
71 tnCache_->sweep();
72 }
73
74 void
75 missingNodeAcquireBySeq(std::uint32_t refNum, uint256 const& nodeHash) override
76 {
77 Throw<std::runtime_error>("missing node");
78 }
79
80 void
81 missingNodeAcquireByHash(uint256 const& refHash, std::uint32_t refNum) override
82 {
83 Throw<std::runtime_error>("missing node");
84 }
85
86 void
87 reset() override
88 {
89 fbCache_->reset();
90 tnCache_->reset();
91 }
92
95 {
96 return clock_;
97 }
98};
99
100} // namespace tests
101} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Persistency layer for NodeObject.
Definition Database.h:31
Simple NodeStore Scheduler that just performs the tasks synchronously.
static Manager & instance()
Returns the instance of the manager singleton.
virtual std::unique_ptr< Database > make_Database(std::size_t burstSize, Scheduler &scheduler, int readThreads, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
Holds a collection of configuration values.
Definition BasicConfig.h:24
void set(std::string const &key, std::string const &value)
Set a key/value pair.
Map/cache combination.
Definition TaggedCache.h:42
Remembers which tree keys have all descendants resident.
std::shared_ptr< TreeNodeCache > tnCache_
Definition common.h:17
std::unique_ptr< NodeStore::Database > db_
Definition common.h:14
void missingNodeAcquireByHash(uint256 const &refHash, std::uint32_t refNum) override
Acquire ledger that has a missing node by ledger hash.
Definition common.h:81
NodeStore::Database const & db() const override
Definition common.h:44
std::shared_ptr< FullBelowCache > getFullBelowCache() override
Return a pointer to the Family Full Below Cache.
Definition common.h:56
std::shared_ptr< TreeNodeCache > getTreeNodeCache() override
Return a pointer to the Family Tree Node Cache.
Definition common.h:62
beast::Journal const j_
Definition common.h:22
TestNodeFamily(beast::Journal j)
Definition common.h:25
beast::manual_clock< std::chrono::steady_clock > clock()
Definition common.h:94
std::shared_ptr< FullBelowCache > fbCache_
Definition common.h:16
void sweep() override
Definition common.h:68
NodeStore::DummyScheduler scheduler_
Definition common.h:20
TestStopwatch clock_
Definition common.h:19
void missingNodeAcquireBySeq(std::uint32_t refNum, uint256 const &nodeHash) override
Acquire ledger that has a missing node by ledger sequence.
Definition common.h:75
beast::Journal const & journal() override
Definition common.h:50
NodeStore::Database & db() override
Definition common.h:38
void reset() override
Definition common.h:87
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr auto megabytes(T value) noexcept