20 #ifndef RIPPLE_SHAMAP_SHAMAPINNERNODE_H_INCLUDED
21 #define RIPPLE_SHAMAP_SHAMAPINNERNODE_H_INCLUDED
23 #include <ripple/basics/TaggedCache.h>
24 #include <ripple/beast/utility/Journal.h>
25 #include <ripple/shamap/SHAMapItem.h>
26 #include <ripple/shamap/SHAMapNodeID.h>
27 #include <ripple/shamap/SHAMapTreeNode.h>
28 #include <ripple/shamap/impl/TaggedPointer.h>
188 invariants(
bool is_root =
false)
const override;
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
void serializeWithPrefix(Serializer &) const override
Serialize the node in a format appropriate for hashing.
bool isInner() const override
Determines if this is an inner node.
Tracks the number of instances of an object.
std::shared_ptr< SHAMapTreeNode > clone(std::uint32_t cowid) const override
Make a copy of this node, setting the owner.
TaggedPointer hashesAndChildren_
Opaque type that contains the hashes array (array of type SHAMapHash) and the children array (array o...
std::shared_ptr< SHAMapTreeNode > getChild(int branch)
An immutable linear range of bytes.
static std::shared_ptr< SHAMapTreeNode > makeFullInner(Slice data, SHAMapHash const &hash, bool hashValid)
std::shared_ptr< SHAMapTreeNode > canonicalizeChild(int branch, std::shared_ptr< SHAMapTreeNode > node)
void updateHash() override
Recalculate the hash of this node.
static constexpr unsigned int branchFactor
Each inner node has 16 children (the 'radix tree' part of the map)
void shareChild(int m, std::shared_ptr< SHAMapTreeNode > const &child)
Identifies a node inside a SHAMap.
void iterChildren(F &&f) const
Call the f callback for all 16 (branchFactor) branches - even if the branch is empty.
TaggedPointer is a combination of a pointer and a mask stored in the lowest two bits.
bool isEmptyBranch(int m) const
void iterNonEmptyChildIndexes(F &&f) const
Call the f callback for all non-empty branches.
std::string getString(SHAMapNodeID const &) const override
SHAMapInnerNode & operator=(SHAMapInnerNode const &)=delete
SHAMapHash const & getChildHash(int m) const
void setChild(int m, std::shared_ptr< SHAMapTreeNode > child)
void resizeChildArrays(std::uint8_t toAllocate)
Convert arrays stored in hashesAndChildren_ so they can store the requested number of children.
bool isFullBelow(std::uint32_t generation) const
std::optional< int > getChildIndex(int i) const
Get the child's index inside the hashes or children array (stored in hashesAndChildren_.
void updateHashDeep()
Recalculate the hash of all children and this node.
SHAMapInnerNode(std::uint32_t cowid, std::uint8_t numAllocatedChildren=2)
int getBranchCount() const
SHAMapNodeType getType() const override
Determines the type of node.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void serializeForWire(Serializer &) const override
Serialize the node in a format appropriate for sending over the wire.
bool isLeaf() const override
Determines if this is a leaf node.
static std::shared_ptr< SHAMapTreeNode > makeCompressedInner(Slice data)
SHAMapTreeNode * getChildPointer(int branch)
void setFullBelowGen(std::uint32_t gen)
std::atomic< std::uint16_t > lock_
A bitlock for the children of this node, with one bit per child.
void invariants(bool is_root=false) const override
std::uint32_t fullBelowGen_