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  missingNodeAcquireBySeq(std::uint32_t seq, uint256 const& nodeHash)
93  override;
94 
95  void
96  missingNodeAcquireByHash(uint256 const& hash, std::uint32_t seq) override
97  {
98  acquire(hash, seq);
99  }
100 
101 private:
106 
109 
112  int const tnTargetSize_;
114 
115  // Missing node handler
118 
119  void
120  acquire(uint256 const& hash, std::uint32_t seq);
121 };
122 
123 } // namespace ripple
124 
125 #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:77
ripple::ShardFamily::maxSeqMutex_
std::mutex maxSeqMutex_
Definition: ShardFamily.h:117
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:51
std::shared_ptr
STL class.
ripple::ShardFamily::cm_
CollectorManager & cm_
Definition: ShardFamily.h:104
std::pair
ripple::ShardFamily::app_
Application & app_
Definition: ShardFamily.h:102
ripple::ShardFamily::db_
NodeStore::Database & db_
Definition: ShardFamily.h:103
ripple::CollectorManager
Provides the beast::insight::Collector service.
Definition: CollectorManager.h:29
std::chrono::seconds
ripple::ShardFamily::fbCache_
std::unordered_map< std::uint32_t, std::shared_ptr< FullBelowCache > > fbCache_
Definition: ShardFamily.h:107
ripple::ShardFamily::acquire
void acquire(uint256 const &hash, std::uint32_t seq)
Definition: ShardFamily.cpp:187
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:108
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:48
ripple::ShardFamily::reset
void reset() override
Definition: ShardFamily.cpp:139
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:110
ripple::ShardFamily::getFullBelowCacheSize
int getFullBelowCacheSize()
Return the number of entries in the cache.
Definition: ShardFamily.cpp:67
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:95
ripple::ShardFamily::tnTargetAge_
const std::chrono::seconds tnTargetAge_
Definition: ShardFamily.h:113
ripple::ShardFamily::tnTargetSize_
const int tnTargetSize_
Definition: ShardFamily.h:112
ripple::ShardFamily::db
NodeStore::Database & db() override
Definition: ShardFamily.h:46
ripple::ShardFamily::maxSeq_
LedgerIndex maxSeq_
Definition: ShardFamily.h:116
ripple::ShardFamily::missingNodeAcquireByHash
void missingNodeAcquireByHash(uint256 const &hash, std::uint32_t seq) override
Acquire ledger that has a missing node by ledger hash.
Definition: ShardFamily.h:96
ripple::ShardFamily::tnCacheMutex_
std::mutex tnCacheMutex_
Definition: ShardFamily.h:111
ripple::ShardFamily::sweep
void sweep() override
Definition: ShardFamily.cpp:109
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:105
ripple::ShardFamily::missingNodeAcquireBySeq
void missingNodeAcquireBySeq(std::uint32_t seq, uint256 const &nodeHash) override
Acquire ledger that has a missing node by ledger sequence.
Definition: ShardFamily.cpp:156
std::unordered_map
STL class.