rippled
Loading...
Searching...
No Matches
SHAMapTxLeafNode.h
1#pragma once
2
3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/protocol/HashPrefix.h>
5#include <xrpl/protocol/digest.h>
6#include <xrpl/shamap/SHAMapItem.h>
7#include <xrpl/shamap/SHAMapLeafNode.h>
8
9namespace xrpl {
10
12class SHAMapTxLeafNode final : public SHAMapLeafNode, public CountedObject<SHAMapTxLeafNode>
13{
14public:
15 SHAMapTxLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid)
16 : SHAMapLeafNode(std::move(item), cowid)
17 {
18 updateHash();
19 }
20
22 boost::intrusive_ptr<SHAMapItem const> item,
24 SHAMapHash const& hash)
25 : SHAMapLeafNode(std::move(item), cowid, hash)
26 {
27 }
28
30 clone(std::uint32_t cowid) const final override
31 {
32 return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid, hash_);
33 }
34
36 getType() const final override
37 {
39 }
40
41 void
42 updateHash() final override
43 {
45 }
46
47 void
48 serializeForWire(Serializer& s) const final override
49 {
50 s.addRaw(item_->slice());
51 s.add8(wireTypeTransaction);
52 }
53
54 void
55 serializeWithPrefix(Serializer& s) const final override
56 {
58 s.addRaw(item_->slice());
59 }
60};
61
62} // namespace xrpl
Tracks the number of instances of an object.
boost::intrusive_ptr< SHAMapItem const > item_
A leaf node for a transaction.
SHAMapNodeType getType() const final override
Determines the type of node.
void serializeForWire(Serializer &s) const final override
Serialize the node in a format appropriate for sending over the wire.
void updateHash() final override
Recalculate the hash of this node.
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
intr_ptr::SharedPtr< SHAMapTreeNode > clone(std::uint32_t cowid) const final override
Make a copy of this node, setting the owner.
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
A shared intrusive pointer class that supports weak pointers.
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
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition digest.h:204
@ transactionID
transaction plus signature to give transaction ID
static constexpr unsigned char const wireTypeTransaction