rippled
Loading...
Searching...
No Matches
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 <xrpld/nodestore/Database.h>
24#include <xrpld/nodestore/NodeObject.h>
25#include <xrpld/shamap/Family.h>
26#include <xrpld/shamap/SHAMapAddNode.h>
27#include <xrpld/shamap/SHAMapInnerNode.h>
28#include <xrpld/shamap/SHAMapItem.h>
29#include <xrpld/shamap/SHAMapLeafNode.h>
30#include <xrpld/shamap/SHAMapMissingNode.h>
31#include <xrpld/shamap/SHAMapTreeNode.h>
32#include <xrpld/shamap/TreeNodeCache.h>
33
34#include <xrpl/basics/IntrusivePointer.h>
35#include <xrpl/basics/UnorderedContainers.h>
36#include <xrpl/beast/utility/Journal.h>
37#include <xrpl/beast/utility/instrumentation.h>
38
39#include <set>
40#include <stack>
41#include <vector>
42
43namespace ripple {
44
45class SHAMapNodeID;
46class SHAMapSyncFilter;
47
49enum class SHAMapState {
54 Modifying = 0,
55
60 Immutable = 1,
61
66 Synching = 2,
67
72 Invalid = 3,
73};
74
98class SHAMap
99{
100private:
103
106
109
113 bool backed_ = true; // Map is backed by the database
114 mutable bool full_ = false; // Map is believed complete in database
115
116public:
119 static inline constexpr unsigned int branchFactor =
121
123 static inline constexpr unsigned int leafDepth = 64;
124
126 boost::intrusive_ptr<SHAMapItem const>,
127 boost::intrusive_ptr<SHAMapItem const>>;
129
130 SHAMap() = delete;
131 SHAMap(SHAMap const&) = delete;
132 SHAMap&
133 operator=(SHAMap const&) = delete;
134
135 // Take a snapshot of the given map:
136 SHAMap(SHAMap const& other, bool isMutable);
137
138 // build new map
139 SHAMap(SHAMapType t, Family& f);
140
141 SHAMap(SHAMapType t, uint256 const& hash, Family& f);
142
143 ~SHAMap() = default;
144
145 Family const&
146 family() const
147 {
148 return f_;
149 }
150
151 Family&
153 {
154 return f_;
155 }
156
157 //--------------------------------------------------------------------------
158
163 class const_iterator;
164
166 begin() const;
168 end() const;
169
170 //--------------------------------------------------------------------------
171
172 // Returns a new map that's a snapshot of this one.
173 // Handles copy on write for mutable snapshots.
175 snapShot(bool isMutable) const;
176
177 /* Mark this SHAMap as "should be full", indicating
178 that the local server wants all the corresponding nodes
179 in durable storage.
180 */
181 void
182 setFull();
183
184 void
186
187 bool
188 fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
189
190 // normal hash access functions
191
193 bool
194 hasItem(uint256 const& id) const;
195
196 bool
197 delItem(uint256 const& id);
198
199 bool
200 addItem(SHAMapNodeType type, boost::intrusive_ptr<SHAMapItem const> item);
201
203 getHash() const;
204
205 // save a copy if you have a temporary anyway
206 bool
208 SHAMapNodeType type,
209 boost::intrusive_ptr<SHAMapItem const> item);
210
211 bool
213 SHAMapNodeType type,
214 boost::intrusive_ptr<SHAMapItem const> item);
215
216 // Save a copy if you need to extend the life
217 // of the SHAMapItem beyond this SHAMap
218 boost::intrusive_ptr<SHAMapItem const> const&
219 peekItem(uint256 const& id) const;
220 boost::intrusive_ptr<SHAMapItem const> const&
221 peekItem(uint256 const& id, SHAMapHash& hash) const;
222
223 // traverse functions
231 upper_bound(uint256 const& id) const;
232
240 lower_bound(uint256 const& id) const;
241
247 void
248 visitNodes(std::function<bool(SHAMapTreeNode&)> const& function) const;
249
256 void
258 SHAMap const* have,
259 std::function<bool(SHAMapTreeNode const&)> const&) const;
260
265 void
268 void(boost::intrusive_ptr<SHAMapItem const> const&)> const&) const;
269
270 // comparison/sync functions
271
283 getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
284
285 bool
287 SHAMapNodeID const& wanted,
289 bool fatLeaves,
290 std::uint32_t depth) const;
291
299 getProofPath(uint256 const& key) const;
300
308 static bool
310 uint256 const& rootHash,
311 uint256 const& key,
312 std::vector<Blob> const& path);
313
315 void
316 serializeRoot(Serializer& s) const;
317
320 SHAMapHash const& hash,
321 Slice const& rootNode,
322 SHAMapSyncFilter* filter);
325 SHAMapNodeID const& nodeID,
326 Slice const& rawNode,
327 SHAMapSyncFilter* filter);
328
329 // status functions
330 void
331 setImmutable();
332 bool
333 isSynching() const;
334 void
335 setSynching();
336 void
338 bool
339 isValid() const;
340
341 // caution: otherMap must be accessed only by this function
342 // return value: true=successfully completed, false=too different
343 bool
344 compare(SHAMap const& otherMap, Delta& differences, int maxCount) const;
345
347 int
348 unshare();
349
351 int
353
354 void
355 walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
356 bool
358 std::vector<SHAMapMissingNode>& missingNodes,
359 int maxMissing) const;
360 bool
361 deepCompare(SHAMap& other) const; // Intended for debug/test only
362
363 void
364 setUnbacked();
365
366 void
367 dump(bool withHashes = false) const;
368 void
369 invariants() const;
370
371private:
375 boost::intrusive_ptr<SHAMapItem const>,
376 boost::intrusive_ptr<SHAMapItem const>>;
377
378 // tree node cache operations
380 cacheLookup(SHAMapHash const& hash) const;
381
382 void
384 const;
385
386 // database operations
388 fetchNodeFromDB(SHAMapHash const& hash) const;
390 fetchNodeNT(SHAMapHash const& hash) const;
392 fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
394 fetchNode(SHAMapHash const& hash) const;
396 checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
397
399 void
400 dirtyUp(
401 SharedPtrNodeStack& stack,
402 uint256 const& target,
404
409 walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr)
410 const;
413 findKey(uint256 const& id) const;
414
416 template <class Node>
419
421 template <class Node>
424
428
429 // returns the first item at or below this node
433 SharedPtrNodeStack& stack,
434 int branch = 0) const;
435
436 // returns the last item at or below this node
438 lastBelow(
440 SharedPtrNodeStack& stack,
441 int branch = branchFactor) const;
442
443 // helper function for firstBelow and lastBelow
447 SharedPtrNodeStack& stack,
448 int branch,
450 int,
451 std::function<bool(int)>,
452 std::function<void(int&)>> const& loopParams) const;
453
454 // Simple descent
455 // Get a child of the specified node
457 descend(SHAMapInnerNode*, int branch) const;
459 descendThrow(SHAMapInnerNode*, int branch) const;
461 descend(SHAMapInnerNode&, int branch) const;
463 descendThrow(SHAMapInnerNode&, int branch) const;
464
465 // Descend with filter
466 // If pending, callback is called as if it called fetchNodeNT
471 SHAMapInnerNode* parent,
472 int branch,
473 SHAMapSyncFilter* filter,
474 bool& pending,
475 descendCallback&&) const;
476
478 descend(
479 SHAMapInnerNode* parent,
480 SHAMapNodeID const& parentID,
481 int branch,
482 SHAMapSyncFilter* filter) const;
483
484 // Non-storing
485 // Does not hook the returned node to its parent
487 descendNoStore(SHAMapInnerNode&, int branch) const;
488
490 boost::intrusive_ptr<SHAMapItem const> const&
492
493 bool
494 hasInnerNode(SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
495 bool
496 hasLeafNode(uint256 const& tag, SHAMapHash const& hash) const;
497
498 SHAMapLeafNode const*
499 peekFirstItem(SharedPtrNodeStack& stack) const;
500 SHAMapLeafNode const*
501 peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
502 bool
504 SHAMapTreeNode* node,
505 boost::intrusive_ptr<SHAMapItem const> const& otherMapItem,
506 bool isFirstMap,
507 Delta& differences,
508 int& maxCount) const;
509 int
510 walkSubTree(bool doWrite, NodeObjectType t);
511
512 // Structure to track information about call to
513 // getMissingNodes while it's in progress
515 {
516 MissingNodes() = delete;
517 MissingNodes(MissingNodes const&) = delete;
519 operator=(MissingNodes const&) = delete;
520
521 // basic parameters
522 int max_;
524 int const maxDefer_;
526
527 // nodes we have discovered to be missing
530
531 // nodes we are in the process of traversing
533 SHAMapInnerNode*, // pointer to the node
534 SHAMapNodeID, // the node's ID
535 int, // while child we check first
536 int, // which child we check next
537 bool>; // whether we've found any missing children yet
538
539 // We explicitly choose to specify the use of std::deque here, because
540 // we need to ensure that pointers and/or references to existing
541 // elements will not be invalidated during the course of element
542 // insertion and removal. Containers that do not offer this guarantee,
543 // such as std::vector, can't be used here.
545
546 // nodes we may have acquired from deferred reads
548 SHAMapInnerNode*, // parent node
549 SHAMapNodeID, // parent node ID
550 int, // branch
552
557
558 // nodes we need to resume after we get their children from deferred
559 // reads
561
563 int max,
564 SHAMapSyncFilter* filter,
565 int maxDefer,
566 std::uint32_t generation)
567 : max_(max)
568 , filter_(filter)
569 , maxDefer_(maxDefer)
570 , generation_(generation)
571 , deferred_(0)
572 {
573 missingNodes_.reserve(max);
574 finishedReads_.reserve(maxDefer);
575 }
576 };
577
578 // getMissingNodes helper functions
579 void
580 gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node);
581 void
582 gmn_ProcessDeferredReads(MissingNodes&);
583
584 // fetch from DB helper function
587 SHAMapHash const& hash,
588 std::shared_ptr<NodeObject> const& object) const;
589};
590
591inline void
593{
594 full_ = true;
595}
596
597inline void
602
603inline void
605{
606 XRPL_ASSERT(
608 "ripple::SHAMap::setImmutable : state is valid");
610}
611
612inline bool
614{
616}
617
618inline void
623
624inline void
629
630inline bool
632{
634}
635
636inline void
638{
639 backed_ = false;
640}
641
642//------------------------------------------------------------------------------
643
645{
646public:
650 using reference = value_type const&;
651 using pointer = value_type const*;
652
653private:
655 SHAMap const* map_ = nullptr;
656 pointer item_ = nullptr;
657
658public:
659 const_iterator() = delete;
660
661 const_iterator(const_iterator const& other) = default;
663 operator=(const_iterator const& other) = default;
664
665 ~const_iterator() = default;
666
668 operator*() const;
669 pointer
670 operator->() const;
671
673 operator++();
675 operator++(int);
676
677private:
678 explicit const_iterator(SHAMap const* map);
680 const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
681
682 friend bool
683 operator==(const_iterator const& x, const_iterator const& y);
684 friend class SHAMap;
685};
686
687inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map)
688{
689 XRPL_ASSERT(
690 map_,
691 "ripple::SHAMap::const_iterator::const_iterator : non-null input");
692
693 if (auto temp = map_->peekFirstItem(stack_))
694 item_ = temp->peekItem().get();
695}
696
698 : map_(map)
699{
700}
701
703 SHAMap const* map,
704 pointer item,
705 SharedPtrNodeStack&& stack)
706 : stack_(std::move(stack)), map_(map), item_(item)
707{
708}
709
712{
713 return *item_;
714}
715
718{
719 return item_;
720}
721
724{
725 if (auto temp = map_->peekNextItem(item_->key(), stack_))
726 item_ = temp->peekItem().get();
727 else
728 item_ = nullptr;
729 return *this;
730}
731
734{
735 auto tmp = *this;
736 ++(*this);
737 return tmp;
738}
739
740inline bool
742{
743 XRPL_ASSERT(
744 x.map_ == y.map_,
745 "ripple::operator==(SHAMap::const_iterator, SHAMap::const_iterator) : "
746 "inputs map do match");
747 return x.item_ == y.item_;
748}
749
750inline bool
752{
753 return !(x == y);
754}
755
756inline SHAMap::const_iterator
758{
759 return const_iterator(this);
760}
761
764{
765 return const_iterator(this, nullptr);
766}
767
768} // namespace ripple
769
770#endif
A generic endpoint for log messages.
Definition Journal.h:60
const_iterator(ReadView const &view, Keylet const &root, Keylet const &page)
Definition Dir.h:115
reference operator*() const
Definition Dir.cpp:70
value_type const & reference
Definition Dir.h:66
const_iterator & operator++()
Definition Dir.cpp:81
value_type const * pointer
Definition Dir.h:65
pointer operator->() const
Definition Dir.h:83
static constexpr unsigned int branchFactor
Each inner node has 16 children (the 'radix tree' part of the map)
Identifies a node inside a SHAMap.
value_type const * pointer
Definition SHAMap.h:651
SharedPtrNodeStack stack_
Definition SHAMap.h:654
const_iterator(const_iterator const &other)=default
const_iterator & operator++()
Definition SHAMap.h:723
reference operator*() const
Definition SHAMap.h:711
value_type const & reference
Definition SHAMap.h:650
friend bool operator==(const_iterator const &x, const_iterator const &y)
Definition SHAMap.h:741
const_iterator & operator=(const_iterator const &other)=default
pointer operator->() const
Definition SHAMap.h:717
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition SHAMap.h:99
intr_ptr::SharedPtr< Node > preFlushNode(intr_ptr::SharedPtr< Node > node) const
prepare a node to be modified before flushing
Definition SHAMap.cpp:1013
Family & family()
Definition SHAMap.h:152
SHAMapTreeNode * descendAsync(SHAMapInnerNode *parent, int branch, SHAMapSyncFilter *filter, bool &pending, descendCallback &&) const
Definition SHAMap.cpp:394
bool hasItem(uint256 const &id) const
Does the tree have an item with the given ID?
Definition SHAMap.cpp:714
intr_ptr::SharedPtr< SHAMapTreeNode > cacheLookup(SHAMapHash const &hash) const
Definition SHAMap.cpp:1220
intr_ptr::SharedPtr< Node > unshareNode(intr_ptr::SharedPtr< Node >, SHAMapNodeID const &nodeID)
Unshare the node, allowing it to be modified.
Definition SHAMap.cpp:438
beast::Journal journal_
Definition SHAMap.h:102
static constexpr unsigned int leafDepth
The depth of the hash map: data is only present in the leaves.
Definition SHAMap.h:123
void dump(bool withHashes=false) const
Definition SHAMap.cpp:1175
void setUnbacked()
Definition SHAMap.h:637
boost::intrusive_ptr< SHAMapItem const > const & onlyBelow(SHAMapTreeNode *) const
If there is only one leaf below this node, get its contents.
Definition SHAMap.cpp:527
void gmn_ProcessNodes(MissingNodes &, MissingNodes::StackEntry &node)
SHAMapTreeNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition SHAMap.cpp:296
std::map< uint256, DeltaItem > Delta
Definition SHAMap.h:128
intr_ptr::SharedPtr< SHAMapTreeNode > root_
Definition SHAMap.h:110
boost::intrusive_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
Definition SHAMap.cpp:616
SHAMapType const type_
Definition SHAMap.h:112
bool isSynching() const
Definition SHAMap.h:613
SHAMapState state_
Definition SHAMap.h:111
Family const & family() const
Definition SHAMap.h:146
Family & f_
Definition SHAMap.h:101
bool getNodeFat(SHAMapNodeID const &wanted, std::vector< std::pair< SHAMapNodeID, Blob > > &data, bool fatLeaves, std::uint32_t depth) const
intr_ptr::SharedPtr< SHAMapTreeNode > finishFetch(SHAMapHash const &hash, std::shared_ptr< NodeObject > const &object) const
Definition SHAMap.cpp:178
bool addGiveItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
Definition SHAMap.cpp:802
SHAMapLeafNode * walkTowardsKey(uint256 const &id, SharedPtrNodeStack *stack=nullptr) const
Walk towards the specified id, returning the node.
Definition SHAMap.cpp:132
SHAMapTreeNode * descend(SHAMapInnerNode *, int branch) const
Definition SHAMap.cpp:318
SHAMapLeafNode const * peekNextItem(uint256 const &id, SharedPtrNodeStack &stack) const
Definition SHAMap.cpp:580
void clearSynching()
Definition SHAMap.h:625
void setImmutable()
Definition SHAMap.h:604
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
void canonicalize(SHAMapHash const &hash, intr_ptr::SharedPtr< SHAMapTreeNode > &) const
Definition SHAMap.cpp:1230
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHAMapSyncFilter *filter)
int walkSubTree(bool doWrite, NodeObjectType t)
Definition SHAMap.cpp:1044
void setLedgerSeq(std::uint32_t lseq)
Definition SHAMap.h:598
const_iterator end() const
Definition SHAMap.h:763
void invariants() const
Definition SHAMap.cpp:1245
void serializeRoot(Serializer &s) const
Serializes the root in a format appropriate for sending over the wire.
bool addItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
Definition SHAMap.cpp:881
const_iterator upper_bound(uint256 const &id) const
Find the first item after the given item.
Definition SHAMap.cpp:639
bool hasInnerNode(SHAMapNodeID const &nodeID, SHAMapHash const &hash) const
Does this map have this inner node?
intr_ptr::SharedPtr< SHAMapTreeNode > writeNode(NodeObjectType t, intr_ptr::SharedPtr< SHAMapTreeNode > node) const
write and canonicalize modified node
Definition SHAMap.cpp:992
void setFull()
Definition SHAMap.h:592
intr_ptr::SharedPtr< SHAMapTreeNode > fetchNodeNT(SHAMapHash const &hash) const
Definition SHAMap.cpp:273
~SHAMap()=default
void gmn_ProcessDeferredReads(MissingNodes &)
std::uint32_t cowid_
ID to distinguish this map for all others we're sharing nodes with.
Definition SHAMap.h:105
SHAMapHash getHash() const
Definition SHAMap.cpp:889
void walkMap(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
SHAMap()=delete
bool walkMapParallel(std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const
void dirtyUp(SharedPtrNodeStack &stack, uint256 const &target, intr_ptr::SharedPtr< SHAMapTreeNode > terminal)
Update hashes up to the root.
Definition SHAMap.cpp:96
bool updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
Definition SHAMap.cpp:901
SHAMapLeafNode const * peekFirstItem(SharedPtrNodeStack &stack) const
Definition SHAMap.cpp:565
bool isValid() const
Definition SHAMap.h:631
std::vector< std::pair< SHAMapNodeID, uint256 > > getMissingNodes(int maxNodes, SHAMapSyncFilter *filter)
Check for nodes in the SHAMap not available.
intr_ptr::SharedPtr< SHAMapTreeNode > fetchNode(SHAMapHash const &hash) const
Definition SHAMap.cpp:285
void visitNodes(std::function< bool(SHAMapTreeNode &)> const &function) const
Visit every node in this SHAMap.
bool hasLeafNode(uint256 const &tag, SHAMapHash const &hash) const
Does this map have this leaf node?
intr_ptr::SharedPtr< SHAMapTreeNode > fetchNodeFromDB(SHAMapHash const &hash) const
Definition SHAMap.cpp:170
SHAMap & operator=(SHAMap const &)=delete
SHAMap(SHAMap const &)=delete
const_iterator begin() const
Definition SHAMap.h:757
intr_ptr::SharedPtr< SHAMapTreeNode > descendNoStore(SHAMapInnerNode &, int branch) const
Definition SHAMap.cpp:351
void setSynching()
Definition SHAMap.h:619
std::uint32_t ledgerSeq_
The sequence of the ledger that this map references, if any.
Definition SHAMap.h:108
bool delItem(uint256 const &id)
Definition SHAMap.cpp:720
bool fetchRoot(SHAMapHash const &hash, SHAMapSyncFilter *filter)
Definition SHAMap.cpp:944
const_iterator lower_bound(uint256 const &id) const
Find the object with the greatest object id smaller than the input id.
Definition SHAMap.cpp:676
void visitDifferences(SHAMap const *have, std::function< bool(SHAMapTreeNode const &)> const &) const
Visit every node in this SHAMap that is not present in the specified SHAMap.
void visitLeaves(std::function< void(boost::intrusive_ptr< SHAMapItem const > const &)> const &) const
Visit every leaf node in this SHAMap.
SHAMapLeafNode * lastBelow(intr_ptr::SharedPtr< SHAMapTreeNode > node, SharedPtrNodeStack &stack, int branch=branchFactor) const
Definition SHAMap.cpp:501
bool walkBranch(SHAMapTreeNode *node, boost::intrusive_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const
std::shared_ptr< SHAMap > snapShot(bool isMutable) const
Definition SHAMap.cpp:90
int flushDirty(NodeObjectType t)
Flush modified nodes to the nodestore and convert them to shared.
Definition SHAMap.cpp:1037
int unshare()
Convert any modified nodes to shared.
Definition SHAMap.cpp:1030
intr_ptr::SharedPtr< SHAMapTreeNode > checkFilter(SHAMapHash const &hash, SHAMapSyncFilter *filter) const
Definition SHAMap.cpp:217
bool deepCompare(SHAMap &other) const
static bool verifyProofPath(uint256 const &rootHash, uint256 const &key, std::vector< Blob > const &path)
Verify the proof path.
SHAMapLeafNode * belowHelper(intr_ptr::SharedPtr< SHAMapTreeNode > node, SharedPtrNodeStack &stack, int branch, std::tuple< int, std::function< bool(int)>, std::function< void(int &)> > const &loopParams) const
Definition SHAMap.cpp:458
SHAMapLeafNode * findKey(uint256 const &id) const
Return nullptr if key not found.
Definition SHAMap.cpp:161
static constexpr unsigned int branchFactor
Number of children each non-leaf node has (the 'radix tree' part of the map)
Definition SHAMap.h:119
std::optional< std::vector< Blob > > getProofPath(uint256 const &key) const
Get the proof path of the key.
SHAMapLeafNode * firstBelow(intr_ptr::SharedPtr< SHAMapTreeNode >, SharedPtrNodeStack &stack, int branch=0) const
Definition SHAMap.cpp:513
A shared intrusive pointer class that supports weak pointers.
An immutable linear range of bytes.
Definition Slice.h:46
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
bool operator!=(Buffer const &lhs, Buffer const &rhs) noexcept
Definition Buffer.h:232
SHAMapState
Describes the current state of a given SHAMap.
Definition SHAMap.h:49
@ Immutable
The map is set in stone and cannot be changed.
@ Invalid
The map is known to not be valid.
@ Synching
The map's hash is fixed but valid nodes may be missing and can be added.
@ Modifying
The map is in flux and objects can be added and removed.
NodeObjectType
The types of node objects.
Definition NodeObject.h:32
@ pending
List will be valid in the future.
constexpr bool operator==(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)
Definition base_uint.h:585
STL namespace.
std::set< SHAMapHash > missingHashes_
Definition SHAMap.h:529
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition SHAMap.h:544
std::condition_variable deferCondVar_
Definition SHAMap.h:555
std::tuple< SHAMapInnerNode *, SHAMapNodeID, int, int, bool > StackEntry
Definition SHAMap.h:537
MissingNodes(int max, SHAMapSyncFilter *filter, int maxDefer, std::uint32_t generation)
Definition SHAMap.h:562
std::uint32_t generation_
Definition SHAMap.h:525
std::vector< std::pair< SHAMapNodeID, uint256 > > missingNodes_
Definition SHAMap.h:528
MissingNodes(MissingNodes const &)=delete
MissingNodes & operator=(MissingNodes const &)=delete
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition SHAMap.h:560
SHAMapSyncFilter * filter_
Definition SHAMap.h:523
std::vector< DeferredNode > finishedReads_
Definition SHAMap.h:556