xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
shamap
SHAMapTxPlusMetaLeafNode.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
SHAMapTxPlusMetaLeafNode
final :
public
SHAMapLeafNode
,
22
public
CountedObject
<SHAMapTxPlusMetaLeafNode>
23
{
24
public
:
25
SHAMapTxPlusMetaLeafNode
(boost::intrusive_ptr<SHAMapItem const> item,
std::uint32_t
cowid
)
26
:
SHAMapLeafNode
(
std
::move(item),
cowid
)
27
{
28
updateHash
();
29
}
30
31
SHAMapTxPlusMetaLeafNode
(
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 override
41
{
42
return
intr_ptr::makeShared<SHAMapTxPlusMetaLeafNode>
(
item_
,
cowid
,
hash_
);
43
}
44
45
SHAMapNodeType
46
getType
()
const override
47
{
48
return
SHAMapNodeType::TnTransactionMd
;
49
}
50
51
void
52
updateHash
() final
53
{
54
hash_
=
SHAMapHash
{
sha512Half
(
HashPrefix::TxNode
,
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(
kWireTypeTransactionWithMeta
);
63
}
64
65
void
66
serializeWithPrefix
(
Serializer
& s)
const
final
67
{
68
s.add32(
HashPrefix::TxNode
);
69
s.addRaw(
item_
->slice());
70
s.addBitString(
item_
->key());
71
}
72
};
73
74
}
// namespace xrpl
xrpl::CountedObject< SHAMapTxPlusMetaLeafNode >::CountedObject
CountedObject() noexcept
Definition
CountedObject.h:119
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::SHAMapTxPlusMetaLeafNode::serializeWithPrefix
void serializeWithPrefix(Serializer &s) const final
Serialize the node in a format appropriate for hashing.
Definition
SHAMapTxPlusMetaLeafNode.h:66
xrpl::SHAMapTxPlusMetaLeafNode::updateHash
void updateHash() final
Recalculate the hash of this node.
Definition
SHAMapTxPlusMetaLeafNode.h:52
xrpl::SHAMapTxPlusMetaLeafNode::SHAMapTxPlusMetaLeafNode
SHAMapTxPlusMetaLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition
SHAMapTxPlusMetaLeafNode.h:25
xrpl::SHAMapTxPlusMetaLeafNode::SHAMapTxPlusMetaLeafNode
SHAMapTxPlusMetaLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
Definition
SHAMapTxPlusMetaLeafNode.h:31
xrpl::SHAMapTxPlusMetaLeafNode::serializeForWire
void serializeForWire(Serializer &s) const final
Serialize the node in a format appropriate for sending over the wire.
Definition
SHAMapTxPlusMetaLeafNode.h:58
xrpl::SHAMapTxPlusMetaLeafNode::getType
SHAMapNodeType getType() const override
Determines the type of node.
Definition
SHAMapTxPlusMetaLeafNode.h:46
xrpl::SHAMapTxPlusMetaLeafNode::clone
SHAMapTreeNodePtr clone(std::uint32_t cowid) const override
Make a copy of this node, setting the owner.
Definition
SHAMapTxPlusMetaLeafNode.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::TnTransactionMd
@ TnTransactionMd
Definition
SHAMapTreeNode.h:33
xrpl::kWireTypeTransactionWithMeta
static constexpr unsigned char const kWireTypeTransactionWithMeta
Definition
SHAMapTreeNode.h:25
xrpl::HashPrefix::TxNode
@ TxNode
transaction plus metadata
Definition
HashPrefix.h:44
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