xrpld
Loading...
Searching...
No Matches
SHAMapAccountStateLeafNode.h
1#pragma once
2
3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/basics/IntrusivePointer.h>
5#include <xrpl/basics/SHAMapHash.h>
6#include <xrpl/protocol/HashPrefix.h>
7#include <xrpl/protocol/Serializer.h>
8#include <xrpl/protocol/digest.h>
9#include <xrpl/shamap/SHAMapItem.h>
10#include <xrpl/shamap/SHAMapLeafNode.h>
11#include <xrpl/shamap/SHAMapTreeNode.h>
12
13#include <cstdint>
14#include <utility>
15
16namespace xrpl {
17
22 public CountedObject<SHAMapAccountStateLeafNode>
23{
24public:
25 SHAMapAccountStateLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid)
26 : SHAMapLeafNode(std::move(item), cowid)
27 {
28 updateHash();
29 }
30
32 boost::intrusive_ptr<SHAMapItem const> item,
34 SHAMapHash const& hash)
35 : SHAMapLeafNode(std::move(item), cowid, hash)
36 {
37 }
38
44
46 getType() const final
47 {
49 }
50
51 void
52 updateHash() final
53 {
55 }
56
57 void
59 {
60 s.addRaw(item_->slice());
61 s.addBitString(item_->key());
63 }
64
65 void
67 {
68 s.add32(HashPrefix::LeafNode);
69 s.addRaw(item_->slice());
70 s.addBitString(item_->key());
71 }
72};
73
74} // namespace xrpl
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
void serializeWithPrefix(Serializer &s) const final
Serialize the node in a format appropriate for hashing.
void updateHash() final
Recalculate the hash of this node.
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
SHAMapTreeNodePtr clone(std::uint32_t cowid) const final
Make a copy of this node, setting the owner.
SHAMapNodeType getType() const final
Determines the type of node.
void serializeForWire(Serializer &s) const final
Serialize the node in a format appropriate for sending over the wire.
boost::intrusive_ptr< SHAMapItem const > item_
SHAMapLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
STL namespace.
SharedPtr< T > makeShared(A &&... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
intr_ptr::SharedPtr< SHAMapTreeNode > SHAMapTreeNodePtr
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition digest.h:215
static constexpr unsigned char const kWireTypeAccountState
@ LeafNode
account state
Definition HashPrefix.h:49