rippled
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 <ripple/basics/CountedObject.h>
24 #include <ripple/protocol/HashPrefix.h>
25 #include <ripple/protocol/digest.h>
26 #include <ripple/shamap/SHAMapItem.h>
27 #include <ripple/shamap/SHAMapLeafNode.h>
28 #include <ripple/shamap/SHAMapNodeID.h>
29 
30 namespace ripple {
31 
33 class SHAMapTxLeafNode final : public SHAMapLeafNode,
34  public CountedObject<SHAMapTxLeafNode>
35 {
36 public:
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 std::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
ripple::SHAMapTreeNode::cowid
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
Definition: SHAMapTreeNode.h:116
ripple::SHAMapTxLeafNode::getType
SHAMapNodeType getType() const final override
Determines the type of node.
Definition: SHAMapTxLeafNode.h:60
ripple::CountedObject
Tracks the number of instances of an object.
Definition: CountedObject.h:124
ripple::SHAMapTxLeafNode::clone
std::shared_ptr< SHAMapTreeNode > clone(std::uint32_t cowid) const final override
Make a copy of this node, setting the owner.
Definition: SHAMapTxLeafNode.h:54
std::shared_ptr
STL class.
ripple::SHAMapNodeType
SHAMapNodeType
Definition: SHAMapTreeNode.h:46
ripple::wireTypeTransaction
static constexpr unsigned const char wireTypeTransaction
Definition: SHAMapTreeNode.h:40
ripple::SHAMapTxLeafNode
A leaf node for a transaction.
Definition: SHAMapTxLeafNode.h:33
ripple::SHAMapTreeNode::hash_
SHAMapHash hash_
Definition: SHAMapTreeNode.h:56
ripple::SHAMapTxLeafNode::serializeForWire
void serializeForWire(Serializer &s) const final override
Serialize the node in a format appropriate for sending over the wire.
Definition: SHAMapTxLeafNode.h:73
ripple::SHAMapLeafNode
Definition: SHAMapLeafNode.h:32
ripple::SHAMapHash
Definition: SHAMapHash.h:32
ripple::SHAMapNodeType::tnTRANSACTION_NM
@ tnTRANSACTION_NM
ripple::SHAMapTxLeafNode::SHAMapTxLeafNode
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
Definition: SHAMapTxLeafNode.h:45
ripple::HashPrefix::transactionID
@ transactionID
transaction plus signature to give transaction ID
std::uint32_t
ripple::SHAMapLeafNode::item_
boost::intrusive_ptr< SHAMapItem const > item_
Definition: SHAMapLeafNode.h:35
ripple::SHAMapTxLeafNode::SHAMapTxLeafNode
SHAMapTxLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
Definition: SHAMapTxLeafNode.h:37
ripple::Serializer
Definition: Serializer.h:39
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
ripple::sha512Half
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition: digest.h:216
ripple::SHAMapTxLeafNode::serializeWithPrefix
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
Definition: SHAMapTxLeafNode.h:80
ripple::SHAMapTxLeafNode::updateHash
void updateHash() final override
Recalculate the hash of this node.
Definition: SHAMapTxLeafNode.h:66