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  SHANodeFormat format,
250  SHAMapSyncFilter* filter);
252  addKnownNode(
253  SHAMapNodeID const& nodeID,
254  Slice const& rawNode,
255  SHAMapSyncFilter* filter);
256 
257  // status functions
258  void
259  setImmutable();
260  bool
261  isSynching() const;
262  void
263  setSynching();
264  void
265  clearSynching();
266  bool
267  isValid() const;
268 
269  // caution: otherMap must be accessed only by this function
270  // return value: true=successfully completed, false=too different
271  bool
272  compare(SHAMap const& otherMap, Delta& differences, int maxCount) const;
273 
274  int
276  void
277  walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
278  bool
279  deepCompare(SHAMap& other) const; // Intended for debug/test only
280 
282 
283  void
284  getFetchPack(
285  SHAMap const* have,
286  bool includeLeaves,
287  int max,
288  std::function<void(SHAMapHash const&, const Blob&)>) const;
289 
290  void
291  setUnbacked();
292  int
293  unshare();
294 
295  void
296  dump(bool withHashes = false) const;
297  void
298  invariants() const;
299 
300 private:
303  using DeltaRef = std::pair<
306 
307  // tree node cache operations
309  getCache(SHAMapHash const& hash) const;
310  void
312  const;
313 
314  // database operations
316  fetchNodeFromDB(SHAMapHash const& hash) const;
318  fetchNodeNT(SHAMapHash const& hash) const;
320  fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
322  fetchNode(SHAMapHash const& hash) const;
324  checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
325 
327  void
328  dirtyUp(
329  SharedPtrNodeStack& stack,
330  uint256 const& target,
332 
337  walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr)
338  const;
341  findKey(uint256 const& id) const;
342 
344  template <class Node>
347 
349  template <class Node>
352 
355  writeNode(
356  NodeObjectType t,
357  std::uint32_t seq,
359 
361  firstBelow(
363  SharedPtrNodeStack& stack,
364  int branch = 0) const;
365 
366  // Simple descent
367  // Get a child of the specified node
369  descend(SHAMapInnerNode*, int branch) const;
371  descendThrow(SHAMapInnerNode*, int branch) const;
373  descend(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
375  descendThrow(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
376 
377  // Descend with filter
379  descendAsync(
380  SHAMapInnerNode* parent,
381  int branch,
382  SHAMapSyncFilter* filter,
383  bool& pending) const;
384 
386  descend(
387  SHAMapInnerNode* parent,
388  SHAMapNodeID const& parentID,
389  int branch,
390  SHAMapSyncFilter* filter) const;
391 
392  // Non-storing
393  // Does not hook the returned node to its parent
395  descendNoStore(std::shared_ptr<SHAMapInnerNode> const&, int branch) const;
396 
400 
401  bool
402  hasInnerNode(SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
403  bool
404  hasLeafNode(uint256 const& tag, SHAMapHash const& hash) const;
405 
406  SHAMapTreeNode const*
407  peekFirstItem(SharedPtrNodeStack& stack) const;
408  SHAMapTreeNode const*
409  peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
410  bool
411  walkBranch(
412  SHAMapAbstractNode* node,
413  std::shared_ptr<SHAMapItem const> const& otherMapItem,
414  bool isFirstMap,
415  Delta& differences,
416  int& maxCount) const;
417  int
418  walkSubTree(bool doWrite, NodeObjectType t, std::uint32_t seq);
419 
420  // Structure to track information about call to
421  // getMissingNodes while it's in progress
423  {
424  MissingNodes() = delete;
425  MissingNodes(const MissingNodes&) = delete;
426  MissingNodes&
427  operator=(const MissingNodes&) = delete;
428 
429  // basic parameters
430  int max_;
432  int const maxDefer_;
434 
435  // nodes we have discovered to be missing
438 
439  // nodes we are in the process of traversing
440  using StackEntry = std::tuple<
441  SHAMapInnerNode*, // pointer to the node
442  SHAMapNodeID, // the node's ID
443  int, // while child we check first
444  int, // which child we check next
445  bool>; // whether we've found any missing children yet
446 
447  // We explicitly choose to specify the use of std::deque here, because
448  // we need to ensure that pointers and/or references to existing
449  // elements will not be invalidated during the course of element
450  // insertion and removal. Containers that do not offer this guarantee,
451  // such as std::vector, can't be used here.
453 
454  // nodes we may acquire from deferred reads
457 
458  // nodes we need to resume after we get their children from deferred
459  // reads
461 
463  int max,
464  SHAMapSyncFilter* filter,
465  int maxDefer,
466  std::uint32_t generation)
467  : max_(max)
468  , filter_(filter)
469  , maxDefer_(maxDefer)
470  , generation_(generation)
471  {
472  missingNodes_.reserve(max);
473  deferredReads_.reserve(maxDefer);
474  }
475  };
476 
477  // getMissingNodes helper functions
478  void
479  gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node);
480  void
481  gmn_ProcessDeferredReads(MissingNodes&);
482 };
483 
484 inline void
486 {
487  full_ = true;
488 }
489 
490 inline void
492 {
493  ledgerSeq_ = lseq;
494 }
495 
496 inline void
498 {
499  assert(state_ != SHAMapState::Invalid);
501 }
502 
503 inline bool
505 {
506  return (state_ == SHAMapState::Floating) ||
508 }
509 
510 inline void
512 {
514 }
515 
516 inline void
518 {
520 }
521 
522 inline bool
524 {
525  return state_ != SHAMapState::Invalid;
526 }
527 
528 inline void
530 {
531  backed_ = false;
532 }
533 
534 //------------------------------------------------------------------------------
535 
537 {
538 public:
542  using reference = value_type const&;
543  using pointer = value_type const*;
544 
545 private:
547  SHAMap const* map_ = nullptr;
548  pointer item_ = nullptr;
549 
550 public:
551  const_iterator() = default;
552 
553  reference
554  operator*() const;
555  pointer
556  operator->() const;
557 
559  operator++();
561  operator++(int);
562 
563 private:
564  explicit const_iterator(SHAMap const* map);
565  const_iterator(SHAMap const* map, pointer item);
566  const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
567 
568  friend bool
569  operator==(const_iterator const& x, const_iterator const& y);
570  friend class SHAMap;
571 };
572 
574  : map_(map), item_(nullptr)
575 {
576  auto temp = map_->peekFirstItem(stack_);
577  if (temp)
578  item_ = temp->peekItem().get();
579 }
580 
582  : map_(map), item_(item)
583 {
584 }
585 
587  SHAMap const* map,
588  pointer item,
589  SharedPtrNodeStack&& stack)
590  : stack_(std::move(stack)), map_(map), item_(item)
591 {
592 }
593 
596 {
597  return *item_;
598 }
599 
602 {
603  return item_;
604 }
605 
608 {
609  auto temp = map_->peekNextItem(item_->key(), stack_);
610  if (temp)
611  item_ = temp->peekItem().get();
612  else
613  item_ = nullptr;
614  return *this;
615 }
616 
619 {
620  auto tmp = *this;
621  ++(*this);
622  return tmp;
623 }
624 
625 inline bool
627 {
628  assert(x.map_ == y.map_);
629  return x.item_ == y.item_;
630 }
631 
632 inline bool
634 {
635  return !(x == y);
636 }
637 
638 inline SHAMap::const_iterator
640 {
641  return const_iterator(this);
642 }
643 
645 SHAMap::end() const
646 {
647  return const_iterator(this, nullptr);
648 }
649 
650 } // namespace ripple
651 
652 #endif
ripple::SHAMap::MissingNodes
Definition: SHAMap.h:422
ripple::SHAMapAddNode
Definition: SHAMapAddNode.h:28
ripple::SHAMap::invariants
void invariants() const
Definition: SHAMap.cpp:1130
ripple::SHAMap::clearSynching
void clearSynching()
Definition: SHAMap.h:517
ripple::SHAMap::isValid
bool isValid() const
Definition: SHAMap.h:523
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:789
ripple::SHAMap::backed_
bool backed_
Definition: SHAMap.h:91
ripple::SHAMap::deepCompare
bool deepCompare(SHAMap &other) const
Definition: SHAMapSync.cpp:680
ripple::SHAMap::MissingNodes::stack_
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition: SHAMap.h:452
ripple::SHAMap::hasInnerNode
bool hasInnerNode(SHAMapNodeID const &nodeID, SHAMapHash const &hash) const
Does this map have this inner node?
Definition: SHAMapSync.cpp:752
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:1118
ripple::Slice
An immutable linear range of bytes.
Definition: Slice.h:43
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:462
ripple::SHAMap::dump
void dump(bool withHashes=false) const
Definition: SHAMap.cpp:1067
ripple::SHAMap::descendThrow
SHAMapAbstractNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition: SHAMap.cpp:249
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:442
ripple::SHAMap::const_iterator::stack_
SharedPtrNodeStack stack_
Definition: SHAMap.h:546
ripple::SHAMap::getFetchPack
void getFetchPack(SHAMap const *have, bool includeLeaves, int max, std::function< void(SHAMapHash const &, const Blob &)>) const
Definition: SHAMapSync.cpp:813
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:432
ripple::SHAMap::MissingNodes::generation_
std::uint32_t generation_
Definition: SHAMap.h:433
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:639
std::function
ripple::SHAMapNodeID
Definition: SHAMapNodeID.h:33
ripple::SHAMap::MissingNodes::filter_
SHAMapSyncFilter * filter_
Definition: SHAMap.h:431
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:238
ripple::const_iterator
Dir::const_iterator const_iterator
Definition: Directory.cpp:25
ripple::SHAMap::const_iterator::operator->
pointer operator->() const
Definition: SHAMap.h:601
ripple::SHAMap::~SHAMap
~SHAMap()
Definition: SHAMap.cpp:45
ripple::SHAMap::setFull
void setFull()
Definition: SHAMap.h:485
ripple::SHAMapHash
Definition: SHAMapTreeNode.h:43
ripple::SHAMap::fetchNodeNT
std::shared_ptr< SHAMapAbstractNode > fetchNodeNT(SHAMapHash const &hash) const
Definition: SHAMap.cpp:226
ripple::SHAMap::getNeededHashes
std::vector< uint256 > getNeededHashes(int max, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:428
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:537
ripple::SHAMap::f_
Family & f_
Definition: SHAMap.h:84
ripple::SHAMap::updateGiveItem
bool updateGiveItem(std::shared_ptr< SHAMapItem const > const &, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:801
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:346
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:457
ripple::SHAMap::MissingNodes::resumes_
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition: SHAMap.h:460
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:626
ripple::SHAMap::MissingNodes::deferredReads_
std::vector< std::tuple< SHAMapInnerNode *, SHAMapNodeID, int > > deferredReads_
Definition: SHAMap.h:456
ripple::SHAMap::hasLeafNode
bool hasLeafNode(uint256 const &tag, SHAMapHash const &hash) const
Does this map have this leaf node?
Definition: SHAMapSync.cpp:776
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:189
ripple::SHAMap::MissingNodes::max_
int max_
Definition: SHAMap.h:430
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:504
ripple::SHAMap::const_iterator
Definition: SHAMap.h:536
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:607
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:445
ripple::SHAMap::addGiveItem
bool addGiveItem(std::shared_ptr< SHAMapItem const > const &, bool isTransaction, bool hasMeta)
Definition: SHAMap.cpp:699
ripple::SHAMapTreeNode
Definition: SHAMapTreeNode.h:255
ripple::SHAMap::getCache
std::shared_ptr< SHAMapAbstractNode > getCache(SHAMapHash const &hash) const
Definition: SHAMap.cpp:1110
ripple::SHAMap::journal_
beast::Journal journal_
Definition: SHAMap.h:85
ripple::SHAMap::MissingNodes::missingHashes_
std::set< SHAMapHash > missingHashes_
Definition: SHAMap.h:437
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:548
std::uint32_t
std::map
STL class.
ripple::SHAMapAbstractNode::TNType
TNType
Definition: SHAMapTreeNode.h:125
ripple::SHAMap::addRootNode
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHANodeFormat format, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:544
ripple::SHAMap::setLedgerSeq
void setLedgerSeq(std::uint32_t lseq)
Definition: SHAMap.h:491
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:316
ripple::SHAMap::const_iterator::map_
SHAMap const * map_
Definition: SHAMap.h:547
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:844
ripple::SHAMap::walkMap
void walkMap(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
Definition: SHAMapDelta.cpp:250
ripple::Serializer
Definition: Serializer.h:43
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:595
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:182
ripple::SHAMap::setImmutable
void setImmutable()
Definition: SHAMap.h:497
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:272
ripple::SHAMap::descendNoStore
std::shared_ptr< SHAMapAbstractNode > descendNoStore(std::shared_ptr< SHAMapInnerNode > const &, int branch) const
Definition: SHAMap.cpp:306
ripple::SHAMap::flushDirty
int flushDirty(NodeObjectType t, std::uint32_t seq)
Convert all modified nodes to shared nodes.
Definition: SHAMap.cpp:939
ripple::SHAMap::setUnbacked
void setUnbacked()
Definition: SHAMap.h:529
ripple::SHAMap::firstBelow
SHAMapTreeNode * firstBelow(std::shared_ptr< SHAMapAbstractNode >, SharedPtrNodeStack &stack, int branch=0) const
Definition: SHAMap.cpp:415
ripple::SHAMap::end
const_iterator end() const
Definition: SHAMap.h:645
std
STL namespace.
cassert
ripple::SHAMap::unshare
int unshare()
Definition: SHAMap.cpp:930
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:780
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:255
ripple::SHAMap::walkSubTree
int walkSubTree(bool doWrite, NodeObjectType t, std::uint32_t seq)
Definition: SHAMap.cpp:945
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:543
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:914
ripple::SHAMap::addKnownNode
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
Definition: SHAMapSync.cpp:588
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:397
ripple::SHAMap::MissingNodes::operator=
MissingNodes & operator=(const MissingNodes &)=delete
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:436
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:511
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:887
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:542