rippled
Loading...
Searching...
No Matches
SHAMapTxLeafNode.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_SHAMAP_SHAMAPTXLEAFNODE_H_INCLUDED
21#define RIPPLE_SHAMAP_SHAMAPTXLEAFNODE_H_INCLUDED
22
23#include <xrpld/shamap/SHAMapItem.h>
24#include <xrpld/shamap/SHAMapLeafNode.h>
25
26#include <xrpl/basics/CountedObject.h>
27#include <xrpl/protocol/HashPrefix.h>
28#include <xrpl/protocol/digest.h>
29
30namespace ripple {
31
33class SHAMapTxLeafNode final : public SHAMapLeafNode,
34 public CountedObject<SHAMapTxLeafNode>
35{
36public:
38 boost::intrusive_ptr<SHAMapItem const> item,
40 : SHAMapLeafNode(std::move(item), cowid)
41 {
42 updateHash();
43 }
44
46 boost::intrusive_ptr<SHAMapItem const> item,
48 SHAMapHash const& hash)
49 : SHAMapLeafNode(std::move(item), cowid, hash)
50 {
51 }
52
54 clone(std::uint32_t cowid) const final override
55 {
56 return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid, hash_);
57 }
58
60 getType() const final override
61 {
63 }
64
65 void
66 updateHash() final override
67 {
68 hash_ =
70 }
71
72 void
73 serializeForWire(Serializer& s) const final override
74 {
75 s.addRaw(item_->slice());
76 s.add8(wireTypeTransaction);
77 }
78
79 void
80 serializeWithPrefix(Serializer& s) const final override
81 {
83 s.addRaw(item_->slice());
84 }
85};
86
87} // namespace ripple
88
89#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:25
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:224
STL namespace.