1#ifndef XRPL_SHAMAP_SHAMAPTREENODE_H_INCLUDED
2#define XRPL_SHAMAP_SHAMAPTREENODE_H_INCLUDED
4#include <xrpl/basics/IntrusivePointer.h>
5#include <xrpl/basics/IntrusiveRefCounts.h>
6#include <xrpl/basics/SHAMapHash.h>
7#include <xrpl/protocol/Serializer.h>
8#include <xrpl/shamap/SHAMapItem.h>
9#include <xrpl/shamap/SHAMapNodeID.h>
Identifies a node inside a SHAMap.
static intr_ptr::SharedPtr< SHAMapTreeNode > makeAccountState(Slice data, SHAMapHash const &hash, bool hashValid)
static intr_ptr::SharedPtr< SHAMapTreeNode > makeFromPrefix(Slice rawNode, SHAMapHash const &hash)
SHAMapHash const & getHash() const
Return the hash of this node.
virtual void serializeWithPrefix(Serializer &) const =0
Serialize the node in a format appropriate for hashing.
static intr_ptr::SharedPtr< SHAMapTreeNode > makeTransactionWithMeta(Slice data, SHAMapHash const &hash, bool hashValid)
std::uint32_t cowid_
Determines the owning SHAMap, if any.
static intr_ptr::SharedPtr< SHAMapTreeNode > makeFromWire(Slice rawNode)
virtual void serializeForWire(Serializer &) const =0
Serialize the node in a format appropriate for sending over the wire.
virtual SHAMapNodeType getType() const =0
Determines the type of node.
SHAMapTreeNode(SHAMapTreeNode const &)=delete
virtual void partialDestructor()
virtual bool isLeaf() const =0
Determines if this is a leaf node.
virtual bool isInner() const =0
Determines if this is an inner node.
virtual void invariants(bool is_root=false) const =0
SHAMapTreeNode(std::uint32_t cowid) noexcept
Construct a node.
static intr_ptr::SharedPtr< SHAMapTreeNode > makeTransaction(Slice data, SHAMapHash const &hash, bool hashValid)
SHAMapTreeNode & operator=(SHAMapTreeNode const &)=delete
SHAMapTreeNode(std::uint32_t cowid, SHAMapHash const &hash) noexcept
virtual ~SHAMapTreeNode() noexcept=default
virtual std::string getString(SHAMapNodeID const &) const
virtual void updateHash()=0
Recalculate the hash of this node.
A shared intrusive pointer class that supports weak pointers.
An immutable linear range of bytes.
virtual intr_ptr::SharedPtr< SHAMapTreeNode > clone(std::uint32_t cowid) const =0
Make a copy of this node, setting the owner.
void unshare()
If this node is shared with another map, mark it as no longer shared.
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.
static constexpr unsigned char const wireTypeAccountState
static constexpr unsigned char const wireTypeInner
static constexpr unsigned char const wireTypeCompressedInner
static constexpr unsigned char const wireTypeTransactionWithMeta
static constexpr unsigned char const wireTypeTransaction
Implement the strong count, weak count, and bit flags for an intrusive pointer.