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