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/SHAMapItem.h>
31 #include <ripple/shamap/SHAMapMissingNode.h>
32 #include <ripple/shamap/SHAMapNodeID.h>
33 #include <ripple/shamap/SHAMapSyncFilter.h>
34 #include <ripple/shamap/SHAMapTreeNode.h>
35 #include <ripple/shamap/TreeNodeCache.h>
36 #include <boost/thread/mutex.hpp>
37 #include <boost/thread/shared_lock_guard.hpp>
38 #include <boost/thread/shared_mutex.hpp>
39 #include <cassert>
40 #include <stack>
41 #include <vector>
42 
43 namespace ripple {
44 
45 enum class SHAMapState {
46  Modifying = 0, // Objects can be added and removed (like an open ledger)
47  Immutable = 1, // Map cannot be changed (like a closed ledger)
48  Synching = 2, // Map's hash is locked in, valid nodes can be added (like a
49  // peer's closing ledger)
50  Floating = 3, // Map is free to change hash (like a synching open ledger)
51  Invalid =
52  4, // Map is known not to be valid (usually synching a corrupt ledger)
53 };
54 
57 
81 class SHAMap
82 {
83 private:
87  std::uint32_t ledgerSeq_ = 0; // sequence number of ledger this is part of
91  bool backed_ = true; // Map is backed by the database
92  bool full_ = false; // Map is believed complete in database
93 
94 public:
95  using DeltaItem = std::pair<
99 
100  ~SHAMap();
101  SHAMap(SHAMap const&) = delete;
102  SHAMap&
103  operator=(SHAMap const&) = delete;
104 
105  // build new map
106  SHAMap(SHAMapType t, Family& f);
107 
108  SHAMap(SHAMapType t, uint256 const& hash, Family& f);
109 
110  Family const&
111  family() const
112  {
113  return f_;
114  }
115 
116  Family&
118  {
119  return f_;
120  }
121 
122  //--------------------------------------------------------------------------
123 
128  class const_iterator;
129 
131  begin() const;
133  end() const;
134 
135  //--------------------------------------------------------------------------
136 
137  // Returns a new map that's a snapshot of this one.
138  // Handles copy on write for mutable snapshots.
140  snapShot(bool isMutable) const;
141 
142  /* Mark this SHAMap as "should be full", indicating
143  that the local server wants all the corresponding nodes
144  in durable storage.
145  */
146  void
147  setFull();
148 
149  void
151 
152  bool
153  fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
154 
155  // normal hash access functions
156  bool
157  hasItem(uint256 const& id) const;
158  bool
159  delItem(uint256 const& id);
160  bool
161  addItem(SHAMapItem&& i, bool isTransaction, bool hasMeta);
162  SHAMapHash
163  getHash() const;
164 
165  // save a copy if you have a temporary anyway
166  bool
169  bool isTransaction,
170  bool hasMeta);
171  bool
172  addGiveItem(
174  bool isTransaction,
175  bool hasMeta);
176 
177  // Save a copy if you need to extend the life
178  // of the SHAMapItem beyond this SHAMap
180  peekItem(uint256 const& id) const;
182  peekItem(uint256 const& id, SHAMapHash& hash) const;
184  peekItem(uint256 const& id, SHAMapTreeNode::TNType& type) const;
185 
186  // traverse functions
188  upper_bound(uint256 const& id) const;
189 
195  void
196  visitNodes(std::function<bool(SHAMapAbstractNode&)> const& function) const;
197 
204  void
206  SHAMap const* have,
207  std::function<bool(SHAMapAbstractNode&)>) const;
208 
213  void
214  visitLeaves(
216  const;
217 
218  // comparison/sync functions
219 
231  getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
232 
233  bool
234  getNodeFat(
235  SHAMapNodeID node,
236  std::vector<SHAMapNodeID>& nodeIDs,
237  std::vector<Blob>& rawNode,
238  bool fatLeaves,
239  std::uint32_t depth) const;
240 
241  bool
242  getRootNode(Serializer& s, SHANodeFormat format) const;
244  getNeededHashes(int max, SHAMapSyncFilter* filter);
246  addRootNode(
247  SHAMapHash const& hash,
248  Slice const& rootNode,
249  SHAMapSyncFilter* filter);
251  addKnownNode(
252  SHAMapNodeID const& nodeID,
253  Slice const& rawNode,
254  SHAMapSyncFilter* filter);
255 
256  // status functions
257  void
258  setImmutable();
259  bool
260  isSynching() const;
261  void
262  setSynching();
263  void
264  clearSynching();
265  bool
266  isValid() const;
267 
268  // caution: otherMap must be accessed only by this function
269  // return value: true=successfully completed, false=too different
270  bool
271  compare(SHAMap const& otherMap, Delta& differences, int maxCount) const;
272 
273  int
275  void
276  walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
277  bool
278  deepCompare(SHAMap& other) const; // Intended for debug/test only
279 
281 
282  void
283  getFetchPack(
284  SHAMap const* have,
285  bool includeLeaves,
286  int max,
287  std::function<void(SHAMapHash const&, const Blob&)>) const;
288 
289  void
290  setUnbacked();
291  int
292  unshare();
293 
294  void
295  dump(bool withHashes = false) const;
296  void
297  invariants() const;
298 
299 private:
302  using DeltaRef = std::pair<
305 
306  // tree node cache operations
308  getCache(SHAMapHash const& hash) const;
309  void
311  const;
312 
313  // database operations
315  fetchNodeFromDB(SHAMapHash const& hash) const;
317  fetchNodeNT(SHAMapHash const& hash) const;
319  fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
321  fetchNode(SHAMapHash const& hash) const;
323  checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
324 
326  void
327  dirtyUp(
328  SharedPtrNodeStack& stack,
329  uint256 const& target,
331 
336  walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr)
337  const;
340  findKey(uint256 const& id) const;
341 
343  template <class Node>
346 
348  template <class Node>
351 
354  writeNode(
355  NodeObjectType t,
356  std::uint32_t seq,
358 
360  firstBelow(
362  SharedPtrNodeStack& stack,
363  int branch = 0) const;
364 
365  // Simple descent
366  // Get a child of the specified node
368  descend(SHAMapInnerNode*, int branch) const;
370  descendThrow(SHAMapInnerNode*, int branch) const;
372  descend(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
374  descendThrow(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
375 
376  // Descend with filter
378  descendAsync(
379  SHAMapInnerNode* parent,
380  int branch,
381  SHAMapSyncFilter* filter,
382  bool& pending) const;
383 
385  descend(
386  SHAMapInnerNode* parent,
387  SHAMapNodeID const& parentID,
388  int branch,
389  SHAMapSyncFilter* filter) const;
390 
391  // Non-storing
392  // Does not hook the returned node to its parent
394  descendNoStore(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
395 
399 
400  bool
401  hasInnerNode(SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
402  bool
403  hasLeafNode(uint256 const& tag, SHAMapHash const& hash) const;
404 
405  SHAMapTreeNode const*
406  peekFirstItem(SharedPtrNodeStack& stack) const;
407  SHAMapTreeNode const*
408  peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
409  bool
410  walkBranch(
411  SHAMapAbstractNode* node,
412  std::shared_ptr<SHAMapItem const> const& otherMapItem,
413  bool isFirstMap,
414  Delta& differences,
415  int& maxCount) const;
416  int
417  walkSubTree(bool doWrite, NodeObjectType t, std::uint32_t seq);
418 
419  // Structure to track information about call to
420  // getMissingNodes while it's in progress
422  {
423  MissingNodes() = delete;
424  MissingNodes(const MissingNodes&) = delete;
425  MissingNodes&
426  operator=(const MissingNodes&) = delete;
427 
428  // basic parameters
429  int max_;
431  int const maxDefer_;
433 
434  // nodes we have discovered to be missing
437 
438  // nodes we are in the process of traversing
439  using StackEntry = std::tuple<
440  SHAMapInnerNode*, // pointer to the node
441  SHAMapNodeID, // the node's ID
442  int, // while child we check first
443  int, // which child we check next
444  bool>; // whether we've found any missing children yet
445 
446  // We explicitly choose to specify the use of std::deque here, because
447  // we need to ensure that pointers and/or references to existing
448  // elements will not be invalidated during the course of element
449  // insertion and removal. Containers that do not offer this guarantee,
450  // such as std::vector, can't be used here.
452 
453  // nodes we may acquire from deferred reads
456 
457  // nodes we need to resume after we get their children from deferred
458  // reads
460 
462  int max,
463  SHAMapSyncFilter* filter,
464  int maxDefer,
465  std::uint32_t generation)
466  : max_(max)
467  , filter_(filter)
468  , maxDefer_(maxDefer)
469  , generation_(generation)
470  {
471  missingNodes_.reserve(max);
472  deferredReads_.reserve(maxDefer);
473  }
474  };
475 
476  // getMissingNodes helper functions
477  void
478  gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node);
479  void
480  gmn_ProcessDeferredReads(MissingNodes&);
481 };
482 
483 inline void
485 {
486  full_ = true;
487 }
488 
489 inline void
491 {
492  ledgerSeq_ = lseq;
493 }
494 
495 inline void
497 {
498  assert(state_ != SHAMapState::Invalid);
500 }
501 
502 inline bool
504 {
505  return (state_ == SHAMapState::Floating) ||
507 }
508 
509 inline void
511 {
513 }
514 
515 inline void
517 {
519 }
520 
521 inline bool
523 {
524  return state_ != SHAMapState::Invalid;
525 }
526 
527 inline void
529 {
530  backed_ = false;
531 }
532 
533 //------------------------------------------------------------------------------
534 
536 {
537 public:
541  using reference = value_type const&;
542  using pointer = value_type const*;
543 
544 private:
546  SHAMap const* map_ = nullptr;
547  pointer item_ = nullptr;
548 
549 public:
550  const_iterator() = default;
551 
552  reference
553  operator*() const;
554  pointer
555  operator->() const;
556 
558  operator++();
560  operator++(int);
561 
562 private:
563  explicit const_iterator(SHAMap const* map);
564  const_iterator(SHAMap const* map, pointer item);
565  const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
566 
567  friend bool
568  operator==(const_iterator const& x, const_iterator const& y);
569  friend class SHAMap;
570 };
571 
573  : map_(map), item_(nullptr)
574 {
575  auto temp = map_->peekFirstItem(stack_);
576  if (temp)
577  item_ = temp->peekItem().get();
578 }
579 
581  : map_(map), item_(item)
582 {
583 }
584 
586  SHAMap const* map,
587  pointer item,
588  SharedPtrNodeStack&& stack)
589  : stack_(std::move(stack)), map_(map), item_(item)
590 {
591 }
592 
595 {
596  return *item_;
597 }
598 
601 {
602  return item_;
603 }
604 
607 {
608  auto temp = map_->peekNextItem(item_->key(), stack_);
609  if (temp)
610  item_ = temp->peekItem().get();
611  else
612  item_ = nullptr;
613  return *this;
614 }
615 
618 {
619  auto tmp = *this;
620  ++(*this);
621  return tmp;
622 }
623 
624 inline bool
626 {
627  assert(x.map_ == y.map_);
628  return x.item_ == y.item_;
629 }
630 
631 inline bool
633 {
634  return !(x == y);
635 }
636 
637 inline SHAMap::const_iterator
639 {
640  return const_iterator(this);
641 }
642 
644 SHAMap::end() const
645 {
646  return const_iterator(this, nullptr);
647 }
648 
649 } // namespace ripple
650 
651 #endif
ripple::SHAMap::MissingNodes
Definition: SHAMap.h:421
ripple::SHAMapAddNode
Definition: SHAMapAddNode.h:28
ripple::SHAMap::invariants
void invariants() const
Definition: SHAMap.cpp:1135
ripple::SHAMap::clearSynching
void clearSynching()
Definition: SHAMap.h:516
ripple::SHAMap::isValid
bool isValid() const
Definition: SHAMap.h:522
ripple::SHAMap::SHAMap
SHAMap(SHAMap const &)=delete
ripple::Dir::const_iterator
Definition: Directory.h:49
std::shared_ptr
STL class.
ripple::SHAMap::getHash
SHAMapHash getHash() const
Definition: SHAMap.cpp:791
ripple::SHAMap::backed_
bool backed_
Definition: SHAMap.h:91
ripple::SHAMap::deepCompare
bool deepCompare(SHAMap &other) const
Definition: SHAMapSync.cpp:687
ripple::SHAMap::MissingNodes::stack_
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition: SHAMap.h:451
ripple::SHAMap::hasInnerNode
bool hasInnerNode(SHAMapNodeID const &nodeID, SHAMapHash const &hash) const
Does this map have this inner node?
Definition: SHAMapSync.cpp:759
ripple::SHAMap::family
Family const & family() const
Definition: SHAMap.h:111
ripple::SHAMap::findKey
SHAMapTreeNode * findKey(uint256 const &id) const
Return nullptr if key not found.
Definition: SHAMap.cpp:135
ripple::SHAMap::canonicalize
void canonicalize(SHAMapHash const &hash, std::shared_ptr< SHAMapAbstractNode > &) const
Definition: SHAMap.cpp:1122
ripple::Slice
An immutable linear range of bytes.
Definition: Slice.h:44
ripple::SHAMap::seq_
std::uint32_t seq_
Definition: SHAMap.h:86
std::pair
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes(int max, SHAMapSyncFilter *filter, int maxDefer, std::uint32_t generation)
Definition: SHAMap.h:461
ripple::SHAMap::dump
void dump(bool withHashes=false) const
Definition: SHAMap.cpp:1071
ripple::SHAMap::descendThrow
SHAMapAbstractNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:256
ripple::SHAMap::getNodeFat
bool getNodeFat(SHAMapNodeID node, std::vector< SHAMapNodeID > &nodeIDs, std::vector< Blob > &rawNode, bool fatLeaves, std::uint32_t depth) const
Definition: SHAMapSync.cpp:447
ripple::SHAMap::const_iterator::stack_
SharedPtrNodeStack stack_
Definition: SHAMap.h:545
ripple::SHAMap::getFetchPack
void getFetchPack(SHAMap const *have, bool includeLeaves, int max, std::function< void(SHAMapHash const &, const Blob &)>) const
Definition: SHAMapSync.cpp:820
vector
ripple::NodeObjectType
NodeObjectType
The types of node objects.
Definition: NodeObject.h:32
ripple::SHAMap::visitNodes
void visitNodes(std::function< bool(SHAMapAbstractNode &)> const &function) const
Visit every node in this SHAMap.
Definition: SHAMapSync.cpp:39
ripple::SHAMap::MissingNodes::maxDefer_
const int maxDefer_
Definition: SHAMap.h:431
ripple::SHAMap::MissingNodes::generation_
std::uint32_t generation_
Definition: SHAMap.h:432
stack
ripple::SHAMap::peekItem
std::shared_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
Definition: SHAMap.cpp:539
std::forward_iterator_tag
ripple::SHAMap::Delta
std::map< uint256, DeltaItem > Delta
Definition: SHAMap.h:98
std::tuple
ripple::SHAMapState::Modifying
@ Modifying
ripple::SHAMap::begin
const_iterator begin() const
Definition: SHAMap.h:638
std::function
ripple::SHAMapNodeID
Definition: SHAMapNodeID.h:33
ripple::SHAMap::MissingNodes::filter_
SHAMapSyncFilter * filter_
Definition: SHAMap.h:430
ripple::SHAMap::snapShot
std::shared_ptr< SHAMap > snapShot(bool isMutable) const
Definition: SHAMap.cpp:51
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:179
ripple::SHAMap::fetchNode
std::shared_ptr< SHAMapAbstractNode > fetchNode(SHAMapHash const &hash) const
Definition: SHAMap.cpp:245
ripple::const_iterator
Dir::const_iterator const_iterator
Definition: Directory.cpp:25
ripple::SHAMap::const_iterator::operator->
pointer operator->() const
Definition: SHAMap.h:600
ripple::SHAMap::~SHAMap
~SHAMap()
Definition: SHAMap.cpp:45
ripple::SHAMap::setFull
void setFull()
Definition: SHAMap.h:484
ripple::SHAMapHash
Definition: SHAMapTreeNode.h:43
ripple::SHAMap::fetchNodeNT
std::shared_ptr< SHAMapAbstractNode > fetchNodeNT(SHAMapHash const &hash) const
Definition: SHAMap.cpp:233
ripple::SHAMap::getNeededHashes
std::vector< uint256 > getNeededHashes(int max, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:433
ripple::SHAMapState::Synching
@ Synching
ripple::operator==
bool operator==(Manifest const &lhs, Manifest const &rhs)
Definition: Manifest.h:155
ripple::SHAMap::getRootNode
bool getRootNode(Serializer &s, SHANodeFormat format) const
Definition: SHAMapSync.cpp:544
ripple::SHAMap::f_
Family & f_
Definition: SHAMap.h:84
ripple::SHAMap::type_
SHAMapType type_
Definition: SHAMap.h:90
ripple::base_uint< 256 >
ripple::SHAMap::descendAsync
SHAMapAbstractNode * descendAsync(SHAMapInnerNode *parent, int branch, SHAMapSyncFilter *filter, bool &pending) const
Definition: SHAMap.cpp:353
ripple::SHAMap::addGiveItem
bool addGiveItem(std::shared_ptr< SHAMapItem const >, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:699
ripple::SHAMap::onlyBelow
std::shared_ptr< SHAMapItem const > const & onlyBelow(SHAMapAbstractNode *) const
If there is only one leaf below this node, get its contents.
Definition: SHAMap.cpp:459
ripple::SHAMap::MissingNodes::resumes_
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition: SHAMap.h:459
ripple::SHAMap::hasItem
bool hasItem(uint256 const &id) const
Definition: SHAMap.cpp:613
ripple::SHAMap::const_iterator::operator==
friend bool operator==(const_iterator const &x, const_iterator const &y)
Definition: SHAMap.h:625
ripple::SHAMap::MissingNodes::deferredReads_
std::vector< std::tuple< SHAMapInnerNode *, SHAMapNodeID, int > > deferredReads_
Definition: SHAMap.h:455
ripple::SHAMap::hasLeafNode
bool hasLeafNode(uint256 const &tag, SHAMapHash const &hash) const
Does this map have this leaf node?
Definition: SHAMapSync.cpp:783
ripple::SHAMap::visitDifferences
void visitDifferences(SHAMap const *have, std::function< bool(SHAMapAbstractNode &)>) const
Visit every node in this SHAMap that is not present in the specified SHAMap.
Definition: SHAMapSync.cpp:105
ripple::SHAMap::operator=
SHAMap & operator=(SHAMap const &)=delete
ripple::SHAMapInnerNode
Definition: SHAMapTreeNode.h:207
ripple::SHAMap::MissingNodes::max_
int max_
Definition: SHAMap.h:429
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:34
ripple::SHAMap::isSynching
bool isSynching() const
Definition: SHAMap.h:503
ripple::SHAMap::const_iterator
Definition: SHAMap.h:535
ripple::SHAMap
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition: SHAMap.h:81
ripple::SHAMap::const_iterator::operator++
const_iterator & operator++()
Definition: SHAMap.h:606
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:444
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:273
ripple::SHAMap::getCache
std::shared_ptr< SHAMapAbstractNode > getCache(SHAMapHash const &hash) const
Definition: SHAMap.cpp:1114
ripple::SHAMap::journal_
beast::Journal journal_
Definition: SHAMap.h:85
ripple::SHAMap::MissingNodes::missingHashes_
std::set< SHAMapHash > missingHashes_
Definition: SHAMap.h:436
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:547
std::uint32_t
std::map
STL class.
ripple::SHAMapAbstractNode::TNType
TNType
Definition: SHAMapTreeNode.h:125
ripple::SHAMap::setLedgerSeq
void setLedgerSeq(std::uint32_t lseq)
Definition: SHAMap.h:490
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:321
ripple::SHAMap::const_iterator::map_
SHAMap const * map_
Definition: SHAMap.h:546
ripple::SHAMap::fetchNodeFromDB
std::shared_ptr< SHAMapAbstractNode > fetchNodeFromDB(SHAMapHash const &hash) const
Definition: SHAMap.cpp:144
ripple::SHAMap::fetchRoot
bool fetchRoot(SHAMapHash const &hash, SHAMapSyncFilter *filter)
Definition: SHAMap.cpp:846
ripple::SHAMap::walkMap
void walkMap(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
Definition: SHAMapDelta.cpp:250
ripple::Serializer
Definition: Serializer.h:39
ripple::SHAMap::upper_bound
const_iterator upper_bound(uint256 const &id) const
Definition: SHAMap.cpp:574
ripple::SHAMap::const_iterator::operator*
reference operator*() const
Definition: SHAMap.h:594
ripple::SHAMap::walkBranch
bool walkBranch(SHAMapAbstractNode *node, std::shared_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const
Definition: SHAMapDelta.cpp:34
ripple::SHAMap::checkFilter
std::shared_ptr< SHAMapAbstractNode > checkFilter(SHAMapHash const &hash, SHAMapSyncFilter *filter) const
Definition: SHAMap.cpp:177
ripple::SHAMap::setImmutable
void setImmutable()
Definition: SHAMap.h:496
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:92
ripple::SHAMap::descend
SHAMapAbstractNode * descend(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:279
ripple::SHAMap::descendNoStore
std::shared_ptr< SHAMapAbstractNode > descendNoStore(std::shared_ptr< SHAMapInnerNode > const &, int branch) const
Definition: SHAMap.cpp:313
ripple::SHAMap::flushDirty
int flushDirty(NodeObjectType t, std::uint32_t seq)
Convert all modified nodes to shared nodes.
Definition: SHAMap.cpp:941
ripple::SHAMap::setUnbacked
void setUnbacked()
Definition: SHAMap.h:528
ripple::SHAMap::firstBelow
SHAMapTreeNode * firstBelow(std::shared_ptr< SHAMapAbstractNode >, SharedPtrNodeStack &stack, int branch=0) const
Definition: SHAMap.cpp:417
ripple::SHAMap::end
const_iterator end() const
Definition: SHAMap.h:644
std
STL namespace.
cassert
ripple::SHAMap::unshare
int unshare()
Definition: SHAMap.cpp:932
std::ptrdiff_t
ripple::SHAMap::root_
std::shared_ptr< SHAMapAbstractNode > root_
Definition: SHAMap.h:88
ripple::SHAMapAbstractNode
Definition: SHAMapTreeNode.h:122
ripple::SHAMapState::Immutable
@ Immutable
ripple::SHAMap::compare
bool compare(SHAMap const &otherMap, Delta &differences, int maxCount) const
Definition: SHAMapDelta.cpp:124
ripple::SHAMap::addItem
bool addItem(SHAMapItem &&i, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:782
ripple::SHAMapType
SHAMapType
Definition: SHAMapMissingNode.h:32
ripple::SHAMap::walkTowardsKey
SHAMapTreeNode * walkTowardsKey(uint256 const &id, SharedPtrNodeStack *stack=nullptr) const
Walk towards the specified id, returning the node.
Definition: SHAMap.cpp:109
ripple::SHAMap::gmn_ProcessDeferredReads
void gmn_ProcessDeferredReads(MissingNodes &)
Definition: SHAMapSync.cpp:260
ripple::SHAMap::walkSubTree
int walkSubTree(bool doWrite, NodeObjectType t, std::uint32_t seq)
Definition: SHAMap.cpp:947
ripple::SHAMapState::Invalid
@ Invalid
ripple::SHAMap::peekFirstItem
SHAMapTreeNode const * peekFirstItem(SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:496
ripple::SHAMap::const_iterator::pointer
value_type const * pointer
Definition: SHAMap.h:542
ripple::SHAMap::dirtyUp
void dirtyUp(SharedPtrNodeStack &stack, uint256 const &target, std::shared_ptr< SHAMapAbstractNode > terminal)
Update hashes up to the root.
Definition: SHAMap.cpp:75
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:916
ripple::SHAMap::addKnownNode
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:593
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:399
ripple::SHAMap::MissingNodes::operator=
MissingNodes & operator=(const MissingNodes &)=delete
ripple::SHAMap::updateGiveItem
bool updateGiveItem(std::shared_ptr< SHAMapItem const >, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:803
ripple::SHAMap::addRootNode
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:551
ripple::SHAMap::peekNextItem
SHAMapTreeNode const * peekNextItem(uint256 const &id, SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:510
ripple::Dir::const_iterator::reference
value_type const & reference
Definition: Directory.h:54
ripple::SHAMap::ledgerSeq_
std::uint32_t ledgerSeq_
Definition: SHAMap.h:87
ripple::SHAMapSyncFilter
Definition: SHAMapSyncFilter.h:30
ripple::SHAMap::MissingNodes::missingNodes_
std::vector< std::pair< SHAMapNodeID, uint256 > > missingNodes_
Definition: SHAMap.h:435
ripple::SHAMap::delItem
bool delItem(uint256 const &id)
Definition: SHAMap.cpp:621
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes()=delete
ripple::SHAMap::state_
SHAMapState state_
Definition: SHAMap.h:89
std::set
STL class.
ripple::SHAMap::setSynching
void setSynching()
Definition: SHAMap.h:510
ripple::SHAMap::writeNode
std::shared_ptr< SHAMapAbstractNode > writeNode(NodeObjectType t, std::uint32_t seq, std::shared_ptr< SHAMapAbstractNode > node) const
write and canonicalize modified node
Definition: SHAMap.cpp:889
ripple::SHANodeFormat
SHANodeFormat
Definition: SHAMapTreeNode.h:35
ripple::SHAMapState
SHAMapState
Definition: SHAMap.h:45
ripple::SHAMapState::Floating
@ Floating
ripple::SHAMap::family
Family & family()
Definition: SHAMap.h:117
ripple::SHAMap::const_iterator::reference
value_type const & reference
Definition: SHAMap.h:541