rippled
SHAMap.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_SHAMAP_H_INCLUDED
21 #define RIPPLE_SHAMAP_SHAMAP_H_INCLUDED
22 
23 #include <ripple/basics/UnorderedContainers.h>
24 #include <ripple/beast/utility/Journal.h>
25 #include <ripple/nodestore/Database.h>
26 #include <ripple/nodestore/NodeObject.h>
27 #include <ripple/shamap/Family.h>
28 #include <ripple/shamap/FullBelowCache.h>
29 #include <ripple/shamap/SHAMapAddNode.h>
30 #include <ripple/shamap/SHAMapInnerNode.h>
31 #include <ripple/shamap/SHAMapItem.h>
32 #include <ripple/shamap/SHAMapLeafNode.h>
33 #include <ripple/shamap/SHAMapMissingNode.h>
34 #include <ripple/shamap/SHAMapTreeNode.h>
35 #include <ripple/shamap/TreeNodeCache.h>
36 #include <cassert>
37 #include <stack>
38 #include <vector>
39 
40 namespace ripple {
41 
42 class SHAMapNodeID;
43 class SHAMapSyncFilter;
44 
46 enum class SHAMapState {
51  Modifying = 0,
52 
57  Immutable = 1,
58 
63  Synching = 2,
64 
69  Invalid = 3,
70 };
71 
95 class SHAMap
96 {
97 private:
100 
103 
106 
110  bool backed_ = true; // Map is backed by the database
111  mutable bool full_ = false; // Map is believed complete in database
112 
113 public:
115  static inline constexpr unsigned int branchFactor = 16;
116 
118  static inline constexpr unsigned int leafDepth = 64;
119 
120  using DeltaItem = std::pair<
124 
125  SHAMap(SHAMap const&) = delete;
126  SHAMap&
127  operator=(SHAMap const&) = delete;
128 
129  // build new map
130  SHAMap(SHAMapType t, Family& f);
131 
132  SHAMap(SHAMapType t, uint256 const& hash, Family& f);
133 
134  ~SHAMap() = default;
135 
136  Family const&
137  family() const
138  {
139  return f_;
140  }
141 
142  Family&
144  {
145  return f_;
146  }
147 
148  //--------------------------------------------------------------------------
149 
154  class const_iterator;
155 
157  begin() const;
159  end() const;
160 
161  //--------------------------------------------------------------------------
162 
163  // Returns a new map that's a snapshot of this one.
164  // Handles copy on write for mutable snapshots.
166  snapShot(bool isMutable) const;
167 
168  /* Mark this SHAMap as "should be full", indicating
169  that the local server wants all the corresponding nodes
170  in durable storage.
171  */
172  void
173  setFull();
174 
175  void
177 
178  bool
179  fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
180 
181  // normal hash access functions
182 
184  bool
185  hasItem(uint256 const& id) const;
186 
187  bool
188  delItem(uint256 const& id);
189 
190  bool
191  addItem(SHAMapNodeType type, SHAMapItem&& i);
192 
193  SHAMapHash
194  getHash() const;
195 
196  // save a copy if you have a temporary anyway
197  bool
199 
200  bool
202 
203  // Save a copy if you need to extend the life
204  // of the SHAMapItem beyond this SHAMap
206  peekItem(uint256 const& id) const;
208  peekItem(uint256 const& id, SHAMapHash& hash) const;
209 
210  // traverse functions
212  upper_bound(uint256 const& id) const;
213 
219  void
220  visitNodes(std::function<bool(SHAMapTreeNode&)> const& function) const;
221 
228  void
230  SHAMap const* have,
231  std::function<bool(SHAMapTreeNode const&)>) const;
232 
237  void
238  visitLeaves(
240  const;
241 
242  // comparison/sync functions
243 
255  getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
256 
257  bool
258  getNodeFat(
259  SHAMapNodeID const& wanted,
260  std::vector<SHAMapNodeID>& nodeIDs,
261  std::vector<Blob>& rawNodes,
262  bool fatLeaves,
263  std::uint32_t depth) const;
264 
266  void
267  serializeRoot(Serializer& s) const;
268 
270  addRootNode(
271  SHAMapHash const& hash,
272  Slice const& rootNode,
273  SHAMapSyncFilter* filter);
275  addKnownNode(
276  SHAMapNodeID const& nodeID,
277  Slice const& rawNode,
278  SHAMapSyncFilter* filter);
279 
280  // status functions
281  void
282  setImmutable();
283  bool
284  isSynching() const;
285  void
286  setSynching();
287  void
288  clearSynching();
289  bool
290  isValid() const;
291 
292  // caution: otherMap must be accessed only by this function
293  // return value: true=successfully completed, false=too different
294  bool
295  compare(SHAMap const& otherMap, Delta& differences, int maxCount) const;
296 
298  int
299  unshare();
300 
302  int
304 
305  void
306  walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
307  bool
308  deepCompare(SHAMap& other) const; // Intended for debug/test only
309 
310  void
311  setUnbacked();
312 
313  void
314  dump(bool withHashes = false) const;
315  void
316  invariants() const;
317 
318 private:
319  using SharedPtrNodeStack =
321  using DeltaRef = std::pair<
324 
325  // tree node cache operations
327  cacheLookup(SHAMapHash const& hash) const;
328  void
330  const;
331 
332  // database operations
334  fetchNodeFromDB(SHAMapHash const& hash) const;
336  fetchNodeNT(SHAMapHash const& hash) const;
338  fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
340  fetchNode(SHAMapHash const& hash) const;
342  checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
343 
345  void
346  dirtyUp(
347  SharedPtrNodeStack& stack,
348  uint256 const& target,
350 
355  walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr)
356  const;
359  findKey(uint256 const& id) const;
360 
362  template <class Node>
365 
367  template <class Node>
370 
374 
376  firstBelow(
378  SharedPtrNodeStack& stack,
379  int branch = 0) const;
380 
381  // Simple descent
382  // Get a child of the specified node
384  descend(SHAMapInnerNode*, int branch) const;
386  descendThrow(SHAMapInnerNode*, int branch) const;
388  descend(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
390  descendThrow(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
391 
392  // Descend with filter
394  descendAsync(
395  SHAMapInnerNode* parent,
396  int branch,
397  SHAMapSyncFilter* filter,
398  bool& pending) const;
399 
401  descend(
402  SHAMapInnerNode* parent,
403  SHAMapNodeID const& parentID,
404  int branch,
405  SHAMapSyncFilter* filter) const;
406 
407  // Non-storing
408  // Does not hook the returned node to its parent
410  descendNoStore(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
411 
414  onlyBelow(SHAMapTreeNode*) const;
415 
416  bool
417  hasInnerNode(SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
418  bool
419  hasLeafNode(uint256 const& tag, SHAMapHash const& hash) const;
420 
421  SHAMapLeafNode const*
422  peekFirstItem(SharedPtrNodeStack& stack) const;
423  SHAMapLeafNode const*
424  peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
425  bool
426  walkBranch(
427  SHAMapTreeNode* node,
428  std::shared_ptr<SHAMapItem const> const& otherMapItem,
429  bool isFirstMap,
430  Delta& differences,
431  int& maxCount) const;
432  int
433  walkSubTree(bool doWrite, NodeObjectType t);
434 
435  // Structure to track information about call to
436  // getMissingNodes while it's in progress
438  {
439  MissingNodes() = delete;
440  MissingNodes(const MissingNodes&) = delete;
441  MissingNodes&
442  operator=(const MissingNodes&) = delete;
443 
444  // basic parameters
445  int max_;
447  int const maxDefer_;
449 
450  // nodes we have discovered to be missing
453 
454  // nodes we are in the process of traversing
455  using StackEntry = std::tuple<
456  SHAMapInnerNode*, // pointer to the node
457  SHAMapNodeID, // the node's ID
458  int, // while child we check first
459  int, // which child we check next
460  bool>; // whether we've found any missing children yet
461 
462  // We explicitly choose to specify the use of std::deque here, because
463  // we need to ensure that pointers and/or references to existing
464  // elements will not be invalidated during the course of element
465  // insertion and removal. Containers that do not offer this guarantee,
466  // such as std::vector, can't be used here.
468 
469  // nodes we may acquire from deferred reads
472 
473  // nodes we need to resume after we get their children from deferred
474  // reads
476 
478  int max,
479  SHAMapSyncFilter* filter,
480  int maxDefer,
481  std::uint32_t generation)
482  : max_(max)
483  , filter_(filter)
484  , maxDefer_(maxDefer)
485  , generation_(generation)
486  {
487  missingNodes_.reserve(max);
488  deferredReads_.reserve(maxDefer);
489  }
490  };
491 
492  // getMissingNodes helper functions
493  void
494  gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node);
495  void
496  gmn_ProcessDeferredReads(MissingNodes&);
497 };
498 
499 inline void
501 {
502  full_ = true;
503 }
504 
505 inline void
507 {
508  ledgerSeq_ = lseq;
509 }
510 
511 inline void
513 {
514  assert(state_ != SHAMapState::Invalid);
516 }
517 
518 inline bool
520 {
521  return state_ == SHAMapState::Synching;
522 }
523 
524 inline void
526 {
528 }
529 
530 inline void
532 {
534 }
535 
536 inline bool
538 {
539  return state_ != SHAMapState::Invalid;
540 }
541 
542 inline void
544 {
545  backed_ = false;
546 }
547 
548 //------------------------------------------------------------------------------
549 
551 {
552 public:
556  using reference = value_type const&;
557  using pointer = value_type const*;
558 
559 private:
561  SHAMap const* map_ = nullptr;
562  pointer item_ = nullptr;
563 
564 public:
565  const_iterator() = default;
566 
567  reference
568  operator*() const;
569  pointer
570  operator->() const;
571 
573  operator++();
575  operator++(int);
576 
577 private:
578  explicit const_iterator(SHAMap const* map);
579  const_iterator(SHAMap const* map, pointer item);
580  const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
581 
582  friend bool
583  operator==(const_iterator const& x, const_iterator const& y);
584  friend class SHAMap;
585 };
586 
588  : map_(map), item_(nullptr)
589 {
590  auto temp = map_->peekFirstItem(stack_);
591  if (temp)
592  item_ = temp->peekItem().get();
593 }
594 
596  : map_(map), item_(item)
597 {
598 }
599 
601  SHAMap const* map,
602  pointer item,
603  SharedPtrNodeStack&& stack)
604  : stack_(std::move(stack)), map_(map), item_(item)
605 {
606 }
607 
610 {
611  return *item_;
612 }
613 
616 {
617  return item_;
618 }
619 
622 {
623  auto temp = map_->peekNextItem(item_->key(), stack_);
624  if (temp)
625  item_ = temp->peekItem().get();
626  else
627  item_ = nullptr;
628  return *this;
629 }
630 
633 {
634  auto tmp = *this;
635  ++(*this);
636  return tmp;
637 }
638 
639 inline bool
641 {
642  assert(x.map_ == y.map_);
643  return x.item_ == y.item_;
644 }
645 
646 inline bool
648 {
649  return !(x == y);
650 }
651 
652 inline SHAMap::const_iterator
654 {
655  return const_iterator(this);
656 }
657 
659 SHAMap::end() const
660 {
661  return const_iterator(this, nullptr);
662 }
663 
664 } // namespace ripple
665 
666 #endif
ripple::SHAMap::MissingNodes
Definition: SHAMap.h:437
ripple::SHAMapAddNode
Definition: SHAMapAddNode.h:28
ripple::SHAMap::visitDifferences
void visitDifferences(SHAMap const *have, std::function< bool(SHAMapTreeNode const &)>) const
Visit every node in this SHAMap that is not present in the specified SHAMap.
Definition: SHAMapSync.cpp:101
ripple::SHAMap::invariants
void invariants() const
Definition: SHAMap.cpp:1114
ripple::SHAMap::clearSynching
void clearSynching()
Definition: SHAMap.h:531
ripple::SHAMap::isValid
bool isValid() const
Definition: SHAMap.h:537
ripple::SHAMap::branchFactor
static constexpr unsigned int branchFactor
Each non-leaf node has 16 children (the 'radix tree' part of the map)
Definition: SHAMap.h:115
ripple::SHAMap::descendNoStore
std::shared_ptr< SHAMapTreeNode > descendNoStore(std::shared_ptr< SHAMapInnerNode > const &, int branch) const
Definition: SHAMap.cpp:333
ripple::SHAMap::SHAMap
SHAMap(SHAMap const &)=delete
ripple::SHAMap::peekNextItem
SHAMapLeafNode const * peekNextItem(uint256 const &id, SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:527
ripple::Dir::const_iterator
Definition: Directory.h:49
std::shared_ptr
STL class.
ripple::SHAMap::getHash
SHAMapHash getHash() const
Definition: SHAMap.cpp:778
ripple::SHAMap::backed_
bool backed_
Definition: SHAMap.h:110
ripple::SHAMap::type_
const SHAMapType type_
Definition: SHAMap.h:109
ripple::SHAMap::deepCompare
bool deepCompare(SHAMap &other) const
Definition: SHAMapSync.cpp:667
ripple::SHAMap::MissingNodes::stack_
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition: SHAMap.h:467
ripple::SHAMap::hasInnerNode
bool hasInnerNode(SHAMapNodeID const &nodeID, SHAMapHash const &hash) const
Does this map have this inner node?
Definition: SHAMapSync.cpp:739
ripple::SHAMap::family
Family const & family() const
Definition: SHAMap.h:137
ripple::SHAMap::fetchNodeFromDB
std::shared_ptr< SHAMapTreeNode > fetchNodeFromDB(SHAMapHash const &hash) const
Definition: SHAMap.cpp:163
ripple::SHAMap::addItem
bool addItem(SHAMapNodeType type, SHAMapItem &&i)
Definition: SHAMap.cpp:772
ripple::Slice
An immutable linear range of bytes.
Definition: Slice.h:44
std::pair
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes(int max, SHAMapSyncFilter *filter, int maxDefer, std::uint32_t generation)
Definition: SHAMap.h:477
ripple::SHAMap::walkSubTree
int walkSubTree(bool doWrite, NodeObjectType t)
Definition: SHAMap.cpp:925
ripple::SHAMap::dump
void dump(bool withHashes=false) const
Definition: SHAMap.cpp:1050
ripple::SHAMap::const_iterator::stack_
SharedPtrNodeStack stack_
Definition: SHAMap.h:560
vector
ripple::NodeObjectType
NodeObjectType
The types of node objects.
Definition: NodeObject.h:32
ripple::SHAMap::onlyBelow
std::shared_ptr< SHAMapItem const > const & onlyBelow(SHAMapTreeNode *) const
If there is only one leaf below this node, get its contents.
Definition: SHAMap.cpp:477
ripple::SHAMapNodeType
SHAMapNodeType
Definition: SHAMapTreeNode.h:126
ripple::SHAMap::MissingNodes::maxDefer_
const int maxDefer_
Definition: SHAMap.h:447
ripple::SHAMap::MissingNodes::generation_
std::uint32_t generation_
Definition: SHAMap.h:448
stack
ripple::SHAMap::peekItem
std::shared_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
Definition: SHAMap.cpp:556
ripple::SHAMap::serializeRoot
void serializeRoot(Serializer &s) const
Serializes the root in a format appropriate for sending over the wire.
Definition: SHAMapSync.cpp:523
ripple::SHAMap::fetchNode
std::shared_ptr< SHAMapTreeNode > fetchNode(SHAMapHash const &hash) const
Definition: SHAMap.cpp:265
std::forward_iterator_tag
ripple::SHAMap::fetchNodeNT
std::shared_ptr< SHAMapTreeNode > fetchNodeNT(SHAMapHash const &hash) const
Definition: SHAMap.cpp:253
ripple::SHAMap::Delta
std::map< uint256, DeltaItem > Delta
Definition: SHAMap.h:123
std::tuple
ripple::SHAMapState::Modifying
@ Modifying
The map is in flux and objects can be added and removed.
ripple::SHAMap::begin
const_iterator begin() const
Definition: SHAMap.h:653
std::function
ripple::SHAMapNodeID
Identifies a node inside a SHAMap.
Definition: SHAMapNodeID.h:33
ripple::SHAMap::MissingNodes::filter_
SHAMapSyncFilter * filter_
Definition: SHAMap.h:446
ripple::SHAMap::snapShot
std::shared_ptr< SHAMap > snapShot(bool isMutable) const
Definition: SHAMap.cpp:70
ripple::Dir::const_iterator::pointer
value_type const * pointer
Definition: Directory.h:53
ripple::SHAMap::gmn_ProcessNodes
void gmn_ProcessNodes(MissingNodes &, MissingNodes::StackEntry &node)
Definition: SHAMapSync.cpp:173
ripple::const_iterator
Dir::const_iterator const_iterator
Definition: Directory.cpp:25
ripple::SHAMap::cacheLookup
std::shared_ptr< SHAMapTreeNode > cacheLookup(SHAMapHash const &hash) const
Definition: SHAMap.cpp:1093
ripple::SHAMap::const_iterator::operator->
pointer operator->() const
Definition: SHAMap.h:615
ripple::SHAMapLeafNode
Definition: SHAMapLeafNode.h:32
ripple::SHAMap::setFull
void setFull()
Definition: SHAMap.h:500
ripple::SHAMapHash
Definition: SHAMapTreeNode.h:47
ripple::SHAMapState::Synching
@ Synching
The map's hash is fixed but valid nodes may be missing and can be added.
ripple::operator==
bool operator==(Manifest const &lhs, Manifest const &rhs)
Definition: Manifest.h:155
ripple::SHAMap::f_
Family & f_
Definition: SHAMap.h:98
ripple::SHAMap::descendAsync
SHAMapTreeNode * descendAsync(SHAMapInnerNode *parent, int branch, SHAMapSyncFilter *filter, bool &pending) const
Definition: SHAMap.cpp:373
ripple::base_uint< 256 >
ripple::SHAMap::MissingNodes::resumes_
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition: SHAMap.h:475
ripple::SHAMap::hasItem
bool hasItem(uint256 const &id) const
Does the tree have an item with the given ID?
Definition: SHAMap.cpp:619
ripple::SHAMap::const_iterator::operator==
friend bool operator==(const_iterator const &x, const_iterator const &y)
Definition: SHAMap.h:640
ripple::SHAMap::MissingNodes::deferredReads_
std::vector< std::tuple< SHAMapInnerNode *, SHAMapNodeID, int > > deferredReads_
Definition: SHAMap.h:471
ripple::SHAMap::hasLeafNode
bool hasLeafNode(uint256 const &tag, SHAMapHash const &hash) const
Does this map have this leaf node?
Definition: SHAMapSync.cpp:763
ripple::SHAMap::operator=
SHAMap & operator=(SHAMap const &)=delete
ripple::SHAMapInnerNode
Definition: SHAMapInnerNode.h:38
ripple::SHAMap::peekFirstItem
SHAMapLeafNode const * peekFirstItem(SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:513
ripple::SHAMap::MissingNodes::max_
int max_
Definition: SHAMap.h:445
ripple::SHAMap::visitLeaves
void visitLeaves(std::function< void(std::shared_ptr< SHAMapItem const > const &)> const &) const
Visit every leaf node in this SHAMap.
Definition: SHAMapSync.cpp:27
ripple::SHAMapItem
Definition: SHAMapItem.h:35
ripple::SHAMap::isSynching
bool isSynching() const
Definition: SHAMap.h:519
ripple::SHAMap::const_iterator
Definition: SHAMap.h:550
ripple::SHAMap::firstBelow
SHAMapLeafNode * firstBelow(std::shared_ptr< SHAMapTreeNode >, SharedPtrNodeStack &stack, int branch=0) const
Definition: SHAMap.cpp:435
ripple::SHAMap
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition: SHAMap.h:95
ripple::SHAMap::const_iterator::operator++
const_iterator & operator++()
Definition: SHAMap.h:621
ripple::operator!=
bool operator!=(Manifest const &lhs, Manifest const &rhs)
Definition: Manifest.h:165
ripple::SHAMap::MissingNodes::StackEntry
std::tuple< SHAMapInnerNode *, SHAMapNodeID, int, int, bool > StackEntry
Definition: SHAMap.h:460
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:133
ripple::SHAMap::descendThrow
SHAMapTreeNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:276
ripple::SHAMap::~SHAMap
~SHAMap()=default
ripple::SHAMap::journal_
beast::Journal journal_
Definition: SHAMap.h:99
ripple::SHAMap::canonicalize
void canonicalize(SHAMapHash const &hash, std::shared_ptr< SHAMapTreeNode > &) const
Definition: SHAMap.cpp:1101
ripple::SHAMap::MissingNodes::missingHashes_
std::set< SHAMapHash > missingHashes_
Definition: SHAMap.h:452
ripple::Family
Definition: Family.h:32
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::SHAMap::const_iterator::item_
pointer item_
Definition: SHAMap.h:562
std::uint32_t
std::map
STL class.
ripple::SHAMap::setLedgerSeq
void setLedgerSeq(std::uint32_t lseq)
Definition: SHAMap.h:506
ripple::SHAMap::getMissingNodes
std::vector< std::pair< SHAMapNodeID, uint256 > > getMissingNodes(int maxNodes, SHAMapSyncFilter *filter)
Check for nodes in the SHAMap not available.
Definition: SHAMapSync.cpp:315
ripple::SHAMap::const_iterator::map_
SHAMap const * map_
Definition: SHAMap.h:561
ripple::SHAMap::fetchRoot
bool fetchRoot(SHAMapHash const &hash, SHAMapSyncFilter *filter)
Definition: SHAMap.cpp:830
ripple::SHAMap::walkMap
void walkMap(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
Definition: SHAMapDelta.cpp:249
ripple::Serializer
Definition: Serializer.h:39
ripple::SHAMap::upper_bound
const_iterator upper_bound(uint256 const &id) const
Definition: SHAMap.cpp:579
ripple::SHAMap::const_iterator::operator*
reference operator*() const
Definition: SHAMap.h:609
ripple::SHAMap::setImmutable
void setImmutable()
Definition: SHAMap.h:512
ripple::SHAMap::const_iterator::const_iterator
const_iterator()=default
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::SHAMap::full_
bool full_
Definition: SHAMap.h:111
ripple::SHAMap::checkFilter
std::shared_ptr< SHAMapTreeNode > checkFilter(SHAMapHash const &hash, SHAMapSyncFilter *filter) const
Definition: SHAMap.cpp:197
ripple::SHAMap::dirtyUp
void dirtyUp(SharedPtrNodeStack &stack, uint256 const &target, std::shared_ptr< SHAMapTreeNode > terminal)
Update hashes up to the root.
Definition: SHAMap.cpp:94
ripple::SHAMap::setUnbacked
void setUnbacked()
Definition: SHAMap.h:543
ripple::SHAMap::findKey
SHAMapLeafNode * findKey(uint256 const &id) const
Return nullptr if key not found.
Definition: SHAMap.cpp:154
ripple::SHAMap::updateGiveItem
bool updateGiveItem(SHAMapNodeType type, std::shared_ptr< SHAMapItem const >)
Definition: SHAMap.cpp:790
ripple::SHAMap::end
const_iterator end() const
Definition: SHAMap.h:659
ripple::SHAMap::walkTowardsKey
SHAMapLeafNode * walkTowardsKey(uint256 const &id, SharedPtrNodeStack *stack=nullptr) const
Walk towards the specified id, returning the node.
Definition: SHAMap.cpp:128
std
STL namespace.
cassert
ripple::SHAMap::addGiveItem
bool addGiveItem(SHAMapNodeType type, std::shared_ptr< SHAMapItem const > item)
Definition: SHAMap.cpp:703
ripple::SHAMap::unshare
int unshare()
Convert any modified nodes to shared.
Definition: SHAMap.cpp:911
ripple::SHAMap::writeNode
std::shared_ptr< SHAMapTreeNode > writeNode(NodeObjectType t, std::shared_ptr< SHAMapTreeNode > node) const
write and canonicalize modified node
Definition: SHAMap.cpp:876
ripple::SHAMap::leafDepth
static constexpr unsigned int leafDepth
The depth of the hash map: data is only present in the leaves.
Definition: SHAMap.h:118
ripple::SHAMap::SharedPtrNodeStack
std::stack< std::pair< std::shared_ptr< SHAMapTreeNode >, SHAMapNodeID > > SharedPtrNodeStack
Definition: SHAMap.h:320
std::ptrdiff_t
ripple::SHAMapState::Immutable
@ Immutable
The map is set in stone and cannot be changed.
ripple::SHAMap::compare
bool compare(SHAMap const &otherMap, Delta &differences, int maxCount) const
Definition: SHAMapDelta.cpp:124
ripple::SHAMapType
SHAMapType
Definition: SHAMapMissingNode.h:32
ripple::SHAMap::visitNodes
void visitNodes(std::function< bool(SHAMapTreeNode &)> const &function) const
Visit every node in this SHAMap.
Definition: SHAMapSync.cpp:39
ripple::SHAMap::gmn_ProcessDeferredReads
void gmn_ProcessDeferredReads(MissingNodes &)
Definition: SHAMapSync.cpp:254
ripple::SHAMapState::Invalid
@ Invalid
The map is known to not be valid.
ripple::SHAMap::const_iterator::pointer
value_type const * pointer
Definition: SHAMap.h:557
ripple::SHAMap::preFlushNode
std::shared_ptr< Node > preFlushNode(std::shared_ptr< Node > node) const
prepare a node to be modified before flushing
Definition: SHAMap.cpp:895
ripple::SHAMap::addKnownNode
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:571
ripple::SHAMap::flushDirty
int flushDirty(NodeObjectType t)
Flush modified nodes to the nodestore and convert them to shared.
Definition: SHAMap.cpp:918
ripple::SHAMap::unshareNode
std::shared_ptr< Node > unshareNode(std::shared_ptr< Node >, SHAMapNodeID const &nodeID)
Unshare the node, allowing it to be modified.
Definition: SHAMap.cpp:419
ripple::SHAMap::descend
SHAMapTreeNode * descend(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:299
ripple::SHAMap::MissingNodes::operator=
MissingNodes & operator=(const MissingNodes &)=delete
ripple::SHAMap::addRootNode
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:529
ripple::SHAMap::walkBranch
bool walkBranch(SHAMapTreeNode *node, std::shared_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const
Definition: SHAMapDelta.cpp:34
ripple::Dir::const_iterator::reference
value_type const & reference
Definition: Directory.h:54
ripple::SHAMap::ledgerSeq_
std::uint32_t ledgerSeq_
The sequence of the ledger that this map references, if any.
Definition: SHAMap.h:105
ripple::SHAMap::getNodeFat
bool getNodeFat(SHAMapNodeID const &wanted, std::vector< SHAMapNodeID > &nodeIDs, std::vector< Blob > &rawNodes, bool fatLeaves, std::uint32_t depth) const
Definition: SHAMapSync.cpp:426
ripple::SHAMapSyncFilter
Definition: SHAMapSyncFilter.h:30
ripple::SHAMap::MissingNodes::missingNodes_
std::vector< std::pair< SHAMapNodeID, uint256 > > missingNodes_
Definition: SHAMap.h:451
ripple::SHAMap::delItem
bool delItem(uint256 const &id)
Definition: SHAMap.cpp:625
ripple::SHAMap::cowid_
std::uint32_t cowid_
ID to distinguish this map for all others we're sharing nodes with.
Definition: SHAMap.h:102
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes()=delete
ripple::SHAMap::state_
SHAMapState state_
Definition: SHAMap.h:108
std::set
STL class.
ripple::SHAMap::setSynching
void setSynching()
Definition: SHAMap.h:525
ripple::SHAMap::root_
std::shared_ptr< SHAMapTreeNode > root_
Definition: SHAMap.h:107
ripple::SHAMapState
SHAMapState
Describes the current state of a given SHAMap.
Definition: SHAMap.h:46
ripple::SHAMap::family
Family & family()
Definition: SHAMap.h:143
ripple::SHAMap::const_iterator::reference
value_type const & reference
Definition: SHAMap.h:556