xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
shamap
SHAMapAccountStateLeafNode.h
1
#pragma once
2
3
#include <xrpl/basics/CountedObject.h>
4
#include <xrpl/basics/IntrusivePointer.h>
5
#include <xrpl/basics/SHAMapHash.h>
6
#include <xrpl/protocol/HashPrefix.h>
7
#include <xrpl/protocol/Serializer.h>
8
#include <xrpl/protocol/digest.h>
9
#include <xrpl/shamap/SHAMapItem.h>
10
#include <xrpl/shamap/SHAMapLeafNode.h>
11
#include <xrpl/shamap/SHAMapTreeNode.h>
12
13
#include <
cstdint
>
14
#include <
utility
>
15
16
namespace
xrpl
{
17
21
class
SHAMapAccountStateLeafNode
final :
public
SHAMapLeafNode
,
22
public
CountedObject
<SHAMapAccountStateLeafNode>
23
{
24
public
:
25
SHAMapAccountStateLeafNode
(boost::intrusive_ptr<SHAMapItem const> item,
std::uint32_t
cowid
)
26
:
SHAMapLeafNode
(
std
::move(item),
cowid
)
27
{
28
updateHash
();
29
}
30
31
SHAMapAccountStateLeafNode
(
32
boost::intrusive_ptr<SHAMapItem const> item,
33
std::uint32_t
cowid
,
34
SHAMapHash
const
& hash)
35
:
SHAMapLeafNode
(
std
::move(item),
cowid
, hash)
36
{
37
}
38
39
SHAMapTreeNodePtr
40
clone
(
std::uint32_t
cowid
)
const
final
41
{
42
return
intr_ptr::makeShared<SHAMapAccountStateLeafNode>
(
item_
,
cowid
,
hash_
);
43
}
44
45
SHAMapNodeType
46
getType
() const final
47
{
48
return
SHAMapNodeType::TnAccountState
;
49
}
50
51
void
52
updateHash
() final
53
{
54
hash_
=
SHAMapHash
{
sha512Half
(
HashPrefix::LeafNode
,
item_
->slice(),
item_
->key())};
55
}
56
57
void
58
serializeForWire
(
Serializer
& s)
const
final
59
{
60
s.addRaw(
item_
->slice());
61
s.addBitString(
item_
->key());
62
s.add8(
kWireTypeAccountState
);
63
}
64
65
void
66
serializeWithPrefix
(
Serializer
& s)
const
final
67
{
68
s.add32(
HashPrefix::LeafNode
);
69
s.addRaw(
item_
->slice());
70
s.addBitString(
item_
->key());
71
}
72
};
73
74
}
// namespace xrpl
xrpl::CountedObject< SHAMapAccountStateLeafNode >::CountedObject
CountedObject() noexcept
Definition
CountedObject.h:119
xrpl::SHAMapAccountStateLeafNode::SHAMapAccountStateLeafNode
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
Definition
SHAMapAccountStateLeafNode.h:31
xrpl::SHAMapAccountStateLeafNode::serializeWithPrefix
void serializeWithPrefix(Serializer &s) const final
Serialize the node in a format appropriate for hashing.
Definition
SHAMapAccountStateLeafNode.h:66
xrpl::SHAMapAccountStateLeafNode::updateHash
void updateHash() final
Recalculate the hash of this node.
Definition
SHAMapAccountStateLeafNode.h:52
xrpl::SHAMapAccountStateLeafNode::SHAMapAccountStateLeafNode
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition
SHAMapAccountStateLeafNode.h:25
xrpl::SHAMapAccountStateLeafNode::clone
SHAMapTreeNodePtr clone(std::uint32_t cowid) const final
Make a copy of this node, setting the owner.
Definition
SHAMapAccountStateLeafNode.h:40
xrpl::SHAMapAccountStateLeafNode::getType
SHAMapNodeType getType() const final
Determines the type of node.
Definition
SHAMapAccountStateLeafNode.h:46
xrpl::SHAMapAccountStateLeafNode::serializeForWire
void serializeForWire(Serializer &s) const final
Serialize the node in a format appropriate for sending over the wire.
Definition
SHAMapAccountStateLeafNode.h:58
xrpl::SHAMapHash
Definition
SHAMapHash.h:16
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::SHAMapTreeNode::hash_
SHAMapHash hash_
Definition
SHAMapTreeNode.h:40
xrpl::Serializer
Definition
Serializer.h:23
cstdint
xrpl::SHAMapTreeNode::cowid
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
Definition
SHAMapTreeNode.h:105
std::uint32_t
std
STL namespace.
xrpl::intr_ptr::makeShared
SharedPtr< T > makeShared(A &&... args)
Definition
IntrusivePointer.h:520
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::SHAMapTreeNodePtr
intr_ptr::SharedPtr< SHAMapTreeNode > SHAMapTreeNodePtr
Definition
SHAMapTreeNode.h:17
xrpl::SHAMapNodeType
SHAMapNodeType
Definition
SHAMapTreeNode.h:30
xrpl::SHAMapNodeType::TnAccountState
@ TnAccountState
Definition
SHAMapTreeNode.h:34
xrpl::kWireTypeAccountState
static constexpr unsigned char const kWireTypeAccountState
Definition
SHAMapTreeNode.h:22
xrpl::HashPrefix::LeafNode
@ LeafNode
account state
Definition
HashPrefix.h:49
xrpl::sha512Half
Sha512HalfHasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition
digest.h:215
utility
Generated by
1.17.0