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>(
29 "App family tree node cache",
30 65536,
31 std::chrono::minutes{1},
32 clock_,
33 j))
34 , j_(j)
35 {
36 Section testSection;
37 testSection.set("type", "memory");
38 testSection.set("path", "SHAMap_test");
40 megabytes(4), scheduler_, 1, testSection, j);
41 }
42
44 db() override
45 {
46 return *db_;
47 }
48
50 db() const override
51 {
52 return *db_;
53 }
54
55 beast::Journal const&
56 journal() override
57 {
58 return j_;
59 }
60
63 {
64 return fbCache_;
65 }
66
69 {
70 return tnCache_;
71 }
72
73 void
74 sweep() override
75 {
76 fbCache_->sweep();
77 tnCache_->sweep();
78 }
79
80 void
81 missingNodeAcquireBySeq(std::uint32_t refNum, uint256 const& nodeHash) override
82 {
83 Throw<std::runtime_error>("missing node");
84 }
85
86 void
87 missingNodeAcquireByHash(uint256 const& refHash, std::uint32_t refNum) override
88 {
89 Throw<std::runtime_error>("missing node");
90 }
91
92 void
93 reset() override
94 {
95 fbCache_->reset();
96 tnCache_->reset();
97 }
98
101 {
102 return clock_;
103 }
104};
105
106} // namespace tests
107} // 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:87
NodeStore::Database const & db() const override
Definition common.h:50
std::shared_ptr< FullBelowCache > getFullBelowCache() override
Return a pointer to the Family Full Below Cache.
Definition common.h:62
std::shared_ptr< TreeNodeCache > getTreeNodeCache() override
Return a pointer to the Family Tree Node Cache.
Definition common.h:68
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:100
std::shared_ptr< FullBelowCache > fbCache_
Definition common.h:16
void sweep() override
Definition common.h:74
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:81
beast::Journal const & journal() override
Definition common.h:56
NodeStore::Database & db() override
Definition common.h:44
void reset() override
Definition common.h:93
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