#pragma once #include #include #include #include #include #include #include #include #include namespace xrpl { class SHAMapLeafNode : public SHAMapTreeNode { protected: boost::intrusive_ptr item_; SHAMapLeafNode(boost::intrusive_ptr item, std::uint32_t cowid); SHAMapLeafNode( boost::intrusive_ptr item, std::uint32_t cowid, SHAMapHash const& hash); public: SHAMapLeafNode(SHAMapLeafNode const&) = delete; SHAMapLeafNode& operator=(SHAMapLeafNode const&) = delete; bool isLeaf() const final { return true; } bool isInner() const final { return false; } void invariants(bool isRoot = false) const final; public: boost::intrusive_ptr const& peekItem() const; /** * Set the item that this node points to and update the node's hash. * * @param i the new item * @return false if the change was, effectively, a noop (that is, if the * hash was unchanged); true otherwise. */ bool setItem(boost::intrusive_ptr i); std::string getString(SHAMapNodeID const&) const final; }; /** * Return the key of the item held by a SHAMap leaf node. * * @param node a node known to be a leaf (see SHAMapTreeNode::isLeaf). */ inline uint256 const& leafKey(SHAMapTreeNode const& node) { XRPL_ASSERT(node.isLeaf(), "xrpl::leafKey : node is a leaf"); return safeDowncast(node).peekItem()->key(); } } // namespace xrpl