| 
    rippled
    
   | 
 
#include <SHAMapInnerNode.h>


Public Member Functions | |
| SHAMapInnerNode (std::uint32_t cowid, std::uint8_t numAllocatedChildren=2) | |
| SHAMapInnerNode (SHAMapInnerNode const &)=delete | |
| SHAMapInnerNode & | operator= (SHAMapInnerNode const &)=delete | 
| ~SHAMapInnerNode () | |
| void | partialDestructor () override | 
| intr_ptr::SharedPtr< SHAMapTreeNode > | clone (std::uint32_t cowid) const override | 
| Make a copy of this node, setting the owner.   | |
| SHAMapNodeType | getType () const override | 
| Determines the type of node.   | |
| bool | isLeaf () const override | 
| Determines if this is a leaf node.   | |
| bool | isInner () const override | 
| Determines if this is an inner node.   | |
| bool | isEmpty () const | 
| bool | isEmptyBranch (int m) const | 
| int | getBranchCount () const | 
| SHAMapHash const & | getChildHash (int m) const | 
| void | setChild (int m, intr_ptr::SharedPtr< SHAMapTreeNode > child) | 
| void | shareChild (int m, intr_ptr::SharedPtr< SHAMapTreeNode > const &child) | 
| SHAMapTreeNode * | getChildPointer (int branch) | 
| intr_ptr::SharedPtr< SHAMapTreeNode > | getChild (int branch) | 
| intr_ptr::SharedPtr< SHAMapTreeNode > | canonicalizeChild (int branch, intr_ptr::SharedPtr< SHAMapTreeNode > node) | 
| bool | isFullBelow (std::uint32_t generation) const | 
| void | setFullBelowGen (std::uint32_t gen) | 
| void | updateHash () override | 
| Recalculate the hash of this node.   | |
| void | updateHashDeep () | 
| Recalculate the hash of all children and this node.   | |
| void | serializeForWire (Serializer &) const override | 
| Serialize the node in a format appropriate for sending over the wire.   | |
| void | serializeWithPrefix (Serializer &) const override | 
| Serialize the node in a format appropriate for hashing.   | |
| std::string | getString (SHAMapNodeID const &) const override | 
| void | invariants (bool is_root=false) const override | 
| std::uint32_t | cowid () const | 
| Returns the SHAMap that owns this node.   | |
| void | unshare () | 
| If this node is shared with another map, mark it as no longer shared.   | |
| SHAMapHash const & | getHash () const | 
| Return the hash of this node.   | |
| void | addStrongRef () const noexcept | 
| void | addWeakRef () const noexcept | 
| ReleaseStrongRefAction | releaseStrongRef () const | 
| ReleaseStrongRefAction | addWeakReleaseStrongRef () const | 
| ReleaseWeakRefAction | releaseWeakRef () const | 
| bool | checkoutStrongRefFromWeak () const noexcept | 
| bool | expired () const noexcept | 
| std::size_t | use_count () const noexcept | 
Static Public Member Functions | |
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeFullInner (Slice data, SHAMapHash const &hash, bool hashValid) | 
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeCompressedInner (Slice data) | 
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeFromPrefix (Slice rawNode, SHAMapHash const &hash) | 
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeFromWire (Slice rawNode) | 
Static Public Attributes | |
| static constexpr unsigned int | branchFactor = 16 | 
| Each inner node has 16 children (the 'radix tree' part of the map)   | |
Protected Attributes | |
| SHAMapHash | hash_ | 
| std::uint32_t | cowid_ | 
| Determines the owning SHAMap, if any.   | |
Private Types | |
| using | CountType = std::uint16_t | 
| using | FieldType = std::uint32_t | 
Private Member Functions | |
| void | resizeChildArrays (std::uint8_t toAllocate) | 
Convert arrays stored in hashesAndChildren_ so they can store the requested number of children.   | |
| std::optional< int > | getChildIndex (int i) const | 
Get the child's index inside the hashes or children array (stored in hashesAndChildren_.   | |
| template<class F > | |
| void | iterChildren (F &&f) const | 
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty.   | |
| template<class F > | |
| void | iterNonEmptyChildIndexes (F &&f) const | 
Call the f callback for all non-empty branches.   | |
Static Private Member Functions | |
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeTransaction (Slice data, SHAMapHash const &hash, bool hashValid) | 
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeAccountState (Slice data, SHAMapHash const &hash, bool hashValid) | 
| static intr_ptr::SharedPtr< SHAMapTreeNode > | makeTransactionWithMeta (Slice data, SHAMapHash const &hash, bool hashValid) | 
| static auto & | getCounter () noexcept | 
Private Attributes | |
| TaggedPointer | hashesAndChildren_ | 
Opaque type that contains the hashes array (array of type SHAMapHash) and the children array (array of type intr_ptr::SharedPtr<SHAMapInnerNode>).   | |
| std::uint32_t | fullBelowGen_ = 0 | 
| std::uint16_t | isBranch_ = 0 | 
| std::atomic< std::uint16_t > | lock_ = 0 | 
| A bitlock for the children of this node, with one bit per child.   | |
| std::atomic< FieldType > | refCounts {strongDelta} | 
refCounts consists of four fields that are treated atomically:   | |
Static Private Attributes | |
| static constexpr size_t | StrongCountNumBits = sizeof(CountType) * 8 | 
| static constexpr size_t | WeakCountNumBits = StrongCountNumBits - 2 | 
| static constexpr size_t | FieldTypeBits = sizeof(FieldType) * 8 | 
| static constexpr FieldType | one = 1 | 
| static constexpr FieldType | strongDelta = 1 | 
| Amount to change the strong count when adding or releasing a reference.   | |
| static constexpr FieldType | weakDelta = (one << StrongCountNumBits) | 
| Amount to change the weak count when adding or releasing a reference.   | |
| static constexpr FieldType | partialDestroyStartedMask | 
| Flag that is set when the partialDestroy function has started running (or is about to start running).   | |
| static constexpr FieldType | partialDestroyFinishedMask | 
| Flag that is set when the partialDestroy function has finished running.   | |
| static constexpr FieldType | tagMask | 
Mask that will zero out all the count bits and leave the tag bits unchanged.   | |
| static constexpr FieldType | valueMask = ~tagMask | 
Mask that will zero out the tag bits and leave the count bits unchanged.   | |
| static constexpr FieldType | strongMask | 
| Mask that will zero out everything except the strong count.   | |
| static constexpr FieldType | weakMask | 
| Mask that will zero out everything except the weak count.   | |
Definition at line 34 of file SHAMapInnerNode.h.
      
  | 
  privateinherited | 
Definition at line 120 of file IntrusiveRefCounts.h.
      
  | 
  privateinherited | 
Definition at line 123 of file IntrusiveRefCounts.h.
      
  | 
  explicit | 
Definition at line 32 of file SHAMapInnerNode.cpp.
      
  | 
  delete | 
      
  | 
  default | 
      
  | 
  private | 
Convert arrays stored in hashesAndChildren_ so they can store the requested number of children. 
| toAllocate | allocate space for at least this number of children (must be <= branchFactor) | 
toAllocate. This is due to the implementation of TagPointer, which only supports allocating arrays of 4 different sizes. Definition at line 67 of file SHAMapInnerNode.cpp.
      
  | 
  private | 
Get the child's index inside the hashes or children array (stored in hashesAndChildren_. 
These arrays may or may not be sparse). The optional will be empty is an empty branch is requested and the arrays are sparse.
| i | index of the requested child | 
Definition at line 74 of file SHAMapInnerNode.cpp.
      
  | 
  private | 
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty. 
| f | a one parameter callback function. The parameter is the child's hash. | 
Definition at line 54 of file SHAMapInnerNode.cpp.
      
  | 
  private | 
Call the f callback for all non-empty branches. 
| f | a two parameter callback function. The first parameter is the branch number, the second parameter is the index into the array. For dense formats these are the same, for sparse they may be different. | 
Definition at line 61 of file SHAMapInnerNode.cpp.
      
  | 
  delete | 
      
  | 
  overridevirtual | 
Reimplemented from ripple::SHAMapTreeNode.
Definition at line 42 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Make a copy of this node, setting the owner.
Implements ripple::SHAMapTreeNode.
Definition at line 80 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Determines the type of node.
Implements ripple::SHAMapTreeNode.
Definition at line 117 of file SHAMapInnerNode.h.
      
  | 
  overridevirtual | 
Determines if this is a leaf node.
Implements ripple::SHAMapTreeNode.
Definition at line 123 of file SHAMapInnerNode.h.
      
  | 
  overridevirtual | 
Determines if this is an inner node.
Implements ripple::SHAMapTreeNode.
Definition at line 129 of file SHAMapInnerNode.h.
| bool ripple::SHAMapInnerNode::isEmpty | ( | ) | const | 
Definition at line 195 of file SHAMapInnerNode.h.
| bool ripple::SHAMapInnerNode::isEmptyBranch | ( | int | m | ) | const | 
Definition at line 201 of file SHAMapInnerNode.h.
| int ripple::SHAMapInnerNode::getBranchCount | ( | ) | const | 
Definition at line 207 of file SHAMapInnerNode.h.
| SHAMapHash const & ripple::SHAMapInnerNode::getChildHash | ( | int | m | ) | const | 
Definition at line 380 of file SHAMapInnerNode.cpp.
| void ripple::SHAMapInnerNode::setChild | ( | int | m, | 
| intr_ptr::SharedPtr< SHAMapTreeNode > | child | ||
| ) | 
Definition at line 283 of file SHAMapInnerNode.cpp.
| void ripple::SHAMapInnerNode::shareChild | ( | int | m, | 
| intr_ptr::SharedPtr< SHAMapTreeNode > const & | child | ||
| ) | 
Definition at line 325 of file SHAMapInnerNode.cpp.
| SHAMapTreeNode * ripple::SHAMapInnerNode::getChildPointer | ( | int | branch | ) | 
Definition at line 346 of file SHAMapInnerNode.cpp.
| intr_ptr::SharedPtr< SHAMapTreeNode > ripple::SHAMapInnerNode::getChild | ( | int | branch | ) | 
Definition at line 363 of file SHAMapInnerNode.cpp.
| intr_ptr::SharedPtr< SHAMapTreeNode > ripple::SHAMapInnerNode::canonicalizeChild | ( | int | branch, | 
| intr_ptr::SharedPtr< SHAMapTreeNode > | node | ||
| ) | 
Definition at line 392 of file SHAMapInnerNode.cpp.
| bool ripple::SHAMapInnerNode::isFullBelow | ( | std::uint32_t | generation | ) | const | 
Definition at line 213 of file SHAMapInnerNode.h.
| void ripple::SHAMapInnerNode::setFullBelowGen | ( | std::uint32_t | gen | ) | 
Definition at line 219 of file SHAMapInnerNode.h.
      
  | 
  overridevirtual | 
Recalculate the hash of this node.
Implements ripple::SHAMapTreeNode.
Definition at line 201 of file SHAMapInnerNode.cpp.
| void ripple::SHAMapInnerNode::updateHashDeep | ( | ) | 
Recalculate the hash of all children and this node.
Definition at line 216 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Serialize the node in a format appropriate for sending over the wire.
Implements ripple::SHAMapTreeNode.
Definition at line 231 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Serialize the node in a format appropriate for hashing.
Implements ripple::SHAMapTreeNode.
Definition at line 256 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Reimplemented from ripple::SHAMapTreeNode.
Definition at line 268 of file SHAMapInnerNode.cpp.
      
  | 
  overridevirtual | 
Implements ripple::SHAMapTreeNode.
Definition at line 429 of file SHAMapInnerNode.cpp.
      
  | 
  static | 
Definition at line 131 of file SHAMapInnerNode.cpp.
      
  | 
  static | 
Definition at line 165 of file SHAMapInnerNode.cpp.
      
  | 
  inherited | 
Return the hash of this node.
Definition at line 144 of file SHAMapTreeNode.h.
      
  | 
  staticinherited | 
Definition at line 145 of file SHAMapTreeNode.cpp.
      
  | 
  staticinherited | 
Definition at line 113 of file SHAMapTreeNode.cpp.
      
  | 
  staticprivateinherited | 
Definition at line 35 of file SHAMapTreeNode.cpp.
      
  | 
  staticprivateinherited | 
Definition at line 80 of file SHAMapTreeNode.cpp.
      
  | 
  staticprivateinherited | 
Definition at line 51 of file SHAMapTreeNode.cpp.
      
  | 
  noexceptinherited | 
Definition at line 251 of file IntrusiveRefCounts.h.
      
  | 
  noexceptinherited | 
Definition at line 257 of file IntrusiveRefCounts.h.
      
  | 
  inherited | 
Definition at line 263 of file IntrusiveRefCounts.h.
      
  | 
  inherited | 
Definition at line 312 of file IntrusiveRefCounts.h.
      
  | 
  inherited | 
Definition at line 366 of file IntrusiveRefCounts.h.
      
  | 
  noexceptinherited | 
Definition at line 393 of file IntrusiveRefCounts.h.
      
  | 
  noexceptinherited | 
Definition at line 411 of file IntrusiveRefCounts.h.
      
  | 
  noexceptinherited | 
Definition at line 418 of file IntrusiveRefCounts.h.
      
  | 
  staticprivatenoexceptinherited | 
Definition at line 129 of file CountedObject.h.
      
  | 
  staticconstexpr | 
Each inner node has 16 children (the 'radix tree' part of the map)
Definition at line 39 of file SHAMapInnerNode.h.
      
  | 
  private | 
Opaque type that contains the hashes array (array of type SHAMapHash) and the children array (array of type intr_ptr::SharedPtr<SHAMapInnerNode>). 
Definition at line 46 of file SHAMapInnerNode.h.
      
  | 
  private | 
Definition at line 48 of file SHAMapInnerNode.h.
      
  | 
  private | 
Definition at line 49 of file SHAMapInnerNode.h.
      
  | 
  mutableprivate | 
A bitlock for the children of this node, with one bit per child.
Definition at line 52 of file SHAMapInnerNode.h.
      
  | 
  protectedinherited | 
Definition at line 53 of file SHAMapTreeNode.h.
      
  | 
  protectedinherited | 
Determines the owning SHAMap, if any.
Used for copy-on-write semantics.
If this value is 0, the node is not dirty and does not need to be flushed. It is eligible for sharing and may be included multiple SHAMap instances.
Definition at line 61 of file SHAMapTreeNode.h.
      
  | 
  staticconstexprprivateinherited | 
Definition at line 121 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Definition at line 122 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Definition at line 124 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Definition at line 125 of file IntrusiveRefCounts.h.
      
  | 
  mutableprivateinherited | 
refCounts consists of four fields that are treated atomically: 
partialDestructor function has been started (or is about to be started). This is used to prevent the destructor from running concurrently with the partial destructor. This can easily happen when the last strong pointer release its reference in one thread and starts the partialDestructor, while in another thread the last weak pointer goes out of scope and starts the destructor while the partialDestructor is still running. Both a start and finished bit is needed to handle a corner-case where the last strong pointer goes out of scope, then then last weakPointer goes out of scope, but this happens before the partialDestructor bit is set. It would be possible to use a single bit if it could also be set atomically when the strong count goes to zero and the weak count is non-zero, but that would add complexity (and likely slow down common cases as well).partialDestructor has finished running. See (3) above for more information. Definition at line 160 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Amount to change the strong count when adding or releasing a reference.
Note: The strong count is stored in the low StrongCountNumBits bits of refCounts 
Definition at line 167 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Amount to change the weak count when adding or releasing a reference.
Note: The weak count is stored in the high WeakCountNumBits bits of refCounts 
Definition at line 174 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Flag that is set when the partialDestroy function has started running (or is about to start running).
See description of the refCounts field for a fuller description of this field. 
Definition at line 182 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Flag that is set when the partialDestroy function has finished running.
See description of the refCounts field for a fuller description of this field. 
Definition at line 190 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Mask that will zero out all the count bits and leave the tag bits unchanged. 
Definition at line 196 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Mask that will zero out the tag bits and leave the count bits unchanged. 
Definition at line 202 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Mask that will zero out everything except the strong count.
Definition at line 206 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivateinherited | 
Mask that will zero out everything except the weak count.
Definition at line 211 of file IntrusiveRefCounts.h.