xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
shamap
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
14
namespace
xrpl
{
15
16
class
SHAMapLeafNode
:
public
SHAMapTreeNode
17
{
18
protected
:
19
boost::intrusive_ptr<SHAMapItem const>
item_
;
20
21
SHAMapLeafNode
(boost::intrusive_ptr<SHAMapItem const> item,
std::uint32_t
cowid
);
22
23
SHAMapLeafNode
(
24
boost::intrusive_ptr<SHAMapItem const> item,
25
std::uint32_t
cowid
,
26
SHAMapHash
const
& hash);
27
28
public
:
29
SHAMapLeafNode
(
SHAMapLeafNode
const
&) =
delete
;
30
SHAMapLeafNode
&
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
48
public:
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
71
inline
UInt256
const&
72
leafKey
(
SHAMapTreeNode
const& node)
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
xrpl::SHAMapHash
Definition
SHAMapHash.h:16
xrpl::SHAMapItem
Definition
SHAMapItem.h:24
xrpl::SHAMapLeafNode::item_
boost::intrusive_ptr< SHAMapItem const > item_
Definition
SHAMapLeafNode.h:19
xrpl::SHAMapLeafNode::SHAMapLeafNode
SHAMapLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition
SHAMapLeafNode.cpp:18
xrpl::SHAMapLeafNode::SHAMapLeafNode
SHAMapLeafNode(SHAMapLeafNode const &)=delete
xrpl::SHAMapLeafNode::isInner
bool isInner() const final
Determines if this is an inner node.
Definition
SHAMapLeafNode.h:40
xrpl::SHAMapLeafNode::invariants
void invariants(bool isRoot=false) const final
Definition
SHAMapLeafNode.cpp:93
xrpl::SHAMapLeafNode::setItem
bool setItem(boost::intrusive_ptr< SHAMapItem const > i)
Set the item that this node points to and update the node's hash.
Definition
SHAMapLeafNode.cpp:47
xrpl::SHAMapLeafNode::isLeaf
bool isLeaf() const final
Determines if this is a leaf node.
Definition
SHAMapLeafNode.h:34
xrpl::SHAMapLeafNode::operator=
SHAMapLeafNode & operator=(SHAMapLeafNode const &)=delete
xrpl::SHAMapLeafNode::getString
std::string getString(SHAMapNodeID const &) const final
Definition
SHAMapLeafNode.cpp:60
xrpl::SHAMapLeafNode::peekItem
boost::intrusive_ptr< SHAMapItem const > const & peekItem() const
Definition
SHAMapLeafNode.cpp:41
xrpl::SHAMapNodeID
Identifies a node inside a SHAMap.
Definition
SHAMapNodeID.h:20
xrpl::SHAMapTreeNode
Definition
SHAMapTreeNode.h:38
xrpl::SHAMapTreeNode::SHAMapTreeNode
SHAMapTreeNode(std::uint32_t cowid) noexcept
Construct a node.
Definition
SHAMapTreeNode.h:58
cstdint
xrpl::SHAMapTreeNode::cowid
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
Definition
SHAMapTreeNode.h:105
std::uint32_t
boost
Definition
IPAddress.h:102
std
STL namespace.
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::leafKey
UInt256 const & leafKey(SHAMapTreeNode const &node)
Return the key of the item held by a SHAMap leaf node.
Definition
SHAMapLeafNode.h:72
xrpl::safeDowncast
Dest safeDowncast(Src *s) noexcept
Definition
safe_cast.h:84
string
Generated by
1.17.0