xrpld
Loading...
Searching...
No Matches
SHAMapLeafNode.h
1#pragma once
2
3#include <xrpl/basics/SHAMapHash.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/safe_cast.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/shamap/SHAMapItem.h>
8#include <xrpl/shamap/SHAMapNodeID.h>
9#include <xrpl/shamap/SHAMapTreeNode.h>
10
11#include <cstdint>
12#include <string>
13
14namespace xrpl {
15
17{
18protected:
19 boost::intrusive_ptr<SHAMapItem const> item_;
20
21 SHAMapLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid);
22
24 boost::intrusive_ptr<SHAMapItem const> item,
26 SHAMapHash const& hash);
27
28public:
31 operator=(SHAMapLeafNode const&) = delete;
32
33 bool
34 isLeaf() const final
35 {
36 return true;
37 }
38
39 bool
40 isInner() const final
41 {
42 return false;
43 }
44
45 void
46 invariants(bool isRoot = false) const final;
47
48public:
49 boost::intrusive_ptr<SHAMapItem const> const&
50 peekItem() const;
51
59 bool
60 setItem(boost::intrusive_ptr<SHAMapItem const> i);
61
62 std::string
63 getString(SHAMapNodeID const&) const final;
64};
65
71inline uint256 const&
73{
74 XRPL_ASSERT(node.isLeaf(), "xrpl::leafKey : node is a leaf");
75 return safeDowncast<SHAMapLeafNode const&>(node).peekItem()->key();
76}
77
78} // namespace xrpl
boost::intrusive_ptr< SHAMapItem const > item_
SHAMapLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
SHAMapLeafNode(SHAMapLeafNode const &)=delete
bool isInner() const final
Determines if this is an inner node.
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.
bool isLeaf() const final
Determines if this is a leaf node.
SHAMapLeafNode & operator=(SHAMapLeafNode const &)=delete
std::string getString(SHAMapNodeID const &) const final
boost::intrusive_ptr< SHAMapItem const > const & peekItem() const
Identifies a node inside a SHAMap.
SHAMapTreeNode(std::uint32_t cowid) noexcept
Construct a node.
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Dest safeDowncast(Src *s) noexcept
Definition safe_cast.h:84
uint256 const & leafKey(SHAMapTreeNode const &node)
Return the key of the item held by a SHAMap leaf node.
BaseUInt< 256 > uint256
Definition base_uint.h:580