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 <xrpl/basics/IntrusivePointer.h>
24#include <xrpl/basics/UnorderedContainers.h>
25#include <xrpl/beast/utility/Journal.h>
26#include <xrpl/beast/utility/instrumentation.h>
27#include <xrpl/nodestore/Database.h>
28#include <xrpl/nodestore/NodeObject.h>
29#include <xrpl/shamap/Family.h>
30#include <xrpl/shamap/SHAMapAddNode.h>
31#include <xrpl/shamap/SHAMapInnerNode.h>
32#include <xrpl/shamap/SHAMapItem.h>
33#include <xrpl/shamap/SHAMapLeafNode.h>
34#include <xrpl/shamap/SHAMapMissingNode.h>
35#include <xrpl/shamap/SHAMapTreeNode.h>
36
37#include <set>
38#include <stack>
39#include <vector>
40
41namespace ripple {
42
43class SHAMapNodeID;
44class SHAMapSyncFilter;
45
47enum class SHAMapState {
52 Modifying = 0,
53
58 Immutable = 1,
59
64 Synching = 2,
65
70 Invalid = 3,
71};
72
96class SHAMap
97{
98private:
101
104
107
111 bool backed_ = true; // Map is backed by the database
112 mutable bool full_ = false; // Map is believed complete in database
113
114public:
117 static inline constexpr unsigned int branchFactor =
119
121 static inline constexpr unsigned int leafDepth = 64;
122
124 boost::intrusive_ptr<SHAMapItem const>,
125 boost::intrusive_ptr<SHAMapItem const>>;
127
128 SHAMap() = delete;
129 SHAMap(SHAMap const&) = delete;
130 SHAMap&
131 operator=(SHAMap const&) = delete;
132
133 // Take a snapshot of the given map:
134 SHAMap(SHAMap const& other, bool isMutable);
135
136 // build new map
137 SHAMap(SHAMapType t, Family& f);
138
139 SHAMap(SHAMapType t, uint256 const& hash, Family& f);
140
141 ~SHAMap() = default;
142
143 Family const&
144 family() const
145 {
146 return f_;
147 }
148
149 Family&
151 {
152 return f_;
153 }
154
155 //--------------------------------------------------------------------------
156
161 class const_iterator;
162
164 begin() const;
166 end() const;
167
168 //--------------------------------------------------------------------------
169
170 // Returns a new map that's a snapshot of this one.
171 // Handles copy on write for mutable snapshots.
173 snapShot(bool isMutable) const;
174
175 /* Mark this SHAMap as "should be full", indicating
176 that the local server wants all the corresponding nodes
177 in durable storage.
178 */
179 void
180 setFull();
181
182 void
184
185 bool
186 fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
187
188 // normal hash access functions
189
191 bool
192 hasItem(uint256 const& id) const;
193
194 bool
195 delItem(uint256 const& id);
196
197 bool
198 addItem(SHAMapNodeType type, boost::intrusive_ptr<SHAMapItem const> item);
199
201 getHash() const;
202
203 // save a copy if you have a temporary anyway
204 bool
206 SHAMapNodeType type,
207 boost::intrusive_ptr<SHAMapItem const> item);
208
209 bool
211 SHAMapNodeType type,
212 boost::intrusive_ptr<SHAMapItem const> item);
213
214 // Save a copy if you need to extend the life
215 // of the SHAMapItem beyond this SHAMap
216 boost::intrusive_ptr<SHAMapItem const> const&
217 peekItem(uint256 const& id) const;
218 boost::intrusive_ptr<SHAMapItem const> const&
219 peekItem(uint256 const& id, SHAMapHash& hash) const;
220
221 // traverse functions
229 upper_bound(uint256 const& id) const;
230
238 lower_bound(uint256 const& id) const;
239
245 void
246 visitNodes(std::function<bool(SHAMapTreeNode&)> const& function) const;
247
254 void
256 SHAMap const* have,
257 std::function<bool(SHAMapTreeNode const&)> const&) const;
258
263 void
266 void(boost::intrusive_ptr<SHAMapItem const> const&)> const&) const;
267
268 // comparison/sync functions
269
281 getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
282
283 bool
285 SHAMapNodeID const& wanted,
287 bool fatLeaves,
288 std::uint32_t depth) const;
289
297 getProofPath(uint256 const& key) const;
298
306 static bool
308 uint256 const& rootHash,
309 uint256 const& key,
310 std::vector<Blob> const& path);
311
313 void
314 serializeRoot(Serializer& s) const;
315
318 SHAMapHash const& hash,
319 Slice const& rootNode,
320 SHAMapSyncFilter* filter);
323 SHAMapNodeID const& nodeID,
324 Slice const& rawNode,
325 SHAMapSyncFilter* filter);
326
327 // status functions
328 void
329 setImmutable();
330 bool
331 isSynching() const;
332 void
333 setSynching();
334 void
336 bool
337 isValid() const;
338
339 // caution: otherMap must be accessed only by this function
340 // return value: true=successfully completed, false=too different
341 bool
342 compare(SHAMap const& otherMap, Delta& differences, int maxCount) const;
343
345 int
346 unshare();
347
349 int
351
352 void
353 walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing) const;
354 bool
356 std::vector<SHAMapMissingNode>& missingNodes,
357 int maxMissing) const;
358 bool
359 deepCompare(SHAMap& other) const; // Intended for debug/test only
360
361 void
362 setUnbacked();
363
364 void
365 dump(bool withHashes = false) const;
366 void
367 invariants() const;
368
369private:
373 boost::intrusive_ptr<SHAMapItem const>,
374 boost::intrusive_ptr<SHAMapItem const>>;
375
376 // tree node cache operations
378 cacheLookup(SHAMapHash const& hash) const;
379
380 void
382 const;
383
384 // database operations
386 fetchNodeFromDB(SHAMapHash const& hash) const;
388 fetchNodeNT(SHAMapHash const& hash) const;
390 fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
392 fetchNode(SHAMapHash const& hash) const;
394 checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
395
397 void
398 dirtyUp(
399 SharedPtrNodeStack& stack,
400 uint256 const& target,
402
407 walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack = nullptr)
408 const;
411 findKey(uint256 const& id) const;
412
414 template <class Node>
417
419 template <class Node>
422
426
427 // returns the first item at or below this node
431 SharedPtrNodeStack& stack,
432 int branch = 0) const;
433
434 // returns the last item at or below this node
436 lastBelow(
438 SharedPtrNodeStack& stack,
439 int branch = branchFactor) const;
440
441 // helper function for firstBelow and lastBelow
445 SharedPtrNodeStack& stack,
446 int branch,
448 int,
449 std::function<bool(int)>,
450 std::function<void(int&)>> const& loopParams) const;
451
452 // Simple descent
453 // Get a child of the specified node
455 descend(SHAMapInnerNode*, int branch) const;
457 descendThrow(SHAMapInnerNode*, int branch) const;
459 descend(SHAMapInnerNode&, int branch) const;
461 descendThrow(SHAMapInnerNode&, int branch) const;
462
463 // Descend with filter
464 // If pending, callback is called as if it called fetchNodeNT
469 SHAMapInnerNode* parent,
470 int branch,
471 SHAMapSyncFilter* filter,
472 bool& pending,
473 descendCallback&&) const;
474
476 descend(
477 SHAMapInnerNode* parent,
478 SHAMapNodeID const& parentID,
479 int branch,
480 SHAMapSyncFilter* filter) const;
481
482 // Non-storing
483 // Does not hook the returned node to its parent
485 descendNoStore(SHAMapInnerNode&, int branch) const;
486
488 boost::intrusive_ptr<SHAMapItem const> const&
490
491 bool
492 hasInnerNode(SHAMapNodeID const& nodeID, SHAMapHash const& hash) const;
493 bool
494 hasLeafNode(uint256 const& tag, SHAMapHash const& hash) const;
495
496 SHAMapLeafNode const*
497 peekFirstItem(SharedPtrNodeStack& stack) const;
498 SHAMapLeafNode const*
499 peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const;
500 bool
502 SHAMapTreeNode* node,
503 boost::intrusive_ptr<SHAMapItem const> const& otherMapItem,
504 bool isFirstMap,
505 Delta& differences,
506 int& maxCount) const;
507 int
508 walkSubTree(bool doWrite, NodeObjectType t);
509
510 // Structure to track information about call to
511 // getMissingNodes while it's in progress
513 {
514 MissingNodes() = delete;
515 MissingNodes(MissingNodes const&) = delete;
517 operator=(MissingNodes const&) = delete;
518
519 // basic parameters
520 int max_;
522 int const maxDefer_;
524
525 // nodes we have discovered to be missing
528
529 // nodes we are in the process of traversing
531 SHAMapInnerNode*, // pointer to the node
532 SHAMapNodeID, // the node's ID
533 int, // while child we check first
534 int, // which child we check next
535 bool>; // whether we've found any missing children yet
536
537 // We explicitly choose to specify the use of std::deque here, because
538 // we need to ensure that pointers and/or references to existing
539 // elements will not be invalidated during the course of element
540 // insertion and removal. Containers that do not offer this guarantee,
541 // such as std::vector, can't be used here.
543
544 // nodes we may have acquired from deferred reads
546 SHAMapInnerNode*, // parent node
547 SHAMapNodeID, // parent node ID
548 int, // branch
550
555
556 // nodes we need to resume after we get their children from deferred
557 // reads
559
561 int max,
562 SHAMapSyncFilter* filter,
563 int maxDefer,
564 std::uint32_t generation)
565 : max_(max)
566 , filter_(filter)
567 , maxDefer_(maxDefer)
568 , generation_(generation)
569 , deferred_(0)
570 {
571 missingNodes_.reserve(max);
572 finishedReads_.reserve(maxDefer);
573 }
574 };
575
576 // getMissingNodes helper functions
577 void
578 gmn_ProcessNodes(MissingNodes&, MissingNodes::StackEntry& node);
579 void
580 gmn_ProcessDeferredReads(MissingNodes&);
581
582 // fetch from DB helper function
585 SHAMapHash const& hash,
586 std::shared_ptr<NodeObject> const& object) const;
587};
588
589inline void
591{
592 full_ = true;
593}
594
595inline void
600
601inline void
603{
604 XRPL_ASSERT(
606 "ripple::SHAMap::setImmutable : state is valid");
608}
609
610inline bool
612{
614}
615
616inline void
621
622inline void
627
628inline bool
630{
632}
633
634inline void
636{
637 backed_ = false;
638}
639
640//------------------------------------------------------------------------------
641
643{
644public:
648 using reference = value_type const&;
649 using pointer = value_type const*;
650
651private:
653 SHAMap const* map_ = nullptr;
654 pointer item_ = nullptr;
655
656public:
657 const_iterator() = delete;
658
659 const_iterator(const_iterator const& other) = default;
661 operator=(const_iterator const& other) = default;
662
663 ~const_iterator() = default;
664
666 operator*() const;
667 pointer
668 operator->() const;
669
671 operator++();
673 operator++(int);
674
675private:
676 explicit const_iterator(SHAMap const* map);
678 const_iterator(SHAMap const* map, pointer item, SharedPtrNodeStack&& stack);
679
680 friend bool
681 operator==(const_iterator const& x, const_iterator const& y);
682 friend class SHAMap;
683};
684
685inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map)
686{
687 XRPL_ASSERT(
688 map_,
689 "ripple::SHAMap::const_iterator::const_iterator : non-null input");
690
691 if (auto temp = map_->peekFirstItem(stack_))
692 item_ = temp->peekItem().get();
693}
694
696 : map_(map)
697{
698}
699
701 SHAMap const* map,
702 pointer item,
703 SharedPtrNodeStack&& stack)
704 : stack_(std::move(stack)), map_(map), item_(item)
705{
706}
707
710{
711 return *item_;
712}
713
716{
717 return item_;
718}
719
722{
723 if (auto temp = map_->peekNextItem(item_->key(), stack_))
724 item_ = temp->peekItem().get();
725 else
726 item_ = nullptr;
727 return *this;
728}
729
732{
733 auto tmp = *this;
734 ++(*this);
735 return tmp;
736}
737
738inline bool
740{
741 XRPL_ASSERT(
742 x.map_ == y.map_,
743 "ripple::operator==(SHAMap::const_iterator, SHAMap::const_iterator) : "
744 "inputs map do match");
745 return x.item_ == y.item_;
746}
747
748inline bool
750{
751 return !(x == y);
752}
753
754inline SHAMap::const_iterator
756{
757 return const_iterator(this);
758}
759
762{
763 return const_iterator(this, nullptr);
764}
765
766} // namespace ripple
767
768#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:649
SharedPtrNodeStack stack_
Definition SHAMap.h:652
const_iterator(const_iterator const &other)=default
const_iterator & operator++()
Definition SHAMap.h:721
reference operator*() const
Definition SHAMap.h:709
value_type const & reference
Definition SHAMap.h:648
friend bool operator==(const_iterator const &x, const_iterator const &y)
Definition SHAMap.h:739
const_iterator & operator=(const_iterator const &other)=default
pointer operator->() const
Definition SHAMap.h:715
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition SHAMap.h:97
intr_ptr::SharedPtr< Node > preFlushNode(intr_ptr::SharedPtr< Node > node) const
prepare a node to be modified before flushing
Definition SHAMap.cpp:1016
Family & family()
Definition SHAMap.h:150
SHAMapTreeNode * descendAsync(SHAMapInnerNode *parent, int branch, SHAMapSyncFilter *filter, bool &pending, descendCallback &&) const
Definition SHAMap.cpp:393
bool hasItem(uint256 const &id) const
Does the tree have an item with the given ID?
Definition SHAMap.cpp:715
intr_ptr::SharedPtr< SHAMapTreeNode > cacheLookup(SHAMapHash const &hash) const
Definition SHAMap.cpp:1223
intr_ptr::SharedPtr< Node > unshareNode(intr_ptr::SharedPtr< Node >, SHAMapNodeID const &nodeID)
Unshare the node, allowing it to be modified.
Definition SHAMap.cpp:437
beast::Journal journal_
Definition SHAMap.h:100
static constexpr unsigned int leafDepth
The depth of the hash map: data is only present in the leaves.
Definition SHAMap.h:121
void dump(bool withHashes=false) const
Definition SHAMap.cpp:1178
void setUnbacked()
Definition SHAMap.h:635
boost::intrusive_ptr< SHAMapItem const > const & onlyBelow(SHAMapTreeNode *) const
If there is only one leaf below this node, get its contents.
Definition SHAMap.cpp:526
void gmn_ProcessNodes(MissingNodes &, MissingNodes::StackEntry &node)
SHAMapTreeNode * descendThrow(SHAMapInnerNode *, int branch) const
Definition SHAMap.cpp:295
std::map< uint256, DeltaItem > Delta
Definition SHAMap.h:126
intr_ptr::SharedPtr< SHAMapTreeNode > root_
Definition SHAMap.h:108
boost::intrusive_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
Definition SHAMap.cpp:617
SHAMapType const type_
Definition SHAMap.h:110
bool isSynching() const
Definition SHAMap.h:611
SHAMapState state_
Definition SHAMap.h:109
Family const & family() const
Definition SHAMap.h:144
Family & f_
Definition SHAMap.h:99
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:177
bool addGiveItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
Definition SHAMap.cpp:803
SHAMapLeafNode * walkTowardsKey(uint256 const &id, SharedPtrNodeStack *stack=nullptr) const
Walk towards the specified id, returning the node.
Definition SHAMap.cpp:131
SHAMapTreeNode * descend(SHAMapInnerNode *, int branch) const
Definition SHAMap.cpp:317
SHAMapLeafNode const * peekNextItem(uint256 const &id, SharedPtrNodeStack &stack) const
Definition SHAMap.cpp:581
void clearSynching()
Definition SHAMap.h:623
void setImmutable()
Definition SHAMap.h:602
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, Slice const &rawNode, SHAMapSyncFilter *filter)
void canonicalize(SHAMapHash const &hash, intr_ptr::SharedPtr< SHAMapTreeNode > &) const
Definition SHAMap.cpp:1233
SHAMapAddNode addRootNode(SHAMapHash const &hash, Slice const &rootNode, SHAMapSyncFilter *filter)
int walkSubTree(bool doWrite, NodeObjectType t)
Definition SHAMap.cpp:1047
void setLedgerSeq(std::uint32_t lseq)
Definition SHAMap.h:596
const_iterator end() const
Definition SHAMap.h:761
void invariants() const
Definition SHAMap.cpp:1248
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:882
const_iterator upper_bound(uint256 const &id) const
Find the first item after the given item.
Definition SHAMap.cpp:640
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:995
void setFull()
Definition SHAMap.h:590
intr_ptr::SharedPtr< SHAMapTreeNode > fetchNodeNT(SHAMapHash const &hash) const
Definition SHAMap.cpp:272
~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:103
SHAMapHash getHash() const
Definition SHAMap.cpp:890
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:95
bool updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item)
Definition SHAMap.cpp:902
SHAMapLeafNode const * peekFirstItem(SharedPtrNodeStack &stack) const
Definition SHAMap.cpp:566
bool isValid() const
Definition SHAMap.h:629
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:284
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:169
SHAMap & operator=(SHAMap const &)=delete
SHAMap(SHAMap const &)=delete
const_iterator begin() const
Definition SHAMap.h:755
intr_ptr::SharedPtr< SHAMapTreeNode > descendNoStore(SHAMapInnerNode &, int branch) const
Definition SHAMap.cpp:350
void setSynching()
Definition SHAMap.h:617
std::uint32_t ledgerSeq_
The sequence of the ledger that this map references, if any.
Definition SHAMap.h:106
bool delItem(uint256 const &id)
Definition SHAMap.cpp:721
bool fetchRoot(SHAMapHash const &hash, SHAMapSyncFilter *filter)
Definition SHAMap.cpp:947
const_iterator lower_bound(uint256 const &id) const
Find the object with the greatest object id smaller than the input id.
Definition SHAMap.cpp:677
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:500
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:89
int flushDirty(NodeObjectType t)
Flush modified nodes to the nodestore and convert them to shared.
Definition SHAMap.cpp:1040
int unshare()
Convert any modified nodes to shared.
Definition SHAMap.cpp:1033
intr_ptr::SharedPtr< SHAMapTreeNode > checkFilter(SHAMapHash const &hash, SHAMapSyncFilter *filter) const
Definition SHAMap.cpp:216
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:457
SHAMapLeafNode * findKey(uint256 const &id) const
Return nullptr if key not found.
Definition SHAMap.cpp:160
static constexpr unsigned int branchFactor
Number of children each non-leaf node has (the 'radix tree' part of the map)
Definition SHAMap.h:117
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:512
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:47
@ 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:527
std::stack< StackEntry, std::deque< StackEntry > > stack_
Definition SHAMap.h:542
std::condition_variable deferCondVar_
Definition SHAMap.h:553
std::tuple< SHAMapInnerNode *, SHAMapNodeID, int, int, bool > StackEntry
Definition SHAMap.h:535
MissingNodes(int max, SHAMapSyncFilter *filter, int maxDefer, std::uint32_t generation)
Definition SHAMap.h:560
std::uint32_t generation_
Definition SHAMap.h:523
std::vector< std::pair< SHAMapNodeID, uint256 > > missingNodes_
Definition SHAMap.h:526
MissingNodes(MissingNodes const &)=delete
MissingNodes & operator=(MissingNodes const &)=delete
std::map< SHAMapInnerNode *, SHAMapNodeID > resumes_
Definition SHAMap.h:558
SHAMapSyncFilter * filter_
Definition SHAMap.h:521
std::vector< DeferredNode > finishedReads_
Definition SHAMap.h:554