|
xrpld
|
#include <SHAMap.h>

Classes | |
| struct | MissingNodes |
| class | ConstIterator |
Public Types | |
| using | DeltaItem |
| using | Delta = std::map<uint256, DeltaItem> |
Public Member Functions | |
| SHAMap ()=delete | |
| SHAMap (SHAMap const &)=delete | |
| SHAMap & | operator= (SHAMap const &)=delete |
| SHAMap (SHAMap const &other, bool isMutable) | |
| SHAMap (SHAMapType t, Family &f) | |
| SHAMap (SHAMapType t, uint256 const &hash, Family &f) | |
| ~SHAMap ()=default | |
| Family const & | family () const |
| Family & | family () |
| ConstIterator | begin () const |
| ConstIterator | end () const |
| std::shared_ptr< SHAMap > | snapShot (bool isMutable) const |
| void | setFull () |
| void | setLedgerSeq (std::uint32_t lseq) |
| bool | fetchRoot (SHAMapHash const &hash, SHAMapSyncFilter const *filter) |
| bool | hasItem (uint256 const &id) const |
| Does the tree have an item with the given ID? | |
| bool | delItem (uint256 const &id) |
| bool | addItem (SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item) |
| SHAMapHash | getHash () const |
| bool | updateGiveItem (SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item) |
| bool | addGiveItem (SHAMapNodeType type, boost::intrusive_ptr< SHAMapItem const > item) |
| boost::intrusive_ptr< SHAMapItem const > const & | peekItem (uint256 const &id) const |
| boost::intrusive_ptr< SHAMapItem const > const & | peekItem (uint256 const &id, SHAMapHash &hash) const |
| ConstIterator | upperBound (uint256 const &id) const |
| Find the first item after the given item. | |
| ConstIterator | lowerBound (uint256 const &id) const |
| Find the object with the greatest object id smaller than the input id. | |
| void | visitNodes (std::function< bool(SHAMapTreeNode &)> const &function) const |
| Visit every node in this SHAMap. | |
| 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. | |
| std::vector< std::pair< SHAMapNodeID, uint256 > > | getMissingNodes (int maxNodes, SHAMapSyncFilter const *filter) |
| Check for nodes in the SHAMap not available. | |
| bool | getNodeFat (SHAMapNodeID const &wanted, std::vector< SHAMapNodeData > &data, bool fatLeaves, std::uint32_t depth) const |
| std::optional< std::vector< Blob > > | getProofPath (uint256 const &key) const |
| Get the proof path of the key. | |
| void | serializeRoot (Serializer &s) const |
| Serializes the root in a format appropriate for sending over the wire. | |
| SHAMapAddNode | addRootNode (SHAMapHash const &hash, SHAMapTreeNodePtr rootNode, SHAMapSyncFilter const *filter) |
| Add a root node to the SHAMap during synchronization. | |
| SHAMapAddNode | addKnownNode (SHAMapNodeID const &nodeID, SHAMapTreeNodePtr treeNode, SHAMapSyncFilter const *filter) |
| Add a known node at a specific position in the SHAMap during synchronization. | |
| void | setImmutable () |
| bool | isSynching () const |
| void | setSynching () |
| void | clearSynching () |
| bool | isValid () const |
| bool | compare (SHAMap const &otherMap, Delta &differences, int maxCount) const |
| int | unshare () |
| Convert any modified nodes to shared. | |
| int | flushDirty (NodeObjectType t) |
| Flush modified nodes to the nodestore and convert them to shared. | |
| void | walkMap (std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const |
| bool | walkMapParallel (std::vector< SHAMapMissingNode > &missingNodes, int maxMissing) const |
| bool | deepCompare (SHAMap &other) const |
| void | setUnbacked () |
| void | dump (bool withHashes=false) const |
| void | invariants () const |
Static Public Member Functions | |
| static bool | verifyProofPath (uint256 const &rootHash, uint256 const &key, std::vector< Blob > const &path) |
| Verify the proof path. | |
Static Public Attributes | |
| static constexpr unsigned int | kBranchFactor = SHAMapInnerNode::kBranchFactor |
| Number of children each non-leaf node has (the 'radix tree' part of the map). | |
| static constexpr unsigned int | kLeafDepth = 64 |
| The depth of the hash map: data is only present in the leaves. | |
Private Types | |
| using | SharedPtrNodeStack = std::stack<std::pair<SHAMapTreeNodePtr, SHAMapNodeID>> |
| using | DeltaRef |
| using | descendCallback = std::function<void(SHAMapTreeNodePtr, SHAMapHash const&)> |
Private Member Functions | |
| SHAMapTreeNodePtr | cacheLookup (SHAMapHash const &hash) const |
| void | canonicalize (SHAMapHash const &hash, SHAMapTreeNodePtr &) const |
| SHAMapTreeNodePtr | fetchNodeFromDB (SHAMapHash const &hash) const |
| SHAMapTreeNodePtr | fetchNodeNT (SHAMapHash const &hash) const |
| SHAMapTreeNodePtr | fetchNodeNT (SHAMapHash const &hash, SHAMapSyncFilter const *filter) const |
| SHAMapTreeNodePtr | fetchNode (SHAMapHash const &hash) const |
| SHAMapTreeNodePtr | checkFilter (SHAMapHash const &hash, SHAMapSyncFilter const *filter) const |
| void | dirtyUp (SharedPtrNodeStack &stack, uint256 const &target, SHAMapTreeNodePtr terminal) |
| Update hashes up to the root. | |
| SHAMapLeafNode * | walkTowardsKey (uint256 const &id, SharedPtrNodeStack *stack=nullptr) const |
| Walk towards the specified id, returning the node. | |
| SHAMapLeafNode * | findKey (uint256 const &id) const |
| Return nullptr if key not found. | |
| template<class Node> | |
| intr_ptr::SharedPtr< Node > | unshareNode (intr_ptr::SharedPtr< Node >, SHAMapNodeID const &nodeID) |
| Unshare the node, allowing it to be modified. | |
| template<class Node> | |
| intr_ptr::SharedPtr< Node > | preFlushNode (intr_ptr::SharedPtr< Node > node) const |
| prepare a node to be modified before flushing | |
| SHAMapTreeNodePtr | writeNode (NodeObjectType t, SHAMapTreeNodePtr node) const |
| write and canonicalize modified node | |
| SHAMapLeafNode * | firstBelow (SHAMapTreeNodePtr node, SharedPtrNodeStack &stack, int branch=0) const |
| SHAMapLeafNode * | lastBelow (SHAMapTreeNodePtr node, SharedPtrNodeStack &stack, int branch=kBranchFactor) const |
| SHAMapLeafNode * | belowHelper (SHAMapTreeNodePtr node, SharedPtrNodeStack &stack, int branch, std::tuple< int, std::function< bool(int)>, std::function< void(int &)> > const &loopParams) const |
| SHAMapTreeNode * | descend (SHAMapInnerNode *, int branch) const |
| SHAMapTreeNode * | descendThrow (SHAMapInnerNode *, int branch) const |
| SHAMapTreeNodePtr | descend (SHAMapInnerNode &, int branch) const |
| SHAMapTreeNodePtr | descendThrow (SHAMapInnerNode &, int branch) const |
| SHAMapTreeNode * | descendAsync (SHAMapInnerNode *parent, int branch, SHAMapSyncFilter const *filter, bool &pending, descendCallback &&) const |
| std::pair< SHAMapTreeNode *, SHAMapNodeID > | descend (SHAMapInnerNode *parent, SHAMapNodeID const &parentID, int branch, SHAMapSyncFilter const *filter) const |
| SHAMapTreeNodePtr | descendNoStore (SHAMapInnerNode &, int branch) const |
| boost::intrusive_ptr< SHAMapItem const > const & | onlyBelow (SHAMapTreeNode *) const |
| If there is only one leaf below this node, get its contents. | |
| bool | hasInnerNode (SHAMapNodeID const &nodeID, SHAMapHash const &hash) const |
| Does this map have this inner node? | |
| bool | hasLeafNode (uint256 const &tag, SHAMapHash const &hash) const |
| Does this map have this leaf node? | |
| SHAMapLeafNode const * | peekFirstItem (SharedPtrNodeStack &stack) const |
| SHAMapLeafNode const * | peekNextItem (uint256 const &id, SharedPtrNodeStack &stack) const |
| bool | walkBranch (SHAMapTreeNode *node, boost::intrusive_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const |
| int | walkSubTree (bool doWrite, NodeObjectType t) |
| void | gmnProcessNodes (MissingNodes &, MissingNodes::StackEntry &node) |
| SHAMapTreeNodePtr | finishFetch (SHAMapHash const &hash, std::shared_ptr< NodeObject > const &object) const |
Static Private Member Functions | |
| static void | gmnProcessDeferredReads (MissingNodes &) |
Private Attributes | |
| Family & | f_ |
| beast::Journal | journal_ |
| std::uint32_t | cowid_ = 1 |
| ID to distinguish this map for all others we're sharing nodes with. | |
| std::uint32_t | ledgerSeq_ = 0 |
| The sequence of the ledger that this map references, if any. | |
| SHAMapTreeNodePtr | root_ |
| SHAMapState | state_ |
| SHAMapType const | type_ |
| bool | backed_ = true |
| bool | full_ = false |
| using xrpl::SHAMap::DeltaItem |
|
private |
|
private |
|
private |
|
delete |
|
delete |
| xrpl::SHAMap::SHAMap | ( | SHAMap const & | other, |
| bool | isMutable ) |
Definition at line 76 of file libxrpl/shamap/SHAMap.cpp.
| xrpl::SHAMap::SHAMap | ( | SHAMapType | t, |
| Family & | f ) |
Definition at line 60 of file libxrpl/shamap/SHAMap.cpp.
| xrpl::SHAMap::SHAMap | ( | SHAMapType | t, |
| uint256 const & | hash, | ||
| Family & | f ) |
Definition at line 70 of file libxrpl/shamap/SHAMap.cpp.
|
default |
| SHAMap::ConstIterator xrpl::SHAMap::begin | ( | ) | const |
| SHAMap::ConstIterator xrpl::SHAMap::end | ( | ) | const |
| std::shared_ptr< SHAMap > xrpl::SHAMap::snapShot | ( | bool | isMutable | ) | const |
Definition at line 94 of file libxrpl/shamap/SHAMap.cpp.
| void xrpl::SHAMap::setLedgerSeq | ( | std::uint32_t | lseq | ) |
| bool xrpl::SHAMap::fetchRoot | ( | SHAMapHash const & | hash, |
| SHAMapSyncFilter const * | filter ) |
Definition at line 889 of file libxrpl/shamap/SHAMap.cpp.
| bool xrpl::SHAMap::hasItem | ( | uint256 const & | id | ) | const |
Does the tree have an item with the given ID?
Definition at line 672 of file libxrpl/shamap/SHAMap.cpp.
| bool xrpl::SHAMap::delItem | ( | uint256 const & | id | ) |
Definition at line 678 of file libxrpl/shamap/SHAMap.cpp.
| bool xrpl::SHAMap::addItem | ( | SHAMapNodeType | type, |
| boost::intrusive_ptr< SHAMapItem const > | item ) |
Definition at line 830 of file libxrpl/shamap/SHAMap.cpp.
| SHAMapHash xrpl::SHAMap::getHash | ( | ) | const |
Definition at line 836 of file libxrpl/shamap/SHAMap.cpp.
| bool xrpl::SHAMap::updateGiveItem | ( | SHAMapNodeType | type, |
| boost::intrusive_ptr< SHAMapItem const > | item ) |
Definition at line 849 of file libxrpl/shamap/SHAMap.cpp.
| bool xrpl::SHAMap::addGiveItem | ( | SHAMapNodeType | type, |
| boost::intrusive_ptr< SHAMapItem const > | item ) |
Definition at line 761 of file libxrpl/shamap/SHAMap.cpp.
| boost::intrusive_ptr< SHAMapItem const > const & xrpl::SHAMap::peekItem | ( | uint256 const & | id | ) | const |
Definition at line 581 of file libxrpl/shamap/SHAMap.cpp.
| boost::intrusive_ptr< SHAMapItem const > const & xrpl::SHAMap::peekItem | ( | uint256 const & | id, |
| SHAMapHash & | hash ) const |
Definition at line 592 of file libxrpl/shamap/SHAMap.cpp.
| SHAMap::ConstIterator xrpl::SHAMap::upperBound | ( | uint256 const & | id | ) | const |
Find the first item after the given item.
| id | the identifier of the item. |
Definition at line 604 of file libxrpl/shamap/SHAMap.cpp.
| SHAMap::ConstIterator xrpl::SHAMap::lowerBound | ( | uint256 const & | id | ) | const |
Find the object with the greatest object id smaller than the input id.
| id | the identifier of the item. |
Definition at line 637 of file libxrpl/shamap/SHAMap.cpp.
| void xrpl::SHAMap::visitNodes | ( | std::function< bool(SHAMapTreeNode &)> const & | function | ) | const |
Visit every node in this SHAMap.
| function | called with every node visited. If function returns false, visitNodes exits. |
Definition at line 47 of file libxrpl/shamap/SHAMapSync.cpp.
| void xrpl::SHAMap::visitDifferences | ( | SHAMap const * | have, |
| std::function< bool(SHAMapTreeNode const &)> const & | function ) const |
Visit every node in this SHAMap that is not present in the specified SHAMap.
| function | called with every node visited. If function returns false, visitDifferences exits. |
Definition at line 109 of file libxrpl/shamap/SHAMapSync.cpp.
| void xrpl::SHAMap::visitLeaves | ( | std::function< void(boost::intrusive_ptr< SHAMapItem const > const &)> const & | ) | const |
Visit every leaf node in this SHAMap.
| function | called with every non inner node visited. |
Definition at line 35 of file libxrpl/shamap/SHAMapSync.cpp.
| std::vector< std::pair< SHAMapNodeID, uint256 > > xrpl::SHAMap::getMissingNodes | ( | int | max, |
| SHAMapSyncFilter const * | filter ) |
Check for nodes in the SHAMap not available.
Get a list of node IDs and hashes for nodes that are part of this SHAMap but not available locally.
Traverse the SHAMap efficiently, maximizing I/O concurrency, to discover nodes referenced in the SHAMap but not available locally.
| maxNodes | The maximum number of found nodes to return |
| filter | The filter to use when retrieving nodes |
| return | The nodes known to be missing |
The filter can hold alternate sources of nodes that are not permanently stored locally
Definition at line 306 of file libxrpl/shamap/SHAMapSync.cpp.
|
nodiscard |
Definition at line 412 of file libxrpl/shamap/SHAMapSync.cpp.
| std::optional< std::vector< Blob > > xrpl::SHAMap::getProofPath | ( | uint256 const & | key | ) | const |
Get the proof path of the key.
The proof path is every node on the path from leaf to root. Sibling hashes are stored in the parent nodes.
| key | key of the leaf |
Definition at line 771 of file libxrpl/shamap/SHAMapSync.cpp.
|
static |
Verify the proof path.
| rootHash | root hash of the map |
| key | key of the leaf |
| path | the proof path |
Definition at line 804 of file libxrpl/shamap/SHAMapSync.cpp.
| void xrpl::SHAMap::serializeRoot | ( | Serializer & | s | ) | const |
Serializes the root in a format appropriate for sending over the wire.
Definition at line 502 of file libxrpl/shamap/SHAMapSync.cpp.
| SHAMapAddNode xrpl::SHAMap::addRootNode | ( | SHAMapHash const & | hash, |
| SHAMapTreeNodePtr | rootNode, | ||
| SHAMapSyncFilter const * | filter ) |
Add a root node to the SHAMap during synchronization.
This function is used when receiving the root node of a SHAMap from a peer during ledger synchronization. The node must already have been deserialized.
| hash | The expected hash of the root node. |
| rootNode | A deserialized root node to add. |
| filter | Optional sync filter to track received nodes. |
Definition at line 508 of file libxrpl/shamap/SHAMapSync.cpp.
| SHAMapAddNode xrpl::SHAMap::addKnownNode | ( | SHAMapNodeID const & | nodeID, |
| SHAMapTreeNodePtr | treeNode, | ||
| SHAMapSyncFilter const * | filter ) |
Add a known node at a specific position in the SHAMap during synchronization.
This function is used when receiving nodes from peers during ledger synchronization. The node is inserted at the position specified by nodeID. The node must already have been deserialized.
| nodeID | The position in the tree where this node belongs. |
| treeNode | A deserialized tree node to add. |
| filter | Optional sync filter to track received nodes. |
Definition at line 551 of file libxrpl/shamap/SHAMapSync.cpp.
Definition at line 130 of file SHAMapDelta.cpp.
| int xrpl::SHAMap::unshare | ( | ) |
Convert any modified nodes to shared.
Definition at line 970 of file libxrpl/shamap/SHAMap.cpp.
| int xrpl::SHAMap::flushDirty | ( | NodeObjectType | t | ) |
Flush modified nodes to the nodestore and convert them to shared.
Definition at line 977 of file libxrpl/shamap/SHAMap.cpp.
| void xrpl::SHAMap::walkMap | ( | std::vector< SHAMapMissingNode > & | missingNodes, |
| int | maxMissing ) const |
Definition at line 245 of file SHAMapDelta.cpp.
| bool xrpl::SHAMap::walkMapParallel | ( | std::vector< SHAMapMissingNode > & | missingNodes, |
| int | maxMissing ) const |
Definition at line 283 of file SHAMapDelta.cpp.
| bool xrpl::SHAMap::deepCompare | ( | SHAMap & | other | ) | const |
Definition at line 649 of file libxrpl/shamap/SHAMapSync.cpp.
| void xrpl::SHAMap::dump | ( | bool | withHashes = false | ) | const |
Definition at line 1107 of file libxrpl/shamap/SHAMap.cpp.
| void xrpl::SHAMap::invariants | ( | ) | const |
Definition at line 1172 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 1154 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 1162 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 166 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 258 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 235 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 270 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 209 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Update hashes up to the root.
Definition at line 100 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Walk towards the specified id, returning the node.
Caller must check if the return is nullptr, and if not, if the node->peekItem()->key() == id
Definition at line 130 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Return nullptr if key not found.
Definition at line 157 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Unshare the node, allowing it to be modified.
Definition at line 417 of file libxrpl/shamap/SHAMap.cpp.
|
private |
prepare a node to be modified before flushing
Definition at line 954 of file libxrpl/shamap/SHAMap.cpp.
|
private |
write and canonicalize modified node
Replace a node with a shareable node.
This code handles two cases:
1) An unshared, unshareable node needs to be made shareable so immutable SHAMap's can have references to it. 2) An unshareable node is shared. This happens when you make a mutable snapshot of a mutable SHAMap.
Definition at line 936 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 488 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 479 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 433 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 303 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 281 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 318 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 292 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 374 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 344 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 335 of file libxrpl/shamap/SHAMap.cpp.
|
private |
If there is only one leaf below this node, get its contents.
Definition at line 499 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Does this map have this inner node?
Definition at line 721 of file libxrpl/shamap/SHAMapSync.cpp.
|
private |
Does this map have this leaf node?
Definition at line 744 of file libxrpl/shamap/SHAMapSync.cpp.
|
private |
Definition at line 538 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 552 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 34 of file SHAMapDelta.cpp.
|
private |
Definition at line 984 of file libxrpl/shamap/SHAMap.cpp.
|
private |
Definition at line 175 of file libxrpl/shamap/SHAMapSync.cpp.
|
staticprivate |
Definition at line 259 of file libxrpl/shamap/SHAMapSync.cpp.
|
private |
Definition at line 174 of file libxrpl/shamap/SHAMap.cpp.
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
staticconstexpr |