rippled
Loading...
Searching...
No Matches
SHAMapTxLeafNode.h
1#ifndef XRPL_SHAMAP_SHAMAPTXLEAFNODE_H_INCLUDED
2#define XRPL_SHAMAP_SHAMAPTXLEAFNODE_H_INCLUDED
3
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/protocol/HashPrefix.h>
6#include <xrpl/protocol/digest.h>
7#include <xrpl/shamap/SHAMapItem.h>
8#include <xrpl/shamap/SHAMapLeafNode.h>
9
10namespace ripple {
11
13class SHAMapTxLeafNode final : public SHAMapLeafNode,
14 public CountedObject<SHAMapTxLeafNode>
15{
16public:
18 boost::intrusive_ptr<SHAMapItem const> item,
20 : SHAMapLeafNode(std::move(item), cowid)
21 {
22 updateHash();
23 }
24
26 boost::intrusive_ptr<SHAMapItem const> item,
28 SHAMapHash const& hash)
29 : SHAMapLeafNode(std::move(item), cowid, hash)
30 {
31 }
32
34 clone(std::uint32_t cowid) const final override
35 {
36 return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid, hash_);
37 }
38
40 getType() const final override
41 {
43 }
44
45 void
46 updateHash() final override
47 {
48 hash_ =
50 }
51
52 void
53 serializeForWire(Serializer& s) const final override
54 {
55 s.addRaw(item_->slice());
56 s.add8(wireTypeTransaction);
57 }
58
59 void
60 serializeWithPrefix(Serializer& s) const final override
61 {
63 s.addRaw(item_->slice());
64 }
65};
66
67} // namespace ripple
68
69#endif
Tracks the number of instances of an object.
boost::intrusive_ptr< SHAMapItem const > item_
A leaf node for a transaction.
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
void updateHash() final override
Recalculate the hash of this node.
SHAMapNodeType getType() const final override
Determines the type of node.
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
void serializeForWire(Serializer &s) const final override
Serialize the node in a format appropriate for sending over the wire.
intr_ptr::SharedPtr< SHAMapTreeNode > clone(std::uint32_t cowid) const final override
Make a copy of this node, setting the owner.
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
A shared intrusive pointer class that supports weak pointers.
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
static constexpr unsigned char const wireTypeTransaction
@ transactionID
transaction plus signature to give transaction ID
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition digest.h:205
STL namespace.