rippled
Loading...
Searching...
No Matches
SHAMapTxPlusMetaLeafNode.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 SHAMapTxPlusMetaLeafNode final : public SHAMapLeafNode, public CountedObject<SHAMapTxPlusMetaLeafNode>
13{
14public:
15 SHAMapTxPlusMetaLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid)
16 : SHAMapLeafNode(std::move(item), cowid)
17 {
18 updateHash();
19 }
20
21 SHAMapTxPlusMetaLeafNode(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 override
28 {
29 return intr_ptr::make_shared<SHAMapTxPlusMetaLeafNode>(item_, cowid, hash_);
30 }
31
33 getType() const 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.addBitString(item_->key());
50 }
51
52 void
53 serializeWithPrefix(Serializer& s) const final override
54 {
55 s.add32(HashPrefix::txNode);
56 s.addRaw(item_->slice());
57 s.addBitString(item_->key());
58 }
59};
60
61} // namespace xrpl
Tracks the number of instances of an object.
boost::intrusive_ptr< SHAMapItem const > item_
A leaf node for a transaction and its associated metadata.
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 override
Make a copy of this node, setting the owner.
SHAMapTxPlusMetaLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
SHAMapTxPlusMetaLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
SHAMapNodeType getType() const override
Determines the type of node.
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
void updateHash() final override
Recalculate the hash of this node.
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
@ txNode
transaction plus metadata
static constexpr unsigned char const wireTypeTransactionWithMeta