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/shamap/Family.h>
24 #include <ripple/shamap/FullBelowCache.h>
25 #include <ripple/shamap/SHAMapAddNode.h>
26 #include <ripple/shamap/SHAMapItem.h>
27 #include <ripple/shamap/SHAMapMissingNode.h>
28 #include <ripple/shamap/SHAMapNodeID.h>
29 #include <ripple/shamap/SHAMapSyncFilter.h>
30 #include <ripple/shamap/SHAMapTreeNode.h>
31 #include <ripple/shamap/TreeNodeCache.h>
32 #include <ripple/basics/UnorderedContainers.h>
33 #include <ripple/nodestore/Database.h>
34 #include <ripple/nodestore/NodeObject.h>
35 #include <ripple/beast/utility/Journal.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 {
47  Modifying = 0, // Objects can be added and removed (like an open ledger)
48  Immutable = 1, // Map cannot be changed (like a closed ledger)
49  Synching = 2, // Map's hash is locked in, valid nodes can be added (like a peer's closing ledger)
50  Floating = 3, // Map is free to change hash (like a synching open ledger)
51  Invalid = 4, // Map is known not to be valid (usually synching a corrupt ledger)
52 };
53 
56 
79 class SHAMap
80 {
81 private:
85  std::uint32_t ledgerSeq_ = 0; // sequence number of ledger this is part of
89  bool backed_ = true; // Map is backed by the database
90  bool full_ = false; // Map is believed complete in database
91 
92 public:
96 
97  ~SHAMap ();
98  SHAMap(SHAMap const&) = delete;
99  SHAMap& operator=(SHAMap const&) = delete;
100 
101  // build new map
102  SHAMap (
103  SHAMapType t,
104  Family& f
105  );
106 
107  SHAMap (
108  SHAMapType t,
109  uint256 const& hash,
110  Family& f);
111 
112  Family const&
113  family() const
114  {
115  return f_;
116  }
117 
118  Family&
120  {
121  return f_;
122  }
123 
124  //--------------------------------------------------------------------------
125 
130  class const_iterator;
131 
132  const_iterator begin() const;
133  const_iterator 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.
139  std::shared_ptr<SHAMap> snapShot (bool isMutable) const;
140 
141  /* Mark this SHAMap as "should be full", indicating
142  that the local server wants all the corresponding nodes
143  in durable storage.
144  */
145  void setFull ();
146 
147  void setLedgerSeq (std::uint32_t lseq);
148 
149  bool fetchRoot (SHAMapHash const& hash, SHAMapSyncFilter * filter);
150 
151  // normal hash access functions
152  bool hasItem (uint256 const& id) const;
153  bool delItem (uint256 const& id);
154  bool addItem (SHAMapItem&& i, bool isTransaction, bool hasMeta);
155  SHAMapHash getHash () const;
156 
157  // save a copy if you have a temporary anyway
159  bool isTransaction, bool hasMeta);
161  bool isTransaction, bool hasMeta);
162 
163  // Save a copy if you need to extend the life
164  // of the SHAMapItem beyond this SHAMap
165  std::shared_ptr<SHAMapItem const> const& peekItem (uint256 const& id) const;
167  peekItem (uint256 const& id, SHAMapHash& hash) const;
169  peekItem (uint256 const& id, SHAMapTreeNode::TNType & type) const;
170 
171  // traverse functions
172  const_iterator upper_bound(uint256 const& id) const;
173 
179  void visitNodes (std::function<bool (
180  SHAMapAbstractNode&)> const& function) const;
181 
188  void visitDifferences(SHAMap const* have,
189  std::function<bool (SHAMapAbstractNode&)>) const;
190 
195  void visitLeaves(std::function<void (
196  std::shared_ptr<SHAMapItem const> const&)> const&) const;
197 
198  // comparison/sync functions
199 
211  getMissingNodes (int maxNodes, SHAMapSyncFilter *filter);
212 
213  bool getNodeFat (SHAMapNodeID node,
214  std::vector<SHAMapNodeID>& nodeIDs,
215  std::vector<Blob>& rawNode,
216  bool fatLeaves, std::uint32_t depth) const;
217 
218  bool getRootNode (Serializer & s, SHANodeFormat format) const;
220  SHAMapAddNode addRootNode (SHAMapHash const& hash, Slice const& rootNode,
221  SHANodeFormat format, SHAMapSyncFilter * filter);
222  SHAMapAddNode addKnownNode (SHAMapNodeID const& nodeID, Slice const& rawNode,
223  SHAMapSyncFilter * filter);
224 
225 
226  // status functions
227  void setImmutable ();
228  bool isSynching () const;
229  void setSynching ();
230  void clearSynching ();
231  bool isValid () const;
232 
233  // caution: otherMap must be accessed only by this function
234  // return value: true=successfully completed, false=too different
235  bool compare (SHAMap const& otherMap,
236  Delta& differences, int maxCount) const;
237 
239  void walkMap (std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
240  bool deepCompare (SHAMap & other) const; // Intended for debug/test only
241 
243 
244  void getFetchPack (SHAMap const* have, bool includeLeaves, int max,
245  std::function<void (SHAMapHash const&, const Blob&)>) const;
246 
247  void setUnbacked ();
248  int unshare ();
249 
250  void dump (bool withHashes = false) const;
251  void invariants() const;
252 
253 private:
254  using SharedPtrNodeStack =
258 
259  // tree node cache operations
262 
263  // database operations
267  SHAMapHash const& hash,
268  SHAMapSyncFilter *filter) const;
271  SHAMapSyncFilter* filter) const;
272 
274  void dirtyUp (SharedPtrNodeStack& stack,
275  uint256 const& target, std::shared_ptr<SHAMapAbstractNode> terminal);
276 
280  walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr) const;
283  findKey(uint256 const& id) const;
284 
286  template <class Node>
289 
291  template <class Node>
294 
299 
301  SharedPtrNodeStack& stack, int branch = 0) const;
302 
303  // Simple descent
304  // Get a child of the specified node
305  SHAMapAbstractNode* descend (SHAMapInnerNode*, int branch) const;
306  SHAMapAbstractNode* descendThrow (SHAMapInnerNode*, int branch) const;
309 
310  // Descend with filter
311  SHAMapAbstractNode* descendAsync (SHAMapInnerNode* parent, int branch,
312  SHAMapSyncFilter* filter, bool& pending) const;
313 
315  descend (SHAMapInnerNode* parent, SHAMapNodeID const& parentID,
316  int branch, SHAMapSyncFilter* filter) const;
317 
318  // Non-storing
319  // Does not hook the returned node to its parent
321  descendNoStore (std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
322 
325 
326  bool hasInnerNode (SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
327  bool hasLeafNode (uint256 const& tag, SHAMapHash const& hash) const;
328 
329  SHAMapTreeNode const* peekFirstItem(SharedPtrNodeStack& stack) const;
330  SHAMapTreeNode const* peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
331  bool walkBranch (SHAMapAbstractNode* node,
332  std::shared_ptr<SHAMapItem const> const& otherMapItem,
333  bool isFirstMap, Delta & differences, int & maxCount) const;
334  int walkSubTree (bool doWrite, NodeObjectType t, std::uint32_t seq);
335 
336  // Structure to track information about call to
337  // getMissingNodes while it's in progress
339  {
340  MissingNodes() = delete;
341  MissingNodes(const MissingNodes&) = delete;
342  MissingNodes& operator=(const MissingNodes&) = delete;
343 
344  // basic parameters
345  int max_;
347  int const maxDefer_;
349 
350  // nodes we have discovered to be missing
353 
354  // nodes we are in the process of traversing
355  using StackEntry = std::tuple<
356  SHAMapInnerNode*, // pointer to the node
357  SHAMapNodeID, // the node's ID
358  int, // while child we check first
359  int, // which child we check next
360  bool>; // whether we've found any missing children yet
361 
362  // We explicitly choose to specify the use of std::deque here, because
363  // we need to ensure that pointers and/or references to existing elements
364  // will not be invalidated during the course of element insertion and
365  // removal. Containers that do not offer this guarantee, such as
366  // std::vector, can't be used here.
368 
369  // nodes we may acquire from deferred reads
371 
372  // nodes we need to resume after we get their children from deferred reads
374 
376  int max, SHAMapSyncFilter* filter,
377  int maxDefer, std::uint32_t generation) :
378  max_(max), filter_(filter),
379  maxDefer_(maxDefer), generation_(generation)
380  {
381  missingNodes_.reserve (max);
382  deferredReads_.reserve(maxDefer);
383  }
384  };
385 
386  // getMissingNodes helper functions
387  void gmn_ProcessNodes (MissingNodes&, MissingNodes::StackEntry& node);
388  void gmn_ProcessDeferredReads (MissingNodes&);
389 };
390 
391 inline
392 void
394 {
395  full_ = true;
396 }
397 
398 inline
399 void
401 {
402  ledgerSeq_ = lseq;
403 }
404 
405 inline
406 void
408 {
409  assert (state_ != SHAMapState::Invalid);
411 }
412 
413 inline
414 bool
416 {
418 }
419 
420 inline
421 void
423 {
425 }
426 
427 inline
428 void
430 {
432 }
433 
434 inline
435 bool
437 {
438  return state_ != SHAMapState::Invalid;
439 }
440 
441 inline
442 void
444 {
445  backed_ = false;
446 }
447 
448 //------------------------------------------------------------------------------
449 
451 {
452 public:
456  using reference = value_type const&;
457  using pointer = value_type const*;
458 
459 private:
461  SHAMap const* map_ = nullptr;
462  pointer item_ = nullptr;
463 
464 public:
465  const_iterator() = default;
466 
467  reference operator*() const;
468  pointer operator->() const;
469 
472 
473 private:
474  explicit const_iterator(SHAMap const* map);
475  const_iterator(SHAMap const* map, pointer item);
476  const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
477 
478  friend bool operator==(const_iterator const& x, const_iterator const& y);
479  friend class SHAMap;
480 };
481 
482 inline
484  : map_(map)
485  , item_(nullptr)
486 {
487  auto temp = map_->peekFirstItem(stack_);
488  if (temp)
489  item_ = temp->peekItem().get();
490 }
491 
492 inline
494  : map_(map)
495  , item_(item)
496 {
497 }
498 
499 inline
501  SharedPtrNodeStack&& stack)
502  : stack_(std::move(stack))
503  , map_(map)
504  , item_(item)
505 {
506 }
507 
508 inline
511 {
512  return *item_;
513 }
514 
515 inline
518 {
519  return item_;
520 }
521 
522 inline
525 {
526  auto temp = map_->peekNextItem(item_->key(), stack_);
527  if (temp)
528  item_ = temp->peekItem().get();
529  else
530  item_ = nullptr;
531  return *this;
532 }
533 
534 inline
537 {
538  auto tmp = *this;
539  ++(*this);
540  return tmp;
541 }
542 
543 inline
544 bool
546 {
547  assert(x.map_ == y.map_);
548  return x.item_ == y.item_;
549 }
550 
551 inline
552 bool
554 {
555  return !(x == y);
556 }
557 
558 inline
559 SHAMap::const_iterator
561 {
562  return const_iterator(this);
563 }
564 
565 inline
567 SHAMap::end() const
568 {
569  return const_iterator(this, nullptr);
570 }
571 
572 }
573 
574 #endif
ripple::SHAMap::MissingNodes
Definition: SHAMap.h:338
ripple::SHAMapAddNode
Definition: SHAMapAddNode.h:28
ripple::SHAMap::invariants
void invariants() const
Definition: SHAMap.cpp:1079
ripple::SHAMap::clearSynching
void clearSynching()
Definition: SHAMap.h:429
ripple::SHAMap::isValid
bool isValid() const
Definition: SHAMap.h:436
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:751
ripple::SHAMap::backed_
bool backed_
Definition: SHAMap.h:89
ripple::SHAMap::deepCompare
bool deepCompare(SHAMap &other) const
Definition: SHAMapSync.cpp:647
ripple::SHAMap::MissingNodes::stack_
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition: SHAMap.h:367
ripple::SHAMap::hasInnerNode
bool hasInnerNode(SHAMapNodeID const &nodeID, SHAMapHash const &hash) const
Does this map have this inner node?
Definition: SHAMapSync.cpp:718
ripple::SHAMap::family
Family const & family() const
Definition: SHAMap.h:113
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:1069
ripple::Slice
An immutable linear range of bytes.
Definition: Slice.h:43
ripple::SHAMap::seq_
std::uint32_t seq_
Definition: SHAMap.h:84
std::pair
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes(int max, SHAMapSyncFilter *filter, int maxDefer, std::uint32_t generation)
Definition: SHAMap.h:375
ripple::SHAMap::dump
void dump(bool withHashes=false) const
Definition: SHAMap.cpp:1018
ripple::SHAMap::descendThrow
SHAMapAbstractNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:244
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:428
ripple::SHAMap::const_iterator::stack_
SharedPtrNodeStack stack_
Definition: SHAMap.h:460
ripple::SHAMap::getFetchPack
void getFetchPack(SHAMap const *have, bool includeLeaves, int max, std::function< void(SHAMapHash const &, const Blob &)>) const
Definition: SHAMapSync.cpp:776
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:40
ripple::SHAMap::MissingNodes::maxDefer_
const int maxDefer_
Definition: SHAMap.h:347
ripple::SHAMap::MissingNodes::generation_
std::uint32_t generation_
Definition: SHAMap.h:348
stack
ripple::SHAMap::peekItem
std::shared_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
Definition: SHAMap.cpp:515
std::forward_iterator_tag
ripple::SHAMap::Delta
std::map< uint256, DeltaItem > Delta
Definition: SHAMap.h:95
std::tuple
ripple::SHAMapState::Modifying
@ Modifying
ripple::SHAMap::begin
const_iterator begin() const
Definition: SHAMap.h:560
std::function
ripple::SHAMapNodeID
Definition: SHAMapNodeID.h:33
ripple::SHAMap::MissingNodes::filter_
SHAMapSyncFilter * filter_
Definition: SHAMap.h:346
ripple::SHAMap::snapShot
std::shared_ptr< SHAMap > snapShot(bool isMutable) const
Definition: SHAMap.cpp:56
ripple::Dir::const_iterator::pointer
value_type const * pointer
Definition: Directory.h:55
ripple::SHAMap::gmn_ProcessNodes
void gmn_ProcessNodes(MissingNodes &, MissingNodes::StackEntry &node)
Definition: SHAMapSync.cpp:173
ripple::SHAMap::fetchNode
std::shared_ptr< SHAMapAbstractNode > fetchNode(SHAMapHash const &hash) const
Definition: SHAMap.cpp:234
ripple::const_iterator
Dir::const_iterator const_iterator
Definition: Directory.cpp:24
ripple::SHAMap::const_iterator::operator->
pointer operator->() const
Definition: SHAMap.h:517
ripple::SHAMap::~SHAMap
~SHAMap()
Definition: SHAMap.cpp:50
ripple::SHAMap::setFull
void setFull()
Definition: SHAMap.h:393
ripple::SHAMapHash
Definition: SHAMapTreeNode.h:44
ripple::SHAMap::fetchNodeNT
std::shared_ptr< SHAMapAbstractNode > fetchNodeNT(SHAMapHash const &hash) const
Definition: SHAMap.cpp:223
ripple::SHAMap::getNeededHashes
std::vector< uint256 > getNeededHashes(int max, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:415
ripple::SHAMapState::Synching
@ Synching
ripple::operator==
bool operator==(Manifest const &lhs, Manifest const &rhs)
Definition: Manifest.h:148
ripple::SHAMap::getRootNode
bool getRootNode(Serializer &s, SHANodeFormat format) const
Definition: SHAMapSync.cpp:519
ripple::SHAMap::f_
Family & f_
Definition: SHAMap.h:82
ripple::SHAMap::updateGiveItem
bool updateGiveItem(std::shared_ptr< SHAMapItem const > const &, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:763
ripple::SHAMap::type_
SHAMapType type_
Definition: SHAMap.h:88
ripple::base_uint< 256 >
ripple::SHAMap::descendAsync
SHAMapAbstractNode * descendAsync(SHAMapInnerNode *parent, int branch, SHAMapSyncFilter *filter, bool &pending) const
Definition: SHAMap.cpp:331
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:432
ripple::SHAMap::MissingNodes::resumes_
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition: SHAMap.h:373
ripple::SHAMap::hasItem
bool hasItem(uint256 const &id) const
Definition: SHAMap.cpp:586
ripple::SHAMap::const_iterator::operator==
friend bool operator==(const_iterator const &x, const_iterator const &y)
Definition: SHAMap.h:545
ripple::SHAMap::hasLeafNode
bool hasLeafNode(uint256 const &tag, SHAMapHash const &hash) const
Does this map have this leaf node?
Definition: SHAMapSync.cpp:741
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:140
ripple::SHAMap::MissingNodes::max_
int max_
Definition: SHAMap.h:345
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:415
ripple::SHAMap::const_iterator
Definition: SHAMap.h:450
ripple::SHAMap
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition: SHAMap.h:79
ripple::SHAMap::const_iterator::operator++
const_iterator & operator++()
Definition: SHAMap.h:524
ripple::operator!=
bool operator!=(Manifest const &lhs, Manifest const &rhs)
Definition: Manifest.h:161
ripple::SHAMap::MissingNodes::StackEntry
std::tuple< SHAMapInnerNode *, SHAMapNodeID, int, int, bool > StackEntry
Definition: SHAMap.h:360
ripple::SHAMap::addGiveItem
bool addGiveItem(std::shared_ptr< SHAMapItem const > const &, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:669
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:183
ripple::SHAMap::getCache
std::shared_ptr< SHAMapAbstractNode > getCache(SHAMapHash const &hash) const
Definition: SHAMap.cpp:1061
ripple::SHAMap::journal_
beast::Journal journal_
Definition: SHAMap.h:83
ripple::SHAMap::MissingNodes::missingHashes_
std::set< SHAMapHash > missingHashes_
Definition: SHAMap.h:352
ripple::Family
Definition: Family.h:32
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::SHAMap::const_iterator::item_
pointer item_
Definition: SHAMap.h:462
std::uint32_t
std::map
STL class.
ripple::SHAMapAbstractNode::TNType
TNType
Definition: SHAMapTreeNode.h:95
ripple::SHAMap::addRootNode
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHANodeFormat format, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:525
ripple::SHAMap::setLedgerSeq
void setLedgerSeq(std::uint32_t lseq)
Definition: SHAMap.h:400
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:307
ripple::SHAMap::const_iterator::map_
SHAMap const * map_
Definition: SHAMap.h:461
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:801
ripple::SHAMap::walkMap
void walkMap(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
Definition: SHAMapDelta.cpp:228
ripple::Serializer
Definition: Serializer.h:43
ripple::SHAMap::upper_bound
const_iterator upper_bound(uint256 const &id) const
Definition: SHAMap.cpp:550
ripple::SHAMap::const_iterator::operator*
reference operator*() const
Definition: SHAMap.h:510
ripple::SHAMap::walkBranch
bool walkBranch(SHAMapAbstractNode *node, std::shared_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const
Definition: SHAMapDelta.cpp:33
ripple::SHAMap::checkFilter
std::shared_ptr< SHAMapAbstractNode > checkFilter(SHAMapHash const &hash, SHAMapSyncFilter *filter) const
Definition: SHAMap.cpp:178
ripple::SHAMap::setImmutable
void setImmutable()
Definition: SHAMap.h:407
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:90
ripple::SHAMap::descend
SHAMapAbstractNode * descend(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:265
ripple::SHAMap::descendNoStore
std::shared_ptr< SHAMapAbstractNode > descendNoStore(std::shared_ptr< SHAMapInnerNode > const &, int branch) const
Definition: SHAMap.cpp:297
ripple::SHAMap::flushDirty
int flushDirty(NodeObjectType t, std::uint32_t seq)
Convert all modified nodes to shared nodes.
Definition: SHAMap.cpp:892
ripple::SHAMap::setUnbacked
void setUnbacked()
Definition: SHAMap.h:443
ripple::SHAMap::firstBelow
SHAMapTreeNode * firstBelow(std::shared_ptr< SHAMapAbstractNode >, SharedPtrNodeStack &stack, int branch=0) const
Definition: SHAMap.cpp:392
ripple::SHAMap::end
const_iterator end() const
Definition: SHAMap.h:567
std
STL namespace.
cassert
ripple::SHAMap::unshare
int unshare()
Definition: SHAMap.cpp:884
std::ptrdiff_t
ripple::SHAMap::root_
std::shared_ptr< SHAMapAbstractNode > root_
Definition: SHAMap.h:86
ripple::SHAMapAbstractNode
Definition: SHAMapTreeNode.h:92
ripple::SHAMapState::Immutable
@ Immutable
ripple::SHAMap::compare
bool compare(SHAMap const &otherMap, Delta &differences, int maxCount) const
Definition: SHAMapDelta.cpp:116
ripple::SHAMap::addItem
bool addItem(SHAMapItem &&i, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:744
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:246
ripple::SHAMap::walkSubTree
int walkSubTree(bool doWrite, NodeObjectType t, std::uint32_t seq)
Definition: SHAMap.cpp:898
ripple::SHAMapState::Invalid
@ Invalid
ripple::SHAMap::peekFirstItem
SHAMapTreeNode const * peekFirstItem(SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:472
ripple::SHAMap::const_iterator::pointer
value_type const * pointer
Definition: SHAMap.h:457
ripple::SHAMap::dirtyUp
void dirtyUp(SharedPtrNodeStack &stack, uint256 const &target, std::shared_ptr< SHAMapAbstractNode > terminal)
Update hashes up to the root.
Definition: SHAMap.cpp:80
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:869
ripple::SHAMap::addKnownNode
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:562
ripple::SHAMap::MissingNodes::deferredReads_
std::vector< std::tuple< SHAMapInnerNode *, SHAMapNodeID, int > > deferredReads_
Definition: SHAMap.h:370
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:374
ripple::SHAMap::MissingNodes::operator=
MissingNodes & operator=(const MissingNodes &)=delete
ripple::SHAMap::peekNextItem
SHAMapTreeNode const * peekNextItem(uint256 const &id, SharedPtrNodeStack &stack) const
Definition: SHAMap.cpp:486
ripple::Dir::const_iterator::reference
value_type const & reference
Definition: Directory.h:57
ripple::SHAMap::ledgerSeq_
std::uint32_t ledgerSeq_
Definition: SHAMap.h:85
ripple::SHAMapSyncFilter
Definition: SHAMapSyncFilter.h:30
ripple::SHAMap::MissingNodes::missingNodes_
std::vector< std::pair< SHAMapNodeID, uint256 > > missingNodes_
Definition: SHAMap.h:351
ripple::SHAMap::delItem
bool delItem(uint256 const &id)
Definition: SHAMap.cpp:593
ripple::SHAMap::MissingNodes::MissingNodes
MissingNodes()=delete
ripple::SHAMap::state_
SHAMapState state_
Definition: SHAMap.h:87
std::set
STL class.
ripple::SHAMap::setSynching
void setSynching()
Definition: SHAMap.h:422
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:847
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:119
ripple::SHAMap::const_iterator::reference
value_type const & reference
Definition: SHAMap.h:456