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
21 SHAMapTxLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid, SHAMapHash const& hash)
22 : SHAMapLeafNode(std::move(item), cowid, hash)
23 {
24 }
25
27 clone(std::uint32_t cowid) const final override
28 {
29 return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid, hash_);
30 }
31
33 getType() const final override
34 {
36 }
37
38 void
39 updateHash() final override
40 {
42 }
43
44 void
45 serializeForWire(Serializer& s) const final override
46 {
47 s.addRaw(item_->slice());
48 s.add8(wireTypeTransaction);
49 }
50
51 void
52 serializeWithPrefix(Serializer& s) const final override
53 {
55 s.addRaw(item_->slice());
56 }
57};
58
59} // 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