rippled
ShardFamily.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2020 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_SHARDFAMILY_H_INCLUDED
21 #define RIPPLE_SHAMAP_SHARDFAMILY_H_INCLUDED
22 
23 #include <ripple/app/main/CollectorManager.h>
24 #include <ripple/shamap/Family.h>
25 
26 namespace ripple {
27 
28 class Application;
29 
30 class ShardFamily : public Family
31 {
32 public:
33  ShardFamily() = delete;
34  ShardFamily(ShardFamily const&) = delete;
35  ShardFamily(ShardFamily&&) = delete;
36 
38  operator=(ShardFamily const&) = delete;
39 
41  operator=(ShardFamily&&) = delete;
42 
44 
46  db() override
47  {
48  return db_;
49  }
50 
51  NodeStore::Database const&
52  db() const override
53  {
54  return db_;
55  }
56 
57  beast::Journal const&
58  journal() override
59  {
60  return j_;
61  }
62 
63  bool
64  isShardBacked() const override
65  {
66  return true;
67  }
68 
70  getFullBelowCache(std::uint32_t ledgerSeq) override;
71 
73  int
75 
77  getTreeNodeCache(std::uint32_t ledgerSeq) override;
78 
84 
85  void
86  sweep() override;
87 
88  void
89  reset() override;
90 
91  void
92  missingNode(std::uint32_t seq) override;
93 
94  void
95  missingNode(uint256 const& hash, std::uint32_t seq) override
96  {
97  acquire(hash, seq);
98  }
99 
100 private:
105 
108 
111  int const tnTargetSize_;
113 
114  // Missing node handler
117 
118  void
119  acquire(uint256 const& hash, std::uint32_t seq);
120 };
121 
122 } // namespace ripple
123 
124 #endif
ripple::Application
Definition: Application.h:115
ripple::ShardFamily::getTreeNodeCache
std::shared_ptr< TreeNodeCache > getTreeNodeCache(std::uint32_t ledgerSeq) override
Return a pointer to the Family Tree Node Cache.
Definition: ShardFamily.cpp:76
ripple::ShardFamily::maxSeqMutex_
std::mutex maxSeqMutex_
Definition: ShardFamily.h:116
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:51
std::shared_ptr
STL class.
ripple::ShardFamily::cm_
CollectorManager & cm_
Definition: ShardFamily.h:103
std::pair
ripple::ShardFamily::app_
Application & app_
Definition: ShardFamily.h:101
ripple::ShardFamily::db_
NodeStore::Database & db_
Definition: ShardFamily.h:102
ripple::CollectorManager
Provides the beast::insight::Collector service.
Definition: CollectorManager.h:29
std::chrono::seconds
ripple::ShardFamily::missingNode
void missingNode(std::uint32_t seq) override
Definition: ShardFamily.cpp:155
ripple::ShardFamily::missingNode
void missingNode(uint256 const &hash, std::uint32_t seq) override
Definition: ShardFamily.h:95
ripple::ShardFamily::fbCache_
std::unordered_map< std::uint32_t, std::shared_ptr< FullBelowCache > > fbCache_
Definition: ShardFamily.h:106
ripple::ShardFamily::acquire
void acquire(uint256 const &hash, std::uint32_t seq)
Definition: ShardFamily.cpp:185
ripple::base_uint< 256 >
ripple::ShardFamily::journal
beast::Journal const & journal() override
Definition: ShardFamily.h:58
ripple::ShardFamily::ShardFamily
ShardFamily()=delete
ripple::ShardFamily::fbCacheMutex_
std::mutex fbCacheMutex_
Definition: ShardFamily.h:107
ripple::ShardFamily::getFullBelowCache
std::shared_ptr< FullBelowCache > getFullBelowCache(std::uint32_t ledgerSeq) override
Return a pointer to the Family Full Below Cache.
Definition: ShardFamily.cpp:47
ripple::ShardFamily::reset
void reset() override
Definition: ShardFamily.cpp:138
ripple::ShardFamily
Definition: ShardFamily.h:30
ripple::Family
Definition: Family.h:32
ripple::ShardFamily::db
NodeStore::Database const & db() const override
Definition: ShardFamily.h:52
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
ripple::ShardFamily::tnCache_
std::unordered_map< std::uint32_t, std::shared_ptr< TreeNodeCache > > tnCache_
Definition: ShardFamily.h:109
ripple::ShardFamily::getFullBelowCacheSize
int getFullBelowCacheSize()
Return the number of entries in the cache.
Definition: ShardFamily.cpp:66
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::ShardFamily::getTreeNodeCacheSize
std::pair< int, int > getTreeNodeCacheSize()
Return a pair where the first item is the number of items cached and the second item is the number of...
Definition: ShardFamily.cpp:94
ripple::ShardFamily::tnTargetAge_
const std::chrono::seconds tnTargetAge_
Definition: ShardFamily.h:112
ripple::ShardFamily::tnTargetSize_
const int tnTargetSize_
Definition: ShardFamily.h:111
ripple::ShardFamily::db
NodeStore::Database & db() override
Definition: ShardFamily.h:46
ripple::ShardFamily::maxSeq_
LedgerIndex maxSeq_
Definition: ShardFamily.h:115
ripple::ShardFamily::tnCacheMutex_
std::mutex tnCacheMutex_
Definition: ShardFamily.h:110
ripple::ShardFamily::sweep
void sweep() override
Definition: ShardFamily.cpp:108
ripple::ShardFamily::operator=
ShardFamily & operator=(ShardFamily const &)=delete
ripple::ShardFamily::isShardBacked
bool isShardBacked() const override
Definition: ShardFamily.h:64
std::mutex
STL class.
ripple::ShardFamily::j_
const beast::Journal j_
Definition: ShardFamily.h:104
std::unordered_map
STL class.