1#include <xrpl/shamap/SHAMapLeafNode.h>
3#include <xrpl/basics/SHAMapHash.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/instrumentation.h>
6#include <xrpl/shamap/SHAMapItem.h>
7#include <xrpl/shamap/SHAMapNodeID.h>
8#include <xrpl/shamap/SHAMapTreeNode.h>
10#include <boost/smart_ptr/intrusive_ptr.hpp>
23 "xrpl::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<"
24 "SHAMapItem const>, std::uint32_t) : minimum input size");
28 boost::intrusive_ptr<SHAMapItem const> item,
35 "xrpl::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<"
36 "SHAMapItem const>, std::uint32_t, SHAMapHash const&) : minimum input "
40boost::intrusive_ptr<SHAMapItem const>
const&
49 XRPL_ASSERT(
cowid_,
"xrpl::SHAMapLeafNode::setItem : nonzero cowid");
50 item_ = std::move(item);
52 auto const oldHash =
hash_;
56 return (oldHash !=
hash_);
95 XRPL_ASSERT(
hash_.isNonZero(),
"xrpl::SHAMapLeafNode::invariants : nonzero hash");
96 XRPL_ASSERT(
item_,
"xrpl::SHAMapLeafNode::invariants : non-null item");
boost::intrusive_ptr< SHAMapItem const > item_
SHAMapLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
void invariants(bool isRoot=false) const final
bool setItem(boost::intrusive_ptr< SHAMapItem const > i)
Set the item that this node points to and update the node's hash.
std::string getString(SHAMapNodeID const &) const final
boost::intrusive_ptr< SHAMapItem const > const & peekItem() const
Identifies a node inside a SHAMap.
std::uint32_t cowid_
Determines the owning SHAMap, if any.
virtual SHAMapNodeType getType() const =0
Determines the type of node.
SHAMapTreeNode(std::uint32_t cowid) noexcept
Construct a node.
virtual std::string getString(SHAMapNodeID const &) const
virtual void updateHash()=0
Recalculate the hash of this node.
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.
std::string to_string(BaseUInt< Bits, Tag > const &a)
constexpr std::size_t kMinShaMapItemBytes