rippled
|
Public Member Functions | |
SHAMapInnerNode (std::uint32_t cowid, std::uint8_t numAllocatedChildren=2) | |
SHAMapInnerNode (SHAMapInnerNode const &)=delete | |
SHAMapInnerNode & | operator= (SHAMapInnerNode const &)=delete |
~SHAMapInnerNode () | |
std::shared_ptr< SHAMapTreeNode > | clone (std::uint32_t cowid) const override |
Make a copy of this node, setting the owner. More... | |
SHAMapNodeType | getType () const override |
Determines the type of node. More... | |
bool | isLeaf () const override |
Determines if this is a leaf node. More... | |
bool | isInner () const override |
Determines if this is an inner node. More... | |
bool | isEmpty () const |
bool | isEmptyBranch (int m) const |
int | getBranchCount () const |
SHAMapHash const & | getChildHash (int m) const |
void | setChild (int m, std::shared_ptr< SHAMapTreeNode > child) |
void | shareChild (int m, std::shared_ptr< SHAMapTreeNode > const &child) |
SHAMapTreeNode * | getChildPointer (int branch) |
std::shared_ptr< SHAMapTreeNode > | getChild (int branch) |
std::shared_ptr< SHAMapTreeNode > | canonicalizeChild (int branch, std::shared_ptr< SHAMapTreeNode > node) |
bool | isFullBelow (std::uint32_t generation) const |
void | setFullBelowGen (std::uint32_t gen) |
void | updateHash () override |
Recalculate the hash of this node. More... | |
void | updateHashDeep () |
Recalculate the hash of all children and this node. More... | |
void | serializeForWire (Serializer &) const override |
Serialize the node in a format appropriate for sending over the wire. More... | |
void | serializeWithPrefix (Serializer &) const override |
Serialize the node in a format appropriate for hashing. More... | |
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. More... | |
void | unshare () |
If this node is shared with another map, mark it as no longer shared. More... | |
SHAMapHash const & | getHash () const |
Return the hash of this node. More... | |
Static Public Member Functions | |
static std::shared_ptr< SHAMapTreeNode > | makeFullInner (Slice data, SHAMapHash const &hash, bool hashValid) |
static std::shared_ptr< SHAMapTreeNode > | makeCompressedInner (Slice data) |
static std::shared_ptr< SHAMapTreeNode > | makeFromPrefix (Slice rawNode, SHAMapHash const &hash) |
static std::shared_ptr< 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) More... | |
Protected Attributes | |
SHAMapHash | hash_ |
std::uint32_t | cowid_ |
Determines the owning SHAMap, if any. More... | |
Private Member Functions | |
void | resizeChildArrays (std::uint8_t toAllocate) |
Convert arrays stored in hashesAndChildren_ so they can store the requested number of children. More... | |
std::optional< int > | getChildIndex (int i) const |
Get the child's index inside the hashes or children array (stored in hashesAndChildren_ . More... | |
template<class F > | |
void | iterChildren (F &&f) const |
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty. More... | |
template<class F > | |
void | iterNonEmptyChildIndexes (F &&f) const |
Call the f callback for all non-empty branches. More... | |
Static Private Member Functions | |
static std::shared_ptr< SHAMapTreeNode > | makeTransaction (Slice data, SHAMapHash const &hash, bool hashValid) |
static std::shared_ptr< SHAMapTreeNode > | makeAccountState (Slice data, SHAMapHash const &hash, bool hashValid) |
static std::shared_ptr< 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 std::shared_ptr<SHAMapInnerNode> ). More... | |
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. More... | |
Definition at line 41 of file SHAMapInnerNode.h.
|
explicit |
Definition at line 38 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 62 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 69 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 49 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 56 of file SHAMapInnerNode.cpp.
|
delete |
|
overridevirtual |
Make a copy of this node, setting the owner.
Implements ripple::SHAMapTreeNode.
Definition at line 75 of file SHAMapInnerNode.cpp.
|
overridevirtual |
Determines the type of node.
Implements ripple::SHAMapTreeNode.
Definition at line 120 of file SHAMapInnerNode.h.
|
overridevirtual |
Determines if this is a leaf node.
Implements ripple::SHAMapTreeNode.
Definition at line 126 of file SHAMapInnerNode.h.
|
overridevirtual |
Determines if this is an inner node.
Implements ripple::SHAMapTreeNode.
Definition at line 132 of file SHAMapInnerNode.h.
bool ripple::SHAMapInnerNode::isEmpty | ( | ) | const |
Definition at line 260 of file SHAMapInnerNode.cpp.
bool ripple::SHAMapInnerNode::isEmptyBranch | ( | int | m | ) | const |
Definition at line 198 of file SHAMapInnerNode.h.
int ripple::SHAMapInnerNode::getBranchCount | ( | ) | const |
Definition at line 266 of file SHAMapInnerNode.cpp.
SHAMapHash const & ripple::SHAMapInnerNode::getChildHash | ( | int | m | ) | const |
Definition at line 361 of file SHAMapInnerNode.cpp.
void ripple::SHAMapInnerNode::setChild | ( | int | m, |
std::shared_ptr< SHAMapTreeNode > | child | ||
) |
Definition at line 287 of file SHAMapInnerNode.cpp.
void ripple::SHAMapInnerNode::shareChild | ( | int | m, |
std::shared_ptr< SHAMapTreeNode > const & | child | ||
) |
Definition at line 323 of file SHAMapInnerNode.cpp.
SHAMapTreeNode * ripple::SHAMapInnerNode::getChildPointer | ( | int | branch | ) |
Definition at line 335 of file SHAMapInnerNode.cpp.
std::shared_ptr< SHAMapTreeNode > ripple::SHAMapInnerNode::getChild | ( | int | branch | ) |
Definition at line 348 of file SHAMapInnerNode.cpp.
std::shared_ptr< SHAMapTreeNode > ripple::SHAMapInnerNode::canonicalizeChild | ( | int | branch, |
std::shared_ptr< SHAMapTreeNode > | node | ||
) |
Definition at line 371 of file SHAMapInnerNode.cpp.
bool ripple::SHAMapInnerNode::isFullBelow | ( | std::uint32_t | generation | ) | const |
Definition at line 204 of file SHAMapInnerNode.h.
void ripple::SHAMapInnerNode::setFullBelowGen | ( | std::uint32_t | gen | ) |
Definition at line 210 of file SHAMapInnerNode.h.
|
overridevirtual |
Recalculate the hash of this node.
Implements ripple::SHAMapTreeNode.
Definition at line 196 of file SHAMapInnerNode.cpp.
void ripple::SHAMapInnerNode::updateHashDeep | ( | ) |
Recalculate the hash of all children and this node.
Definition at line 211 of file SHAMapInnerNode.cpp.
|
overridevirtual |
Serialize the node in a format appropriate for sending over the wire.
Implements ripple::SHAMapTreeNode.
Definition at line 226 of file SHAMapInnerNode.cpp.
|
overridevirtual |
Serialize the node in a format appropriate for hashing.
Implements ripple::SHAMapTreeNode.
Definition at line 250 of file SHAMapInnerNode.cpp.
|
overridevirtual |
Reimplemented from ripple::SHAMapTreeNode.
Definition at line 272 of file SHAMapInnerNode.cpp.
|
overridevirtual |
Implements ripple::SHAMapTreeNode.
Definition at line 399 of file SHAMapInnerNode.cpp.
|
static |
Definition at line 126 of file SHAMapInnerNode.cpp.
|
static |
Definition at line 160 of file SHAMapInnerNode.cpp.
|
inherited |
Return the hash of this node.
Definition at line 143 of file SHAMapTreeNode.h.
|
staticinherited |
Definition at line 148 of file SHAMapTreeNode.cpp.
|
staticinherited |
Definition at line 116 of file SHAMapTreeNode.cpp.
|
staticprivateinherited |
Definition at line 40 of file SHAMapTreeNode.cpp.
|
staticprivateinherited |
Definition at line 84 of file SHAMapTreeNode.cpp.
|
staticprivateinherited |
Definition at line 55 of file SHAMapTreeNode.cpp.
|
staticprivatenoexceptinherited |
Definition at line 128 of file CountedObject.h.
|
staticconstexpr |
Each inner node has 16 children (the 'radix tree' part of the map)
Definition at line 46 of file SHAMapInnerNode.h.
|
private |
Opaque type that contains the hashes
array (array of type SHAMapHash
) and the children
array (array of type std::shared_ptr<SHAMapInnerNode>
).
Definition at line 53 of file SHAMapInnerNode.h.
|
private |
Definition at line 55 of file SHAMapInnerNode.h.
|
private |
Definition at line 56 of file SHAMapInnerNode.h.
|
mutableprivate |
A bitlock for the children of this node, with one bit per child.
Definition at line 59 of file SHAMapInnerNode.h.
|
protectedinherited |
Definition at line 56 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 64 of file SHAMapTreeNode.h.