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