rippled
Loading...
Searching...
No Matches
common.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_SHAMAP_TESTS_COMMON_H_INCLUDED
21#define RIPPLE_SHAMAP_TESTS_COMMON_H_INCLUDED
22
23#include <xrpl/basics/chrono.h>
24#include <xrpl/nodestore/DummyScheduler.h>
25#include <xrpl/nodestore/Manager.h>
26#include <xrpl/shamap/Family.h>
27
28namespace ripple {
29namespace tests {
30
31class TestNodeFamily : public Family
32{
33private:
35
38
41
43
44public:
46 : fbCache_(std::make_shared<FullBelowCache>(
47 "App family full below cache",
48 clock_,
49 j))
50 , tnCache_(std::make_shared<TreeNodeCache>(
51 "App family tree node cache",
52 65536,
53 std::chrono::minutes{1},
54 clock_,
55 j))
56 , j_(j)
57 {
58 Section testSection;
59 testSection.set("type", "memory");
60 testSection.set("path", "SHAMap_test");
62 megabytes(4), scheduler_, 1, testSection, j);
63 }
64
66 db() override
67 {
68 return *db_;
69 }
70
72 db() const override
73 {
74 return *db_;
75 }
76
77 beast::Journal const&
78 journal() override
79 {
80 return j_;
81 }
82
85 {
86 return fbCache_;
87 }
88
91 {
92 return tnCache_;
93 }
94
95 void
96 sweep() override
97 {
98 fbCache_->sweep();
99 tnCache_->sweep();
100 }
101
102 void
104 override
105 {
106 Throw<std::runtime_error>("missing node");
107 }
108
109 void
111 override
112 {
113 Throw<std::runtime_error>("missing node");
114 }
115
116 void
117 reset() override
118 {
119 fbCache_->reset();
120 tnCache_->reset();
121 }
122
125 {
126 return clock_;
127 }
128};
129
130} // namespace tests
131} // namespace ripple
132
133#endif
A generic endpoint for log messages.
Definition Journal.h:60
Persistency layer for NodeObject.
Definition Database.h:51
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:45
void set(std::string const &key, std::string const &value)
Set a key/value pair.
Map/cache combination.
Definition TaggedCache.h:62
Remembers which tree keys have all descendants resident.
TestNodeFamily(beast::Journal j)
Definition common.h:45
std::unique_ptr< NodeStore::Database > db_
Definition common.h:34
void reset() override
Definition common.h:117
beast::Journal const & journal() override
Definition common.h:78
NodeStore::Database & db() override
Definition common.h:66
std::shared_ptr< FullBelowCache > fbCache_
Definition common.h:36
std::shared_ptr< TreeNodeCache > getTreeNodeCache() override
Return a pointer to the Family Tree Node Cache.
Definition common.h:90
void missingNodeAcquireBySeq(std::uint32_t refNum, uint256 const &nodeHash) override
Acquire ledger that has a missing node by ledger sequence.
Definition common.h:103
void sweep() override
Definition common.h:96
void missingNodeAcquireByHash(uint256 const &refHash, std::uint32_t refNum) override
Acquire ledger that has a missing node by ledger hash.
Definition common.h:110
std::shared_ptr< TreeNodeCache > tnCache_
Definition common.h:37
NodeStore::Database const & db() const override
Definition common.h:72
std::shared_ptr< FullBelowCache > getFullBelowCache() override
Return a pointer to the Family Full Below Cache.
Definition common.h:84
NodeStore::DummyScheduler scheduler_
Definition common.h:40
beast::Journal const j_
Definition common.h:42
beast::manual_clock< std::chrono::steady_clock > clock()
Definition common.h:124
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
constexpr auto megabytes(T value) noexcept
STL namespace.